com.bigdata.journal
Interface IResourceLockService

All Known Implementing Classes:
ResourceLockService, ZooResourceLockService

public interface IResourceLockService

Interface named synchronous distributed locks without deadlock detection.

Version:
$Id: IResourceLockService.java 2265 2009-10-26 12:51:06Z thompsonbry $ FIXME Two features need to be teased apart. On the one hand there are full tx, which provide deadlock detection and could support hierarchical locking (with changes to the lock manager to decouple threads from lock queues, the imposition of a path syntax on the resource names, and perhaps the introduction of 2PL lock modes {S,I,X}). This lock manager could then be exposed, providing applications with the possibility of 2PL, but bigdata does not require that in and of itself (it might be of interest for others).

The other feature is distributed locks without deadlock detection. This is the kind of lock that you get with zookeeper. When running in a single JVM java.util.concurrent.locks provides this kind of locking. These locks are good for coordinating actions such as who is the master in some computation.

This second role (global synchronous locks without deadlock detection) can be realized by a client library. When running in a single JVM, the java.util.concurrent.locks package can provide the implementation. When running in a distributed environment, zookeeper can provide the implementation. FIXME The main use of this interface today is creating and destroying relations, relation containers, and their indices "atomically". Unisolated operations CAN NOT be used to create more than a single resource atomically. A full tx should be used instead. The place where this happens is AbstractResource.acquireExclusiveLock(). That is invoked only when creating or destroying a resource. All callers should be using a full tx instead when creating or destroying a resource!

Author:
Bryan Thompson

Method Summary
 IResourceLock acquireLock(String namespace)
          Acquire an exclusive lock on the named resource.
 IResourceLock acquireLock(String namespace, long timeout)
          Acquire an exclusive lock the named resource.
 

Method Detail

acquireLock

IResourceLock acquireLock(String namespace)
Acquire an exclusive lock on the named resource. The request will block until the lock is available.

Parameters:
namespace - The named resource.
Returns:
The lock.
Throws:
RuntimeException - wrapping InterruptedException or TimeoutException

acquireLock

IResourceLock acquireLock(String namespace,
                          long timeout)
                          throws InterruptedException,
                                 TimeoutException
Acquire an exclusive lock the named resource. The request will block until the lock is available or the timeout expires.

Parameters:
namespace - The named resource.
timeout - Timeout in milliseconds for the request -or- Long.MAX_VALUE to wait forever.
Returns:
The lock.
Throws:
TimeoutException
InterruptedException


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.