org.apache.activemq.store.jdbc
Class DefaultDatabaseLocker

java.lang.Object
  extended by org.apache.activemq.util.ServiceSupport
      extended by org.apache.activemq.broker.AbstractLocker
          extended by org.apache.activemq.store.jdbc.DefaultDatabaseLocker
All Implemented Interfaces:
Locker, Service
Direct Known Subclasses:
TransactDatabaseLocker

public class DefaultDatabaseLocker
extends AbstractLocker

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


Field Summary
protected  Connection connection
           
protected  DataSource dataSource
           
protected  Handler<Exception> exceptionHandler
           
protected  PreparedStatement lockCreateStatement
           
protected  PreparedStatement lockUpdateStatement
           
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
DefaultDatabaseLocker()
           
 
Method Summary
 void configure(PersistenceAdapter adapter)
          Optionally configure the locker with the persistence adapter currently used You can use persistence adapter configuration details like, data directory datasource, etc.
 void doStart()
           
 void doStop(ServiceStopper stopper)
           
 Handler getExceptionHandler()
           
 long getLockAcquireSleepInterval()
           
 int getQueryTimeout()
           
 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
 void setQueryTimeout(int queryTimeout)
           
 
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, toString, wait, wait, wait
 
Methods inherited from interface org.apache.activemq.Service
start, stop
 

Field Detail

dataSource

protected DataSource dataSource

statements

protected Statements statements

lockCreateStatement

protected volatile PreparedStatement lockCreateStatement

lockUpdateStatement

protected volatile PreparedStatement lockUpdateStatement

connection

protected volatile Connection connection

stopping

protected volatile boolean stopping

exceptionHandler

protected Handler<Exception> exceptionHandler

queryTimeout

protected int queryTimeout
Constructor Detail

DefaultDatabaseLocker

public DefaultDatabaseLocker()
Method Detail

configure

public void configure(PersistenceAdapter adapter)
               throws IOException
Description copied from interface: Locker
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

Throws:
IOException

doStart

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

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

getLockAcquireSleepInterval

public long getLockAcquireSleepInterval()

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 interface Locker
Overrides:
setLockAcquireSleepInterval in class AbstractLocker
Parameters:
lockAcquireSleepInterval - the sleep interval in miliseconds

getExceptionHandler

public Handler getExceptionHandler()

setExceptionHandler

public void setExceptionHandler(Handler exceptionHandler)

getQueryTimeout

public int getQueryTimeout()

setQueryTimeout

public void setQueryTimeout(int queryTimeout)


Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.