| java.lang.Object org.continuent.sequoia.controller.loadbalancer.AbstractLoadBalancer
All known Subclasses: org.continuent.sequoia.controller.loadbalancer.raidb2.RAIDb2, org.continuent.sequoia.controller.loadbalancer.singledb.SingleDB, org.continuent.sequoia.controller.loadbalancer.raidb1.RAIDb1, org.continuent.sequoia.controller.loadbalancer.paralleldb.ParallelDB, org.continuent.sequoia.controller.loadbalancer.raidb0.RAIDb0,
Method Summary | |
abstract public void | abort(TransactionMetaData tm) Abort a transaction and all its currently pending or executing queries. | protected int | acquireLockAndCheckNbOfThreads(Object request, String requestDescription) Acquire the given lock and check the number of threads. | abstract public void | begin(TransactionMetaData tm) Begin a new transaction. | abstract public ExecuteResult | callableStatementExecute(StoredProcedure proc, MetadataCache metadataCache) Call a stored procedure that returns multiple results. | abstract public ControllerResultSet | callableStatementExecuteQuery(StoredProcedure proc, MetadataCache metadataCache) Call a stored procedure that returns a ResultSet. | abstract public ExecuteUpdateResult | callableStatementExecuteUpdate(StoredProcedure proc) Call a stored procedure that performs an update. | abstract public void | closePersistentConnection(String login, long persistentConnectionId) Close a persistent connection. | abstract public void | commit(TransactionMetaData tm) Commit a transaction. | abstract public void | disableBackend(DatabaseBackend db, boolean forceDisable) Disable a backend without further check. | abstract public void | enableBackend(DatabaseBackend db, boolean writeEnabled) Enable a backend without further check. | final public static ExecuteResult | executeCallableStatementExecuteOnBackend(StoredProcedure proc, DatabaseBackend backend, BackendWorkerThread workerThread, PooledConnection pc, MetadataCache metadataCache) Execute a stored procedure that returns multiple results on the given
backend. | final public static ControllerResultSet | executeCallableStatementExecuteQueryOnBackend(StoredProcedure proc, DatabaseBackend backend, BackendWorkerThread workerThread, Connection c, MetadataCache metadataCache) Execute a read stored procedure on the given backend. | final public static ExecuteUpdateResult | executeCallableStatementExecuteUpdateOnBackend(StoredProcedure proc, DatabaseBackend backend, BackendWorkerThread workerThread, PooledConnection pc) Execute a write stored procedure on the given backend. | final public static ExecuteResult | executeStatementExecuteOnBackend(AbstractRequest request, DatabaseBackend backend, BackendWorkerThread workerThread, PooledConnection pc, MetadataCache metadataCache) Execute a request that returns multiple results on the given backend. | final public static ControllerResultSet | executeStatementExecuteQueryOnBackend(SelectRequest request, DatabaseBackend backend, BackendWorkerThread workerThread, Connection c, MetadataCache metadataCache) Execute a statement on a backend. | final public static ExecuteUpdateResult | executeStatementExecuteUpdateOnBackend(AbstractWriteRequest request, DatabaseBackend backend, BackendWorkerThread workerThread, PooledConnection pc) Execute an update prepared statement on a backend. | final public static GeneratedKeysResult | executeStatementExecuteUpdateWithKeysOnBackend(AbstractWriteRequest request, DatabaseBackend backend, BackendWorkerThread workerThread, PooledConnection pc, MetadataCache metadataCache) Execute an update prepared statement on a backend. | final public static Connection | getConnectionAndBeginTransaction(DatabaseBackend backend, AbstractConnectionManager cm, AbstractRequest request) | final public static int | getDefaultTransactionIsolationLevel() Returns the defaultTransactionIsolationLevel value. | abstract public String | getInformation() | protected int | getNbToWait(int nbOfThreads) Returns the number of nodes to wait for according to the defined
waitForCompletion policy. | public int | getNumberOfEnabledBackends() Get the number of currently enabled backends. | public int | getParsingGranularity() Get the needed query parsing granularity. | abstract public ControllerResultSet | getPreparedStatementGetMetaData(AbstractRequest request) | public int | getRAIDbLevel() Returns the RAIDbLevel. | final public RecoveryLog | getRecoveryLog() Returns the recoveryLog value. | public String | getXml() | abstract public String | getXmlImpl() | public void | handleMacros(AbstractRequest request) Interprets the macros in the request (depending on the
MacroHandler set for this class) and modify either the
skeleton or the query itself. | abstract public void | openPersistentConnection(String login, long persistentConnectionId) Open a persistent connection. | final public static ControllerResultSet | preparedStatementGetMetaDataOnBackend(String sqlTemplate, DatabaseBackend backend, Connection c) Get PreparedStatement metadata before the statement is executed. | abstract public ExecuteResult | readOnlyCallableStatementExecute(StoredProcedure proc, MetadataCache metadataCache) Call a read-only stored procedure that returns multiple results. | abstract public ControllerResultSet | readOnlyCallableStatementExecuteQuery(StoredProcedure proc, MetadataCache metadataCache) Call a read-only stored procedure that returns a ResultSet. | protected void | releaseLockAndUnlockNextQuery(Object currentQuery) Release the backend list lock and remove the current query from the head of
the total order queue to unlock the next query. | abstract public void | releaseSavepoint(TransactionMetaData tm, String name) | public void | removeObjectFromAndNotifyTotalOrderQueue(Object request) Remove an entry of the total order queue (usually the head) and notify the
queue so that the next queries can be scheduled. | abstract public void | rollback(TransactionMetaData tm) Rollback a transaction. | abstract public void | rollbackToSavepoint(TransactionMetaData tm, String savepointName) | final public void | setDefaultTransactionIsolationLevel(int defaultTransactionIsolationLevel) Sets the defaultTransactionIsolationLevel value. | public void | setMacroHandler(MacrosHandler handler) This sets the macro handler for this load balancer. | final public void | setRecoveryLog(RecoveryLog recoveryLog) Sets the recoveryLog value. | abstract public void | setSavepoint(TransactionMetaData tm, String name) Set a savepoint to a transaction. | public void | setWeight(String name, int w) Associate a weight to a backend identified by its logical name. | abstract public ExecuteResult | statementExecute(AbstractRequest request, MetadataCache metadataCache) Call a request that returns multiple results. | abstract public ControllerResultSet | statementExecuteQuery(SelectRequest request, MetadataCache metadataCache) Perform a read request. | abstract public ExecuteUpdateResult | statementExecuteUpdate(AbstractWriteRequest request) Perform a write request. | abstract public GeneratedKeysResult | statementExecuteUpdateWithKeys(AbstractWriteRequest request, MetadataCache metadataCache) Perform a write request and return a ResultSet containing the auto
generated keys. | public void | waitForSuspendWritesToComplete(AbstractRequest request) This will block the given request if there are any suspending task in
progress (before the request in the total order queue). | public static void | waitForTaskCompletion(long timeout, String requestDescription, AbstractTask task) Wait for the completion of the given task. | public boolean | waitForTotalOrder(Object request, boolean errorIfNotFound) If we are executing in a distributed virtual database, we have to make sure
that we post the query in the queue following the total order. |
parsingGranularity | protected int parsingGranularity(Code) | | |
raidbLevel | protected int raidbLevel(Code) | | |
totalOrderQueue | protected LinkedList totalOrderQueue(Code) | | Reference to distributed virtual database total order queue
|
AbstractLoadBalancer | protected AbstractLoadBalancer(VirtualDatabase vdb, int raidbLevel, int parsingGranularity) throws SQLException(Code) | | Generic constructor that sets some member variables and checks that
backends are in the disabled state
Parameters: vdb - The virtual database this load balancer belongs to Parameters: raidbLevel - The RAIDb level of this load balancer Parameters: parsingGranularity - The parsing granularity needed by this loadbalancer |
acquireLockAndCheckNbOfThreads | protected int acquireLockAndCheckNbOfThreads(Object request, String requestDescription) throws SQLException, NoMoreBackendException(Code) | | Acquire the given lock and check the number of threads. Throw a
NoMoreBackendException if no thread is available else returns the number of
threads.
Parameters: request - object to remove from the total order queue in case nobackend is available Parameters: requestDescription - description of the request to put in the errormessage in case of an error the number of threads in the acquired list throws: SQLException - if there was a problem to acquire the lock on theenabled backend list throws: NoMoreBackendException - if no backends are available anymore |
closePersistentConnection | abstract public void closePersistentConnection(String login, long persistentConnectionId) throws SQLException(Code) | | Close a persistent connection.
Parameters: login - login requesting the connection closing Parameters: persistentConnectionId - id of the persistent connection to close throws: SQLException - if an error occurs |
disableBackend | abstract public void disableBackend(DatabaseBackend db, boolean forceDisable) throws SQLException(Code) | | Disable a backend without further check. Ask the corresponding connection
manager to finalize the connections if needed. This method should not be
called directly but instead should access the
RequestManager.disableBackend(...) method.
Parameters: db - The database backend to disable Parameters: forceDisable - true if disable must be forced throws: SQLException - if an error occurs |
enableBackend | abstract public void enableBackend(DatabaseBackend db, boolean writeEnabled) throws SQLException(Code) | | Enable a backend without further check. The backend is at least read
enabled but could also be enabled for writes. Ask the corresponding
connection manager to initialize the connections if needed.
Parameters: db - The database backend to enable Parameters: writeEnabled - True if the backend must be enabled for writes throws: SQLException - if an error occurs |
executeCallableStatementExecuteOnBackend | final public static ExecuteResult executeCallableStatementExecuteOnBackend(StoredProcedure proc, DatabaseBackend backend, BackendWorkerThread workerThread, PooledConnection pc, MetadataCache metadataCache) throws SQLException, BadConnectionException(Code) | | Execute a stored procedure that returns multiple results on the given
backend. The callable statement is setXXX if the driver has not processed
the statement.
Parameters: proc - the stored procedure to execute Parameters: backend - the backend on which to execute the stored procedure Parameters: workerThread - the backend worker thread executing this query (or nullif none) Parameters: c - the connection on which to execute the stored procedure Parameters: metadataCache - the matedatacache to build the ControllerResultSet an ExecuteResult object throws: SQLException - if an error occurs throws: BadConnectionException - if the connection was bad |
executeCallableStatementExecuteQueryOnBackend | final public static ControllerResultSet executeCallableStatementExecuteQueryOnBackend(StoredProcedure proc, DatabaseBackend backend, BackendWorkerThread workerThread, Connection c, MetadataCache metadataCache) throws SQLException, BadConnectionException(Code) | | Execute a read stored procedure on the given backend. The callable
statement is setXXX if the driver has not processed the statement.
Parameters: proc - the stored procedure to execute Parameters: backend - the backend on which to execute the stored procedure Parameters: workerThread - the backend worker thread executing this query (or nullif none) Parameters: c - the connection on which to execute the stored procedure Parameters: metadataCache - the matedatacache to build the ControllerResultSet the controllerResultSet throws: SQLException - if an error occurs throws: BadConnectionException - if the connection was bad |
executeCallableStatementExecuteUpdateOnBackend | final public static ExecuteUpdateResult executeCallableStatementExecuteUpdateOnBackend(StoredProcedure proc, DatabaseBackend backend, BackendWorkerThread workerThread, PooledConnection pc) throws SQLException, BadConnectionException(Code) | | Execute a write stored procedure on the given backend. The callable
statement is setXXX if the driver has not processed the statement.
Parameters: proc - the stored procedure to execute Parameters: backend - the backend on which to execute the stored procedure Parameters: workerThread - the backend worker thread executing this query (or nullif none) Parameters: c - the connection on which to execute the stored procedure the number of updated rows throws: SQLException - if an error occurs throws: BadConnectionException - if the connection was bad |
executeStatementExecuteOnBackend | final public static ExecuteResult executeStatementExecuteOnBackend(AbstractRequest request, DatabaseBackend backend, BackendWorkerThread workerThread, PooledConnection pc, MetadataCache metadataCache) throws SQLException, BadConnectionException(Code) | | Execute a request that returns multiple results on the given backend. The
statement is setXXX if the driver has not processed the statement.
Parameters: request - the request to execute Parameters: backend - the backend on which to execute the stored procedure Parameters: workerThread - the backend worker thread executing this query (or nullif none) Parameters: pc - the connection on which to execute the stored procedure Parameters: metadataCache - the matedatacache to build the ControllerResultSet an ExecuteResult object throws: SQLException - if an error occurs throws: BadConnectionException - if the connection was bad |
executeStatementExecuteUpdateOnBackend | final public static ExecuteUpdateResult executeStatementExecuteUpdateOnBackend(AbstractWriteRequest request, DatabaseBackend backend, BackendWorkerThread workerThread, PooledConnection pc) throws SQLException, BadConnectionException(Code) | | Execute an update prepared statement on a backend. If the execution fails,
the connection is checked for validity. If the connection was not valid,
the query is automatically retried on a new connection.
Parameters: request - the request to execute Parameters: backend - the backend on which the request is executed Parameters: workerThread - the backend worker thread executing this query (or nullif none) Parameters: pc - pooled connection used to create the statement int Number of rows effected throws: SQLException - if an error occurs throws: BadConnectionException - if the connection was bad |
executeStatementExecuteUpdateWithKeysOnBackend | final public static GeneratedKeysResult executeStatementExecuteUpdateWithKeysOnBackend(AbstractWriteRequest request, DatabaseBackend backend, BackendWorkerThread workerThread, PooledConnection pc, MetadataCache metadataCache) throws SQLException, BadConnectionException(Code) | | Execute an update prepared statement on a backend. If the execution fails,
the connection is checked for validity. If the connection was not valid,
the query is automatically retried on a new connection.
Parameters: request - the request to execute Parameters: backend - the backend on which the request is executed Parameters: workerThread - the backend worker thread executing this query (or nullif none) Parameters: pc - connection used to create the statement Parameters: metadataCache - MetadataCache (null if none) ControllerResultSet containing the auto-generated keys throws: SQLException - if an error occurs throws: BadConnectionException - if the connection was bad |
getDefaultTransactionIsolationLevel | final public static int getDefaultTransactionIsolationLevel()(Code) | | Returns the defaultTransactionIsolationLevel value.
Returns the defaultTransactionIsolationLevel. |
getInformation | abstract public String getInformation()(Code) | | Get information about the Request Load Balancer
String containing information |
getNbToWait | protected int getNbToWait(int nbOfThreads)(Code) | | Returns the number of nodes to wait for according to the defined
waitForCompletion policy.
Parameters: nbOfThreads - total number of threads int number of threads to wait for |
getNumberOfEnabledBackends | public int getNumberOfEnabledBackends()(Code) | | Get the number of currently enabled backends. 0 means that no backend is
available.
number of currently enabled backends |
getParsingGranularity | public int getParsingGranularity()(Code) | | Get the needed query parsing granularity.
needed query parsing granularity |
getPreparedStatementGetMetaData | abstract public ControllerResultSet getPreparedStatementGetMetaData(AbstractRequest request) throws SQLException(Code) | | Return a ControllerResultSet containing the PreparedStatement metaData of
the given sql template
Parameters: request - the request containing the sql template an empty ControllerResultSet with the metadata throws: SQLException - if a database error occurs |
getRAIDbLevel | public int getRAIDbLevel()(Code) | | Returns the RAIDbLevel.
int the RAIDb level |
getRecoveryLog | final public RecoveryLog getRecoveryLog()(Code) | | Returns the recoveryLog value.
Returns the recoveryLog. |
getXmlImpl | abstract public String getXmlImpl()(Code) | | Get information about the Request Load Balancer in xml
String containing information, xml formatted |
handleMacros | public void handleMacros(AbstractRequest request)(Code) | | Interprets the macros in the request (depending on the
MacroHandler set for this class) and modify either the
skeleton or the query itself. Note that the given object is directly
modified.
Parameters: request - the request to process |
openPersistentConnection | abstract public void openPersistentConnection(String login, long persistentConnectionId) throws SQLException(Code) | | Open a persistent connection.
Parameters: login - login requesting the connection closing Parameters: persistentConnectionId - id of the persistent connection to open throws: SQLException - if an error occurs |
preparedStatementGetMetaDataOnBackend | final public static ControllerResultSet preparedStatementGetMetaDataOnBackend(String sqlTemplate, DatabaseBackend backend, Connection c) throws SQLException, BadConnectionException(Code) | | Get PreparedStatement metadata before the statement is executed.
Parameters: sqlTemplate - the PreparedStatement sql template Parameters: backend - the backend on which we execute the request Parameters: c - the connection to create the statement from an empty ResultSet with the associated metadata throws: SQLException - if an error occurs throws: BadConnectionException - if the databsae connection was bad |
readOnlyCallableStatementExecute | abstract public ExecuteResult readOnlyCallableStatementExecute(StoredProcedure proc, MetadataCache metadataCache) throws SQLException(Code) | | Call a read-only stored procedure that returns multiple results. The stored
procedure will be executed by one node only.
Parameters: proc - the stored procedure call Parameters: metadataCache - MetadataCache (null if none) a ExecuteResult object containing all results exception: SQLException - if an error occurs |
readOnlyCallableStatementExecuteQuery | abstract public ControllerResultSet readOnlyCallableStatementExecuteQuery(StoredProcedure proc, MetadataCache metadataCache) throws SQLException(Code) | | Call a read-only stored procedure that returns a ResultSet. The stored
procedure will be executed by one node only.
Parameters: proc - the stored procedure call Parameters: metadataCache - MetadataCache (null if none) a ControllerResultSet value exception: SQLException - if an error occurs |
releaseLockAndUnlockNextQuery | protected void releaseLockAndUnlockNextQuery(Object currentQuery)(Code) | | Release the backend list lock and remove the current query from the head of
the total order queue to unlock the next query.
Parameters: currentQuery - the current query to remove from the total order queue |
removeObjectFromAndNotifyTotalOrderQueue | public void removeObjectFromAndNotifyTotalOrderQueue(Object request)(Code) | | Remove an entry of the total order queue (usually the head) and notify the
queue so that the next queries can be scheduled.
Parameters: request - Object that should be removed from the total order queue |
setDefaultTransactionIsolationLevel | final public void setDefaultTransactionIsolationLevel(int defaultTransactionIsolationLevel)(Code) | | Sets the defaultTransactionIsolationLevel value.
Parameters: defaultTransactionIsolationLevel - ThedefaultTransactionIsolationLevel to set. |
setMacroHandler | public void setMacroHandler(MacrosHandler handler)(Code) | | This sets the macro handler for this load balancer. Handling macros
prevents different backends to generate different values when interpreting
the macros which could result in data inconsitencies.
Parameters: handler - MacrosHandler instance |
setRecoveryLog | final public void setRecoveryLog(RecoveryLog recoveryLog)(Code) | | Sets the recoveryLog value.
Parameters: recoveryLog - The recoveryLog to set. |
setWeight | public void setWeight(String name, int w) throws SQLException(Code) | | Associate a weight to a backend identified by its logical name.
Parameters: name - the backend name Parameters: w - the weight throws: SQLException - if an error occurs |
waitForSuspendWritesToComplete | public void waitForSuspendWritesToComplete(AbstractRequest request)(Code) | | This will block the given request if there are any suspending task in
progress (before the request in the total order queue).
Parameters: request - the request that we are processing |
waitForTaskCompletion | public static void waitForTaskCompletion(long timeout, String requestDescription, AbstractTask task) throws SQLException(Code) | | Wait for the completion of the given task. Note that this method must be
called within a synchronized block on the task.
Parameters: timeout - timeout in ms for this task Parameters: requestDescription - description of the request to put in the errormessage in case of a timeout Parameters: task - the task to wait for completion throws: SQLException - if the timeout has expired |
waitForTotalOrder | public boolean waitForTotalOrder(Object request, boolean errorIfNotFound)(Code) | | If we are executing in a distributed virtual database, we have to make sure
that we post the query in the queue following the total order. This method
does not remove the request from the total order queue. You have to call
removeHeadFromAndNotifyTotalOrderQueue() to do so.
Parameters: request - the request to wait for (can be any object but usually aDistributedRequest, Commit or Rollback) Parameters: errorIfNotFound - true if an error message should be logged if therequest is not found in the total order queue true if the element was found and wait has succeeded, falseotherwise See Also: AbstractLoadBalancer.removeHeadFromAndNotifyTotalOrderQueue(Object) |
|
|