org.apache.oozie.lock
Class MemoryLocks

java.lang.Object
  extended by org.apache.oozie.lock.MemoryLocks

public class MemoryLocks
extends Object

In memory resource locking that provides READ/WRITE lock capabilities.


Constructor Summary
MemoryLocks()
           
 
Method Summary
 org.apache.oozie.lock.MemoryLocks.MemoryLockToken getReadLock(String resource, long wait)
          Obtain a READ lock for a source.
 org.apache.oozie.lock.MemoryLocks.MemoryLockToken getWriteLock(String resource, long wait)
          Obtain a WRITE lock for a source.
 int size()
          Return the number of active locks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryLocks

public MemoryLocks()
Method Detail

size

public int size()
Return the number of active locks.

Returns:
the number of active locks.

getReadLock

public org.apache.oozie.lock.MemoryLocks.MemoryLockToken getReadLock(String resource,
                                                                     long wait)
                                                              throws InterruptedException
Obtain a READ lock for a source.

Parameters:
resource - resource name.
wait - time out in milliseconds to wait for the lock, -1 means no timeout and 0 no wait.
Returns:
the lock token for the resource, or null if the lock could not be obtained.
Throws:
InterruptedException - thrown if the thread was interrupted while waiting.

getWriteLock

public org.apache.oozie.lock.MemoryLocks.MemoryLockToken getWriteLock(String resource,
                                                                      long wait)
                                                               throws InterruptedException
Obtain a WRITE lock for a source.

Parameters:
resource - resource name.
wait - time out in milliseconds to wait for the lock, -1 means no timeout and 0 no wait.
Returns:
the lock token for the resource, or null if the lock could not be obtained.
Throws:
InterruptedException - thrown if the thread was interrupted while waiting.


Copyright © 2015 Apache Software Foundation. All Rights Reserved.