EAC Toolkit 3.2.1

com.endeca.soleng.eac.toolkit.base
Class LockManager

java.lang.Object
  extended by com.endeca.soleng.eac.toolkit.base.EacElement
      extended by com.endeca.soleng.eac.toolkit.base.Synchronizable
          extended by com.endeca.soleng.eac.toolkit.base.LockManager

public class LockManager
extends Synchronizable

Lock Manager used to acquire, track and release locks. A lock manager is associated with most applications. A pointer to the lock manager is inherited by every object defined in the application, allowing all objects a common interface to set and test flags and locks. This also allows the toolkit controller to release any locks obtained during script execution if a failure occurs. If this behavior is not desired, the lock manager can be configured not to release locks on failure.

Author:
sshusteff

Field Summary
 
Fields inherited from class com.endeca.soleng.eac.toolkit.base.EacElement
appName, dataPrefix, eacHost, eacPort, elementId, lockManager, logDir, sslEnabled, workingDir
 
Constructor Summary
LockManager()
           
 
Method Summary
 boolean acquireLock()
          Convenience wrapper that calls acquireLock(String) with a null string.
 boolean acquireLock(java.lang.String lockName)
          Tries to acquire a lock.
 boolean acquireLockBlocking(long maxWaitSeconds)
          Convenience wrapper that calls acquireLockBlocking(String) with a null string.
 boolean acquireLockBlocking(java.lang.String lockName, long maxWaitSeconds)
          Tries to acquire a lock.
 void addHeldLock(java.lang.String lockName)
          Adds a lock to the list of held locks.
 java.util.List<java.lang.String> getHeldLocks()
          Gets a list of held locks.
 boolean isLockHeld(java.lang.String lockName)
          Determined whether the specified lock is held by this object.
 boolean isReleaseLocksOnFailure()
           
 void releaseHeldLocks()
          Releases all locks held by this object.
 void releaseLock()
          Convenience wrapper that calls releaseLock(String) with a null string.
 void releaseLock(java.lang.String lockName)
          Releases a lock.
 void removeHeldLock(java.lang.String lockName)
          Removes a lock from the list of held locks.
 void setHeldLocks(java.util.List<java.lang.String> heldLocks)
          Sets a list of held locks.
 void setReleaseLocksOnFailure(boolean releaseLocksOnFailure)
           
 
Methods inherited from class com.endeca.soleng.eac.toolkit.base.Synchronizable
isFlagSet, listFlags, removeFlag, setFlag, waitForFlagSet
 
Methods inherited from class com.endeca.soleng.eac.toolkit.base.EacElement
getAppName, getDataPrefix, getEacHost, getEacPort, getElementId, getLockManager, getLogDir, getWorkingDir, isSslEnabled, setAppName, setDataPrefix, setEacHost, setEacPort, setElementId, setLockManager, setLogDir, setSslEnabled, setWorkingDir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockManager

public LockManager()
Method Detail

acquireLock

public boolean acquireLock(java.lang.String lockName)
Tries to acquire a lock. If no name is specified, the lock is named after this object's class.

Parameters:
lockName - The name of the lock to acquire, or null to indicate that the class name should be used as the lock name.
Returns:
Returns true if the lock is obtained.

acquireLock

public boolean acquireLock()
                    throws EacCommunicationException,
                           EacSynchronizationException
Convenience wrapper that calls acquireLock(String) with a null string.

Throws:
EacCommunicationException
EacSynchronizationException

acquireLockBlocking

public boolean acquireLockBlocking(java.lang.String lockName,
                                   long maxWaitSeconds)
Tries to acquire a lock. If no name is specified, the lock is named after this object's class. If the lock can't be obtained, this method will poll until the lock is obtained, or the maximum wait time expires.

Parameters:
lockName - The name of the lock to acquire, or null to indicate that the class name should be used as the lock name.
maxWaitSeconds - Maximum number of seconds to try to acquire lock.
Returns:
Returns true if the lock is obtained.

acquireLockBlocking

public boolean acquireLockBlocking(long maxWaitSeconds)
                            throws EacCommunicationException,
                                   EacSynchronizationException
Convenience wrapper that calls acquireLockBlocking(String) with a null string.

Throws:
EacCommunicationException
EacSynchronizationException

releaseLock

public void releaseLock(java.lang.String lockName)
Releases a lock. If no name is specified, the lock is named after this object's class.

Parameters:
lockName - The name of the lock to remove, or null to indicate that the class name should be used as the lock name.

releaseLock

public void releaseLock()
Convenience wrapper that calls releaseLock(String) with a null string.


getHeldLocks

public java.util.List<java.lang.String> getHeldLocks()
Gets a list of held locks.

Returns:
Returns the list of held locks or null, if uninitialized.

setHeldLocks

public void setHeldLocks(java.util.List<java.lang.String> heldLocks)
Sets a list of held locks.

Parameters:
heldLocks - List to set.

addHeldLock

public void addHeldLock(java.lang.String lockName)
Adds a lock to the list of held locks.

Parameters:
lockName - Name of the lock to add.

removeHeldLock

public void removeHeldLock(java.lang.String lockName)
Removes a lock from the list of held locks.

Parameters:
lockName - Name of the lock to remove.

isLockHeld

public boolean isLockHeld(java.lang.String lockName)
Determined whether the specified lock is held by this object.

Parameters:
lockName - Name of the lock to test.
Returns:
Returns true if this object has the specified lock.

releaseHeldLocks

public void releaseHeldLocks()
Releases all locks held by this object.


isReleaseLocksOnFailure

public boolean isReleaseLocksOnFailure()

setReleaseLocksOnFailure

public void setReleaseLocksOnFailure(boolean releaseLocksOnFailure)

EAC Toolkit 3.2.1

Copyright © 2011 Endeca Technologies, Inc. All Rights Reserved.
@VERSION
PRODUCT: EAC Toolkit (eacToolkit)
VERSION: 3.2.1
BUILD:   NONE
ARCH_OS: n/a
DATE:    2011-11-10T16:21:05-0500