Package org.apache.activemq.broker
Interface Locker
-
- All Superinterfaces:
Service
- All Known Implementing Classes:
AbstractJDBCLocker
,AbstractLocker
,DefaultDatabaseLocker
,LeaseDatabaseLocker
,SharedFileLocker
,TransactDatabaseLocker
public interface Locker extends Service
Represents a lock service to ensure that a broker is the only master
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
configure(PersistenceAdapter persistenceAdapter)
Optionally configure the locker with the persistence adapter currently used You can use persistence adapter configuration details like, data directory datasource, etc.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 lockable)
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.
-
-
-
Method Detail
-
keepAlive
boolean keepAlive() throws IOException
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- Throws:
IOException
-
setLockAcquireSleepInterval
void setLockAcquireSleepInterval(long lockAcquireSleepInterval)
set the delay interval in milliseconds between lock acquire attempts- Parameters:
lockAcquireSleepInterval
- the sleep interval in miliseconds
-
setName
void setName(String name)
Set the name of the lock to use.
-
setFailIfLocked
void setFailIfLocked(boolean failIfLocked)
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.- Parameters:
failIfLocked
- true => fail immediately if the lock is held; false => block until the lock can be obtained (default).
-
setLockable
void setLockable(LockableServiceSupport lockable)
A reference to what is locked
-
configure
void configure(PersistenceAdapter persistenceAdapter) throws IOException
Optionally configure the locker with the persistence adapter currently used You can use persistence adapter configuration details like, data directory datasource, etc. to be used by the locker- Parameters:
persistenceAdapter
-- Throws:
IOException
-
-