Sun Java System Web Server 6.1 SP12 Administrator's Guide

Locking and Unlocking Resources

Sun Java System Web Server allows the server administrator to lock a resource so as to serialize access to that resource. Using a lock, a user accessing a particular resource is reassured that another user will not modify the same resource. In this way, the "lost updates" problem is resolved as multiple users share resources on the server. The lock database maintained by the server keeps track of the lock tokens issued and in use by clients.

Sun Java System Web Server 6.1 supports the opaquelocktoken URI scheme, which is designed to be unique across all resources for all time. This uses the Universal Unique Identifier (UUID) mechanism, as described in ISO-11578.

Sun Java System Web Server 6.1 recognizes two types of locking mechanisms:

Exclusive Locks

An exclusive lock is a lock that grants access to a resource to only a single user. Another user can access the same resource only after the exclusive lock on the resource is removed.

Exclusive locking sometimes proves to be too rigid and expensive a mechanism for locking resources. For example, in the event of a program crash or the lock owner forgetting to unlock the resource, a lock timeout or the administrator’s intervention would be required to remove the exclusive lock.

Shared Locks

A shared lock allows multiple users to receive a lock to a resource. Hence any user with appropriate access can get the lock.

When using shared locks, lock owners may use any other communication channel to coordinate their work. The intent of a shared lock is to let collaborators know who else may be working on a resource.

Lock Management

Sun Java System Web Server 6.1 provides a lock management feature which allows you to view all outstanding locks, their type, the resources they hold, the duration of the lock and so on.

To use lock management, perform the following steps.

ProcedureTo use lock management

  1. Access the WebDAV-enabled virtual server.

  2. Click the WebDAV tab.

  3. Click the Lock Management link.

  4. Select the locking database and the WebDAV-enabled URI for which you want to view the outstanding locks and other information.

  5. Click List Lock Info.

Minimum Lock Timeout

You can control locking by configuring the value of the minlocktimeout attribute of the DAV or DAVCOLLECTION objects in the server.xml file. The minlocktimeout attribute specifies the minimum lifetime of a lock in seconds. This value indicates the amount of time that an element will be locked before the lock is automatically removed.

This is an optional attribute. If the value is set to -1, the lock will never expire. Setting the value to 0 allows all the resources in the collection to be locked with the Timeout header specified in the request.

If no Timeout header is specified, then the resource is locked with infinite timeout. If a request has a Timeout header set to the value Infinite, then also, the resource is locked with infinite timeout.

If the request for a WebDAV resource has a Timeout header value that is equal to or greater than the minlocktimeout value specified in server.xml, then the resource is locked for the period of time specified in the request.

However, if the request has a Timeout header value that is lower than the minlocktimeout value specified in server.xml, then the resource is locked with the minlocktimeout value specified in server.xml.

The following table illustrates how Sun Java System Web Server handles locking requests:

Table 19–3 How Sun Java System Web Server handles locking requests

If Timeout header value in Request is set to:  

The resource is:  

Infinite

Locked with timeout set to -1 (infinite) 

None 

Locked with timeout set to -1 (infinite) 

Second-xxx

  • Locked with xxx value, if xxx is equal to or greater than minlocktimeout value set in server.xml

    or

  • locked with minlocktimeout value specified in server.xml, if xxx is lower than minlocktimeout value set in server.xml.

Example of a Lock Request

This example illustrates a request for an exclusive write lock on the resource /col1/myfile.html with a timeout of 500 seconds.


LOCK /col1/myfile.html HTTP/1.1
Host: sun
Content-Type: text/xml; charset=”utf-8”
Content-Length: 259
Timeout: Second-500
<?xml version=”1.0” encoding=”utf-8” ?>
<d:lockinfo xmlns:d=”DAV:”>
    <d:locktype><d:write></d:locktype>
    <d:lockscope><d:exclusive></d:lockscope>
    <d:owner>
        <d:href>http://info.sun.com/resources/info.html</d:href>
    </d:owner>
</d:lockinfo>