Package org.apache.activemq.store.jdbc
Class DefaultDatabaseLocker
- java.lang.Object
-
- org.apache.activemq.util.ServiceSupport
-
- org.apache.activemq.broker.AbstractLocker
-
- org.apache.activemq.store.jdbc.AbstractJDBCLocker
-
- org.apache.activemq.store.jdbc.DefaultDatabaseLocker
-
- Direct Known Subclasses:
TransactDatabaseLocker
public class DefaultDatabaseLocker extends AbstractJDBCLocker
Represents an exclusive lock on a database to avoid multiple brokers running against the same logical database.
-
-
Field Summary
Fields Modifier and Type Field Description protected Connection
connection
protected Handler<Exception>
exceptionHandler
protected PreparedStatement
lockCreateStatement
protected PreparedStatement
lockUpdateStatement
-
Fields inherited from class org.apache.activemq.store.jdbc.AbstractJDBCLocker
createTablesOnStartup, dataSource, jdbcAdapter, queryTimeout
-
Fields inherited from class org.apache.activemq.broker.AbstractLocker
DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL, failIfLocked, lockable, lockAcquireSleepInterval, name
-
-
Constructor Summary
Constructors Constructor Description DefaultDatabaseLocker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doStart()
void
doStop(ServiceStopper stopper)
Handler
getExceptionHandler()
long
getLockAcquireSleepInterval()
boolean
keepAlive()
Used by a timer to keep alive the lock.void
setExceptionHandler(Handler exceptionHandler)
void
setLockAcquireSleepInterval(long lockAcquireSleepInterval)
set the delay interval in milliseconds between lock acquire attempts-
Methods inherited from class org.apache.activemq.store.jdbc.AbstractJDBCLocker
close, close, configure, getConnection, getQueryTimeout, getStatements, preStart, setCreateTablesOnStartup, setDataSource, setQueryTimeout, setQueryTimeout, setStatements
-
Methods inherited from class org.apache.activemq.broker.AbstractLocker
setFailIfLocked, setLockable, setName
-
Methods inherited from class org.apache.activemq.util.ServiceSupport
addServiceListener, dispose, isStarted, isStopped, isStopping, postStop, removeServiceListener, start, stop
-
-
-
-
Field Detail
-
lockCreateStatement
protected volatile PreparedStatement lockCreateStatement
-
lockUpdateStatement
protected volatile PreparedStatement lockUpdateStatement
-
connection
protected volatile Connection connection
-
-
Method Detail
-
doStart
public void doStart() throws Exception
- Specified by:
doStart
in classServiceSupport
- Throws:
Exception
-
doStop
public void doStop(ServiceStopper stopper) throws Exception
- Specified by:
doStop
in classServiceSupport
- Throws:
Exception
-
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
- Overrides:
keepAlive
in classAbstractLocker
- Throws:
IOException
-
getLockAcquireSleepInterval
public long getLockAcquireSleepInterval()
- Overrides:
getLockAcquireSleepInterval
in classAbstractLocker
-
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
- Overrides:
setLockAcquireSleepInterval
in classAbstractLocker
- Parameters:
lockAcquireSleepInterval
- the sleep interval in miliseconds
-
getExceptionHandler
public Handler getExceptionHandler()
-
setExceptionHandler
public void setExceptionHandler(Handler exceptionHandler)
-
-