org.apache.oozie.service
Class MemoryLocksService

java.lang.Object
  extended by org.apache.oozie.service.MemoryLocksService
All Implemented Interfaces:
Service, Instrumentable

public class MemoryLocksService
extends Object
implements Service, Instrumentable


Field Summary
 
Fields inherited from interface org.apache.oozie.service.Service
CONF_PREFIX, DEFAULT_LOCK_TIMEOUT, lockTimeout, USE_XCOMMAND
 
Constructor Summary
MemoryLocksService()
           
 
Method Summary
 void destroy()
          Destroy the memory locks service.
 Class<? extends Service> getInterface()
          Return the public interface for the memory locks services
 MemoryLocks.LockToken getReadLock(String resource, long wait)
          Obtain a READ lock for a source.
 MemoryLocks.LockToken getWriteLock(String resource, long wait)
          Obtain a WRITE lock for a source.
 void init(Services services)
          Initialize the memory locks service
 void instrument(Instrumentation instr)
          Instruments the memory locks service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryLocksService

public MemoryLocksService()
Method Detail

init

public void init(Services services)
Initialize the memory locks service

Specified by:
init in interface Service
Parameters:
services - services instance.

destroy

public void destroy()
Destroy the memory locks service.

Specified by:
destroy in interface Service

getInterface

public Class<? extends Service> getInterface()
Return the public interface for the memory locks services

Specified by:
getInterface in interface Service
Returns:
MemoryLocksService.

instrument

public void instrument(Instrumentation instr)
Instruments the memory locks service.

Specified by:
instrument in interface Instrumentable
Parameters:
instr - instance to instrument the memory locks service to.

getReadLock

public MemoryLocks.LockToken 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 MemoryLocks.LockToken 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 © 2013 Apache Software Foundation. All Rights Reserved.