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.LeaseDatabaseLocker
All Implemented Interfaces:
Locker, Service

public class LeaseDatabaseLocker
extends AbstractLocker

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


Field Summary
protected  javax.sql.DataSource dataSource
           
protected  long diffFromCurrentTime
           
protected  boolean handleStartException
           
protected  java.lang.String leaseHolderId
           
protected  int maxAllowableDiffFromDBTime
           
protected  int queryTimeout
           
protected  Statements statements
           
protected  boolean stopping
           
 
Fields inherited from class org.apache.activemq.broker.AbstractLocker
DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL, failIfLocked, lockAcquireSleepInterval, name
 
Constructor Summary
LeaseDatabaseLocker()
           
 
Method Summary
 void configure(PersistenceAdapter adapter)
           
protected  long determineTimeDifference(java.sql.Connection connection)
           
 void doStart()
           
 void doStop(ServiceStopper stopper)
           
 java.lang.String getLeaseHolderId()
           
 long getLockAcquireSleepInterval()
           
 int getMaxAllowableDiffFromDBTime()
           
 int getQueryTimeout()
           
protected  long initTimeDiff(java.sql.Connection connection)
           
 boolean isHandleStartException()
           
 boolean keepAlive()
           
 void setHandleStartException(boolean handleStartException)
           
 void setLeaseHolderId(java.lang.String leaseHolderId)
           
 void setLockAcquireSleepInterval(long lockAcquireSleepInterval)
           
 void setMaxAllowableDiffFromDBTime(int maxAllowableDiffFromDBTime)
           
 void setQueryTimeout(int queryTimeout)
           
 java.lang.String toString()
           
 
Methods inherited from class org.apache.activemq.broker.AbstractLocker
setFailIfLocked, setName
 
Methods inherited from class org.apache.activemq.util.ServiceSupport
addServiceListener, dispose, isStarted, isStopped, isStopping, postStop, preStart, 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

dataSource

protected javax.sql.DataSource dataSource

statements

protected Statements statements

stopping

protected boolean stopping

maxAllowableDiffFromDBTime

protected int maxAllowableDiffFromDBTime

diffFromCurrentTime

protected long diffFromCurrentTime

leaseHolderId

protected java.lang.String leaseHolderId

queryTimeout

protected int queryTimeout

handleStartException

protected boolean handleStartException
Constructor Detail

LeaseDatabaseLocker

public LeaseDatabaseLocker()
Method Detail

configure

public void configure(PersistenceAdapter adapter)
               throws java.io.IOException
Throws:
java.io.IOException

doStart

public void doStart()
             throws java.lang.Exception
Specified by:
doStart in class ServiceSupport
Throws:
java.lang.Exception

initTimeDiff

protected long initTimeDiff(java.sql.Connection connection)
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

determineTimeDifference

protected long determineTimeDifference(java.sql.Connection connection)
                                throws java.sql.SQLException
Throws:
java.sql.SQLException

doStop

public void doStop(ServiceStopper stopper)
            throws java.lang.Exception
Specified by:
doStop in class ServiceSupport
Throws:
java.lang.Exception

keepAlive

public boolean keepAlive()
                  throws java.io.IOException
Specified by:
keepAlive in interface Locker
Overrides:
keepAlive in class AbstractLocker
Throws:
java.io.IOException

getLockAcquireSleepInterval

public long getLockAcquireSleepInterval()

setLockAcquireSleepInterval

public void setLockAcquireSleepInterval(long lockAcquireSleepInterval)
Specified by:
setLockAcquireSleepInterval in interface Locker
Overrides:
setLockAcquireSleepInterval in class AbstractLocker

getQueryTimeout

public int getQueryTimeout()

setQueryTimeout

public void setQueryTimeout(int queryTimeout)

getLeaseHolderId

public java.lang.String getLeaseHolderId()

setLeaseHolderId

public void setLeaseHolderId(java.lang.String leaseHolderId)

getMaxAllowableDiffFromDBTime

public int getMaxAllowableDiffFromDBTime()

setMaxAllowableDiffFromDBTime

public void setMaxAllowableDiffFromDBTime(int maxAllowableDiffFromDBTime)

isHandleStartException

public boolean isHandleStartException()

setHandleStartException

public void setHandleStartException(boolean handleStartException)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2005-2015 Red Hat, Inc.. All Rights Reserved.