Package org.apache.activemq.broker
Class AbstractLocker
- java.lang.Object
-
- org.apache.activemq.util.ServiceSupport
-
- org.apache.activemq.broker.AbstractLocker
-
- Direct Known Subclasses:
AbstractJDBCLocker,SharedFileLocker
public abstract class AbstractLocker extends ServiceSupport implements Locker
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_LOCK_ACQUIRE_SLEEP_INTERVALprotected booleanfailIfLockedprotected LockableServiceSupportlockableprotected longlockAcquireSleepIntervalprotected Stringname
-
Constructor Summary
Constructors Constructor Description AbstractLocker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetLockAcquireSleepInterval()booleankeepAlive()Used by a timer to keep alive the lock.voidsetFailIfLocked(boolean failIfLocked)Specify whether to fail immediately if the lock is already held.voidsetLockable(LockableServiceSupport lockableServiceSupport)A reference to what is lockedvoidsetLockAcquireSleepInterval(long lockAcquireSleepInterval)set the delay interval in milliseconds between lock acquire attemptsvoidsetName(String name)Set the name of the lock to use.-
Methods inherited from class org.apache.activemq.util.ServiceSupport
addServiceListener, dispose, doStart, doStop, isStarted, isStopped, isStopping, postStop, preStart, removeServiceListener, start, stop
-
-
-
-
Field Detail
-
DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL
public static final long DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL
- See Also:
- Constant Field Values
-
name
protected String name
-
failIfLocked
protected boolean failIfLocked
-
lockAcquireSleepInterval
protected long lockAcquireSleepInterval
-
lockable
protected LockableServiceSupport lockable
-
-
Method Detail
-
keepAlive
public boolean keepAlive() throws IOExceptionDescription copied from interface:LockerUsed by a timer to keep alive the lock. If the method returns false the broker should be terminated if an exception is thrown, the lock state cannot be determined- Specified by:
keepAlivein interfaceLocker- Throws:
IOException
-
setLockAcquireSleepInterval
public void setLockAcquireSleepInterval(long lockAcquireSleepInterval)
Description copied from interface:Lockerset the delay interval in milliseconds between lock acquire attempts- Specified by:
setLockAcquireSleepIntervalin interfaceLocker- Parameters:
lockAcquireSleepInterval- the sleep interval in miliseconds
-
getLockAcquireSleepInterval
public long getLockAcquireSleepInterval()
-
setName
public void setName(String name)
Description copied from interface:LockerSet the name of the lock to use.
-
setFailIfLocked
public void setFailIfLocked(boolean failIfLocked)
Description copied from interface:LockerSpecify whether to fail immediately if the lock is already held. When set, the CustomLock must throw an IOException immediately upon detecting the lock is already held.- Specified by:
setFailIfLockedin interfaceLocker- Parameters:
failIfLocked- true => fail immediately if the lock is held; false => block until the lock can be obtained (default).
-
setLockable
public void setLockable(LockableServiceSupport lockableServiceSupport)
Description copied from interface:LockerA reference to what is locked- Specified by:
setLockablein interfaceLocker
-
-