org.apache.activemq.store.jdbc
Class LeaseDatabaseLocker

java.lang.Object
  extended by org.apache.activemq.util.ServiceSupport
      extended by org.apache.activemq.broker.AbstractLocker
          extended by org.apache.activemq.store.jdbc.AbstractJDBCLocker
              extended by org.apache.activemq.store.jdbc.LeaseDatabaseLocker
All Implemented Interfaces:
Locker, Service

public class LeaseDatabaseLocker
extends AbstractJDBCLocker

Represents an exclusive lease on a database to avoid multiple brokers running against the same logical database.


Field Summary
protected  long diffFromCurrentTime
           
protected  String leaseHolderId
           
protected  int maxAllowableDiffFromDBTime
           
 
Fields inherited from class org.apache.activemq.store.jdbc.AbstractJDBCLocker
createTablesOnStartup, dataSource, queryTimeout, statements
 
Fields inherited from class org.apache.activemq.broker.AbstractLocker
DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL, failIfLocked, lockable, lockAcquireSleepInterval, name
 
Constructor Summary
LeaseDatabaseLocker()
           
 
Method Summary
protected  long determineTimeDifference(Connection connection)
           
 void doStart()
           
 void doStop(ServiceStopper stopper)
           
 String getLeaseHolderId()
           
 int getMaxAllowableDiffFromDBTime()
           
protected  long initTimeDiff(Connection connection)
           
 boolean keepAlive()
          Used by a timer to keep alive the lock.
 void setLeaseHolderId(String leaseHolderId)
           
 void setMaxAllowableDiffFromDBTime(int maxAllowableDiffFromDBTime)
           
 String toString()
           
 
Methods inherited from class org.apache.activemq.store.jdbc.AbstractJDBCLocker
close, close, configure, getConnection, getQueryTimeout, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.activemq.Service
start, stop
 

Field Detail

maxAllowableDiffFromDBTime

protected int maxAllowableDiffFromDBTime

diffFromCurrentTime

protected long diffFromCurrentTime

leaseHolderId

protected String leaseHolderId
Constructor Detail

LeaseDatabaseLocker

public LeaseDatabaseLocker()
Method Detail

doStart

public void doStart()
             throws Exception
Specified by:
doStart in class ServiceSupport
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:
doStop in class ServiceSupport
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 interface Locker
Overrides:
keepAlive in class AbstractLocker
Throws:
IOException

getLeaseHolderId

public String getLeaseHolderId()

setLeaseHolderId

public void setLeaseHolderId(String leaseHolderId)

getMaxAllowableDiffFromDBTime

public int getMaxAllowableDiffFromDBTime()

setMaxAllowableDiffFromDBTime

public void setMaxAllowableDiffFromDBTime(int maxAllowableDiffFromDBTime)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.