org.apache.activemq.store.jdbc
Class DefaultDatabaseLocker

java.lang.Object
  extended by org.apache.activemq.store.jdbc.DefaultDatabaseLocker
All Implemented Interfaces:
Service, DatabaseLocker
Direct Known Subclasses:
TransactDatabaseLocker

public class DefaultDatabaseLocker
extends java.lang.Object
implements DatabaseLocker

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


Field Summary
protected  java.sql.Connection connection
           
protected  javax.sql.DataSource dataSource
           
static long DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL
           
protected  Handler<java.lang.Exception> exceptionHandler
           
protected  long lockAcquireSleepInterval
           
protected  java.sql.PreparedStatement lockCreateStatement
           
protected  java.sql.PreparedStatement lockUpdateStatement
           
protected  int queryTimeout
           
protected  Statements statements
           
protected  boolean stopping
           
 
Constructor Summary
DefaultDatabaseLocker()
           
DefaultDatabaseLocker(JDBCPersistenceAdapter persistenceAdapter)
           
 
Method Summary
 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 setPersistenceAdapter(JDBCPersistenceAdapter adapter)
          allow the injection of a jdbc persistence adapter
 void setQueryTimeout(int queryTimeout)
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL

public static final long DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL
See Also:
Constant Field Values

dataSource

protected javax.sql.DataSource dataSource

statements

protected Statements statements

lockAcquireSleepInterval

protected long lockAcquireSleepInterval

lockCreateStatement

protected java.sql.PreparedStatement lockCreateStatement

lockUpdateStatement

protected java.sql.PreparedStatement lockUpdateStatement

connection

protected java.sql.Connection connection

stopping

protected boolean stopping

exceptionHandler

protected Handler<java.lang.Exception> exceptionHandler

queryTimeout

protected int queryTimeout
Constructor Detail

DefaultDatabaseLocker

public DefaultDatabaseLocker()

DefaultDatabaseLocker

public DefaultDatabaseLocker(JDBCPersistenceAdapter persistenceAdapter)
                      throws java.io.IOException
Throws:
java.io.IOException
Method Detail

setPersistenceAdapter

public void setPersistenceAdapter(JDBCPersistenceAdapter adapter)
                           throws java.io.IOException
Description copied from interface: DatabaseLocker
allow the injection of a jdbc persistence adapter

Specified by:
setPersistenceAdapter in interface DatabaseLocker
Parameters:
adapter - the persistence adapter to use
Throws:
java.io.IOException

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface Service
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Specified by:
stop in interface Service
Throws:
java.lang.Exception

keepAlive

public boolean keepAlive()
Description copied from interface: DatabaseLocker
Used by a timer to keep alive the lock. If the method returns false the broker should be terminated

Specified by:
keepAlive in interface DatabaseLocker

getLockAcquireSleepInterval

public long getLockAcquireSleepInterval()

setLockAcquireSleepInterval

public void setLockAcquireSleepInterval(long lockAcquireSleepInterval)
Description copied from interface: DatabaseLocker
set the delay interval in milliseconds between lock acquire attempts

Specified by:
setLockAcquireSleepInterval in interface DatabaseLocker
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-2015. All Rights Reserved.