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 long
DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL
protected boolean
failIfLocked
protected LockableServiceSupport
lockable
protected long
lockAcquireSleepInterval
protected String
name
-
Constructor Summary
Constructors Constructor Description AbstractLocker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getLockAcquireSleepInterval()
boolean
keepAlive()
Used by a timer to keep alive the lock.void
setFailIfLocked(boolean failIfLocked)
Specify whether to fail immediately if the lock is already held.void
setLockable(LockableServiceSupport lockableServiceSupport)
A reference to what is lockedvoid
setLockAcquireSleepInterval(long lockAcquireSleepInterval)
set the delay interval in milliseconds between lock acquire attemptsvoid
setName(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 IOException
Description copied from interface:Locker
Used 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:
keepAlive
in interfaceLocker
- Throws:
IOException
-
setLockAcquireSleepInterval
public void setLockAcquireSleepInterval(long lockAcquireSleepInterval)
Description copied from interface:Locker
set the delay interval in milliseconds between lock acquire attempts- Specified by:
setLockAcquireSleepInterval
in interfaceLocker
- Parameters:
lockAcquireSleepInterval
- the sleep interval in miliseconds
-
getLockAcquireSleepInterval
public long getLockAcquireSleepInterval()
-
setName
public void setName(String name)
Description copied from interface:Locker
Set the name of the lock to use.
-
setFailIfLocked
public void setFailIfLocked(boolean failIfLocked)
Description copied from interface:Locker
Specify 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:
setFailIfLocked
in 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:Locker
A reference to what is locked- Specified by:
setLockable
in interfaceLocker
-
-