Package org.apache.activemq.store.jdbc
Class LeaseDatabaseLocker
- java.lang.Object
-
- org.apache.activemq.util.ServiceSupport
-
- org.apache.activemq.broker.AbstractLocker
-
- org.apache.activemq.store.jdbc.AbstractJDBCLocker
-
- org.apache.activemq.store.jdbc.LeaseDatabaseLocker
-
public class LeaseDatabaseLocker extends AbstractJDBCLocker
Represents an exclusive lease on a database to avoid multiple brokers running against the same logical database.
-
-
Field Summary
Fields Modifier and Type Field Description protected longdiffFromCurrentTimeprotected booleanhandleStartExceptionprotected StringleaseHolderIdprotected intmaxAllowableDiffFromDBTime-
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 LeaseDatabaseLocker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected longdetermineTimeDifference(Connection connection)voiddoStart()voiddoStop(ServiceStopper stopper)StringgetLeaseHolderId()intgetMaxAllowableDiffFromDBTime()protected longinitTimeDiff(Connection connection)booleanisHandleStartException()booleankeepAlive()Used by a timer to keep alive the lock.voidsetHandleStartException(boolean handleStartException)voidsetLeaseHolderId(String leaseHolderId)voidsetMaxAllowableDiffFromDBTime(int maxAllowableDiffFromDBTime)StringtoString()-
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
getLockAcquireSleepInterval, setFailIfLocked, setLockable, setLockAcquireSleepInterval, setName
-
Methods inherited from class org.apache.activemq.util.ServiceSupport
addServiceListener, dispose, isStarted, isStopped, isStopping, postStop, removeServiceListener, start, stop
-
-
-
-
Field Detail
-
maxAllowableDiffFromDBTime
protected int maxAllowableDiffFromDBTime
-
diffFromCurrentTime
protected long diffFromCurrentTime
-
leaseHolderId
protected String leaseHolderId
-
handleStartException
protected boolean handleStartException
-
-
Method Detail
-
doStart
public void doStart() throws Exception- Specified by:
doStartin classServiceSupport- Throws:
Exception
-
initTimeDiff
protected long initTimeDiff(Connection connection) throws SQLException
- Throws:
SQLException
-
determineTimeDifference
protected long determineTimeDifference(Connection connection) throws SQLException
- Throws:
SQLException
-
doStop
public void doStop(ServiceStopper stopper) throws Exception
- Specified by:
doStopin classServiceSupport- Throws:
Exception
-
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- Overrides:
keepAlivein classAbstractLocker- Throws:
IOException
-
getLeaseHolderId
public String getLeaseHolderId()
-
setLeaseHolderId
public void setLeaseHolderId(String leaseHolderId)
-
getMaxAllowableDiffFromDBTime
public int getMaxAllowableDiffFromDBTime()
-
setMaxAllowableDiffFromDBTime
public void setMaxAllowableDiffFromDBTime(int maxAllowableDiffFromDBTime)
-
isHandleStartException
public boolean isHandleStartException()
-
setHandleStartException
public void setHandleStartException(boolean handleStartException)
-
-