org.objectweb.cjdbc.controller.requestmanager
Class RequestManager

java.lang.Object
  extended byjavax.management.StandardMBean
      extended byorg.objectweb.cjdbc.controller.jmx.AbstractStandardMBean
          extended byorg.objectweb.cjdbc.controller.requestmanager.RequestManager
All Implemented Interfaces:
javax.management.DynamicMBean, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, RequestManagerMBean, XmlComponent
Direct Known Subclasses:
DistributedRequestManager

public class RequestManager
extends AbstractStandardMBean
implements XmlComponent, RequestManagerMBean

This class defines the Request Manager.

The RM is composed of a Request Scheduler, an optional Query Cache, and a Load Balancer and an optional Recovery Log.

Version:
1.0
Author:
Emmanuel Cecchet , Julie Marguerite , Nicolas Modrzyk , Vadim Kassin , Jean-Bernard van Zuylen

Nested Class Summary
 
Nested classes inherited from class javax.management.StandardMBean
 
Field Summary
private  BackendStateListener backendStateListener
           
protected  BackupManager backupManager
          The backup manager responsible for backup and restore of backends
protected  long beginTimeout
          begin timeout in ms
private  int cacheParsingranularity
           
protected  long commitTimeout
          commit timeout in ms
protected  DatabaseSchema dbs
           
private  boolean isCaseSensitiveParsing
           
protected  AbstractLoadBalancer loadBalancer
          The request load balancer to use to send requests to the databases
private  int loadBalancerParsingranularity
           
protected static Trace logger
           
private  MetadataCache metadataCache
           
protected  ParsingCache parsingCache
           
protected  RecoveryLog recoveryLog
          An optional recovery log
protected  int requiredParsingGranularity
           
protected  AbstractResultCache resultCache
          An optional request cache to cache responses to SQL requests
protected  long rollbackTimeout
          rollback timeout in ms
protected  AbstractScheduler scheduler
          The request scheduler to order and schedule requests
protected  int schedulerParsingranularity
           
private  boolean schemaIsDirty
          true if schema is no more up-to-date and needs a refresh
private  boolean schemaIsStatic
           
protected  java.util.Hashtable tidLoginTable
          Transaction id/Login mapping
protected  java.util.Hashtable tidSavepoints
          Transaction id/Savepoints mapping
protected  VirtualDatabase vdb
          The virtual database owning this Request Manager
 
Fields inherited from class org.objectweb.cjdbc.controller.jmx.AbstractStandardMBean
 
Fields inherited from class javax.management.StandardMBean
 
Fields inherited from interface org.objectweb.cjdbc.common.xml.XmlComponent
DOCTYPE_CONTROLLER, DOCTYPE_DB, XML_VERSION
 
Constructor Summary
RequestManager(VirtualDatabase vdb, AbstractScheduler scheduler, AbstractResultCache cache, AbstractLoadBalancer loadBalancer, RecoveryLog recoveryLog, long beginTimeout, long commitTimeout, long rollbackTimeout)
          Creates a new RequestManager instance.
 
Method Summary
 void abort(long transactionId, boolean logAbort)
          Abort a transaction that has been started but in which no query was executed.
 void addSavepoint(java.lang.Long tid, java.lang.String savepointName)
          Adds a given savepoint to a given transaction
private  void assignAndCheckSchedulerLoadBalancerValidity(AbstractScheduler scheduler, AbstractLoadBalancer loadBalancer)
          Check that Scheduler and Load Balancer are not null and have compatible RAIDb levels.
 void backupBackend(DatabaseBackend backend, java.lang.String login, java.lang.String password, java.lang.String dumpName, java.lang.String backuperName, java.lang.String path, java.util.ArrayList tables)
          Create a backup from the content of a backend.
 long begin(java.lang.String login)
          Begin a new transaction and return the corresponding transaction identifier.
 void commit(long transactionId, boolean logCommit)
          Commit a transaction given its id.
 void completeTransaction(java.lang.Long tid)
          Complete the transaction by removing it from the tidLoginTable.
 void disableBackend(DatabaseBackend db)
          Disable a backend that is currently enabled on this virtual database.
 void disableBackendForCheckpoint(DatabaseBackend db, java.lang.String checkpointName)
          The backend must belong to this virtual database and be in the enabled state.
 void disableBackendsForCheckpoint(java.util.ArrayList backendsArrayList, java.lang.String checkpointName)
          Disable a list of backends.
 void enableBackend(DatabaseBackend db)
          Enable a backend that has been previously added to this virtual database and that is in the disabled state.
 RecoverThread enableBackendFromCheckpoint(DatabaseBackend db, java.lang.String checkpointName)
          The backend must have been previously added to this virtual database and be in the disabled state.
 ControllerResultSet execReadRequest(SelectRequest request)
          Perform a read request and return the reply.
 ControllerResultSet execReadStoredProcedure(StoredProcedure proc)
          Call a stored procedure that returns a ResultSet.
 int execWriteRequest(AbstractWriteRequest request)
          Perform a write request and return the number of rows affected Call first the scheduler (if defined), then notify the cache (if defined) and finally call the load balancer.
 ControllerResultSet execWriteRequestWithKeys(AbstractWriteRequest request)
          Perform a write request and return the auto generated keys.
 int execWriteStoredProcedure(StoredProcedure proc)
          Call a stored procedure that performs an update.
 void flushCacheAndLogStoredProcedure(StoredProcedure proc, boolean isRead)
          Flush the cache and log the stored procedure execution in the recovery log.
 java.lang.String getAssociatedString()
          Allow to retrieve internationalization description on mbeans as well
 BackendStateListener getBackendStateListener()
          Returns the backendStateListener value.
 BackupManager getBackupManager()
          Returns the backupManager value.
 long getBeginTimeout()
          Returns the beginTimeout value.
 int getCacheParsingranularity()
          Returns the cacheParsingranularity value.
 long getCommitTimeout()
          Returns the commitTimeout value.
 DatabaseSchema getDatabaseSchema()
          Get the DatabaseSchema used by this Request Manager.
 AbstractLoadBalancer getLoadBalancer()
          Get the Request Load Balancer used in this Request Controller.
 int getLoadBalancerParsingranularity()
          Returns the loadBalancerParsingranularity value.
 MetadataCache getMetadataCache()
          Returns the metadataCache value.
 RecoveryLog getRecoveryLog()
          Returns the Recovery Log Manager.
 int getRequiredParsingGranularity()
          Returns the requiredParsingGranularity value.
 AbstractResultCache getResultCache()
          Get the result cache (if any) used in this Request Manager.
 long getRollbackTimeout()
          Returns the rollbackTimeout value.
 AbstractScheduler getScheduler()
          Get the Request Scheduler (if any) used in this Request Controller.
 int getSchedulerParsingranularity()
          Returns the schedulerParsingranularity value.
 TransactionMarkerMetaData getTransactionMarker(java.lang.Long tid)
          Get the TransactionMarkerMetaData for the given transaction id.
 VirtualDatabase getVirtualDatabase()
          Returns the vdb value.
 java.lang.String getXml()
          Get xml information about this Request Manager
 boolean hasSavepoint(java.lang.Long tid, java.lang.String savepointName)
          Check if a given savepoint has been set for a given transaction
private  void initRequestManagerVariables(VirtualDatabase vdb, long beginTimeout, long commitTimeout, long rollbackTimeout)
          Method initRequestManagerVariables.
 boolean isCaseSensitiveParsing()
          Returns the isCaseSensitiveParsing value.
 boolean isSchemaIsStatic()
          Returns the schemaIsStatic value.
 int loadBalanceExecWriteRequest(AbstractWriteRequest request)
          Send the given query to the load balancer.
 ControllerResultSet loadBalanceExecWriteRequestWithKeys(AbstractWriteRequest request)
          Send the given query to the load balancer.
 ControllerResultSet loadBalanceReadStoredProcedure(StoredProcedure proc)
          Execute a read stored procedure on the load balancer.
 int loadBalanceWriteStoredProcedure(StoredProcedure proc)
          Execute a write stored procedure on the load balancer.
 void logLazyTransactionBegin(long transactionId)
          Log the begin of a transaction that is started lazily.
 void mergeDatabaseSchema(DatabaseSchema backendSchema)
          Merge the given schema with the existing database schema.
 void releaseSavepoint(long transactionId, java.lang.String name)
          Releases a savepoint given its name from a transaction given its id.
 void removeCheckpoint(java.lang.String checkpointName)
          Remove a checkpoint and corresponding entries from the log table
 void removeSavepoint(java.lang.Long tid, java.lang.String savepointName)
          Removes a given savepoint for a given transaction
 void removeSavepoints(java.lang.Long tid, java.lang.String savepointName)
          Removes all the savepoints set after a given savepoint for a given transaction
 void restoreBackendFromBackupCheckpoint(DatabaseBackend backend, java.lang.String login, java.lang.String password, java.lang.String dumpName, java.util.ArrayList tables)
          Restore a dump on a specific backend.
 void rollback(long transactionId, boolean logRollback)
          Rollback a transaction given its id.
 void rollback(long transactionId, java.lang.String savepointName)
          Rollback a transaction given its id to a savepoint given its name.
 void scheduleExecWriteRequest(AbstractWriteRequest request)
          Schedule a request for execution.
 void scheduleStoredProcedure(StoredProcedure proc)
          This method does some sanity check on the given stored procedure and then tries to schedule it.
private  void setBackendsLastKnownCheckpointFromRecoveryLog()
          Retrieve the last known checkpoint from the recovery log and set it for each backend.
 void setBackupManager(BackupManager currentBackupManager)
          Sets the backup manager for this recovery log
 void setBeginTimeout(long beginTimeout)
          Sets the beginTimeout value.
 void setCacheParsingranularity(int cacheParsingranularity)
          Sets the cacheParsingranularity value.
 void setCaseSensitiveParsing(boolean isCaseSensitiveParsing)
          Sets the parsing case sensitivity.
 void setCommitTimeout(long commitTimeout)
          Sets the commitTimeout value.
 void setDatabaseSchema(DatabaseSchema schema, boolean isStatic)
          Sets the DatabaseSchema to be able to parse the requests and find dependencies.
 void setLoadBalancer(AbstractLoadBalancer loadBalancer)
          Set the Request Load Balancer to use in this Request Controller.
 void setLoadBalancerParsingranularity(int loadBalancerParsingranularity)
          Sets the loadBalancerParsingranularity value.
 void setMetadataCache(MetadataCache metadataCache)
          Sets the metadataCache value.
 void setParsingCache(ParsingCache parsingCache)
          Sets the ParsingCache.
 void setRecoveryLog(RecoveryLog recoveryLog)
          Sets the Recovery Log Manager.
 void setRequiredParsingGranularity(int requiredGranularity)
          Sets the requiredParsingGranularity value.
 void setResultCache(AbstractResultCache cache)
          Set the Request Cache to use in this Request Controller.
 void setRollbackTimeout(long rollbackTimeout)
          Sets the rollbackTimeout value.
 int setSavepoint(long transactionId)
          Sets a unnamed savepoint to a transaction given its id.
 void setSavepoint(long transactionId, java.lang.String name)
          Sets a savepoint given its desired name to a transaction given its id.
 void setScheduler(AbstractScheduler scheduler)
          Set the Request Scheduler to use in this Request Controller.
 void setSchedulerParsingranularity(int schedulerParsingranularity)
          Sets the schedulerParsingranularity value.
 void setSchemaIsDirty(boolean schemaIsDirty)
          Sets the schemaIsDirty value if the backend schema needs to be refreshed.
 void setSchemaIsStatic(boolean schemaIsStatic)
          Sets the schemaIsStatic value.
 void storeBackendsInfo(java.lang.String databaseName, java.util.ArrayList backends)
          Store all the backends checkpoint in the recoverylog
 void updateAndNotifyExecWriteRequest(AbstractWriteRequest request)
          Update the cache, notify the recovery log, update the database schema if needed and finally notify the scheduler.
 
Methods inherited from class org.objectweb.cjdbc.controller.jmx.AbstractStandardMBean
addNotificationListener, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getNotificationInfo, getParameterName, getParameterName, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class javax.management.StandardMBean
cacheMBeanInfo, getAttribute, getAttributes, getCachedMBeanInfo, getClassName, getConstructors, getDescription, getImpact, getImplementation, getImplementationClass, getMBeanInfo, getMBeanInterface, invoke, setAttribute, setAttributes, setImplementation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beginTimeout

protected long beginTimeout
begin timeout in ms


commitTimeout

protected long commitTimeout
commit timeout in ms


rollbackTimeout

protected long rollbackTimeout
rollback timeout in ms


vdb

protected VirtualDatabase vdb
The virtual database owning this Request Manager


scheduler

protected AbstractScheduler scheduler
The request scheduler to order and schedule requests


resultCache

protected AbstractResultCache resultCache
An optional request cache to cache responses to SQL requests


loadBalancer

protected AbstractLoadBalancer loadBalancer
The request load balancer to use to send requests to the databases


recoveryLog

protected RecoveryLog recoveryLog
An optional recovery log


backupManager

protected BackupManager backupManager
The backup manager responsible for backup and restore of backends


dbs

protected DatabaseSchema dbs

schemaIsDirty

private boolean schemaIsDirty
true if schema is no more up-to-date and needs a refresh


schemaIsStatic

private boolean schemaIsStatic

isCaseSensitiveParsing

private boolean isCaseSensitiveParsing

parsingCache

protected ParsingCache parsingCache

metadataCache

private MetadataCache metadataCache

schedulerParsingranularity

protected int schedulerParsingranularity

cacheParsingranularity

private int cacheParsingranularity

loadBalancerParsingranularity

private int loadBalancerParsingranularity

requiredParsingGranularity

protected int requiredParsingGranularity

tidLoginTable

protected java.util.Hashtable tidLoginTable
Transaction id/Login mapping


tidSavepoints

protected java.util.Hashtable tidSavepoints
Transaction id/Savepoints mapping


logger

protected static Trace logger

backendStateListener

private BackendStateListener backendStateListener
Constructor Detail

RequestManager

public RequestManager(VirtualDatabase vdb,
                      AbstractScheduler scheduler,
                      AbstractResultCache cache,
                      AbstractLoadBalancer loadBalancer,
                      RecoveryLog recoveryLog,
                      long beginTimeout,
                      long commitTimeout,
                      long rollbackTimeout)
               throws java.sql.SQLException,
                      javax.management.NotCompliantMBeanException
Creates a new RequestManager instance.

Parameters:
vdb - the virtual database this request manager belongs to
scheduler - the Request Scheduler to use
cache - a Query Cache implementation
loadBalancer - the Request Load Balancer to use
recoveryLog - the Log Recovery to use
beginTimeout - timeout in seconds for begin
commitTimeout - timeout in seconds for commit
rollbackTimeout - timeout in seconds for rollback
Throws:
java.sql.SQLException - if an error occurs
javax.management.NotCompliantMBeanException - if the MBean is not JMX compliant
Method Detail

setBackendsLastKnownCheckpointFromRecoveryLog

private void setBackendsLastKnownCheckpointFromRecoveryLog()
Retrieve the last known checkpoint from the recovery log and set it for each backend.


assignAndCheckSchedulerLoadBalancerValidity

private void assignAndCheckSchedulerLoadBalancerValidity(AbstractScheduler scheduler,
                                                         AbstractLoadBalancer loadBalancer)
                                                  throws java.sql.SQLException
Check that Scheduler and Load Balancer are not null and have compatible RAIDb levels.

Parameters:
scheduler -
loadBalancer -
Throws:
java.sql.SQLException - if an error occurs

initRequestManagerVariables

private void initRequestManagerVariables(VirtualDatabase vdb,
                                         long beginTimeout,
                                         long commitTimeout,
                                         long rollbackTimeout)
Method initRequestManagerVariables.

Parameters:
vdb -
beginTimeout -
commitTimeout -
rollbackTimeout -

execReadRequest

public ControllerResultSet execReadRequest(SelectRequest request)
                                    throws java.sql.SQLException
Perform a read request and return the reply. Call first the scheduler, then the cache (if defined) and finally the load balancer.

Parameters:
request - the request to execute
Returns:
a ControllerResultSet value
Throws:
java.sql.SQLException - if an error occurs

execWriteRequest

public int execWriteRequest(AbstractWriteRequest request)
                     throws java.sql.SQLException
Perform a write request and return the number of rows affected Call first the scheduler (if defined), then notify the cache (if defined) and finally call the load balancer.

Parameters:
request - the request to execute
Returns:
number of rows affected
Throws:
java.sql.SQLException - if an error occurs

execWriteRequestWithKeys

public ControllerResultSet execWriteRequestWithKeys(AbstractWriteRequest request)
                                             throws java.sql.SQLException
Perform a write request and return the auto generated keys. Call first the scheduler (if defined), then notify the cache (if defined) and finally call the load balancer.

Parameters:
request - the request to execute
Returns:
auto generated keys.
Throws:
java.sql.SQLException - if an error occurs

scheduleExecWriteRequest

public void scheduleExecWriteRequest(AbstractWriteRequest request)
                              throws java.sql.SQLException
Schedule a request for execution.

Parameters:
request - the request to execute
Throws:
java.sql.SQLException - if an error occurs

loadBalanceExecWriteRequestWithKeys

public ControllerResultSet loadBalanceExecWriteRequestWithKeys(AbstractWriteRequest request)
                                                        throws AllBackendsFailedException,
                                                               java.sql.SQLException
Send the given query to the load balancer. If the request fails, the scheduler is properly notified.

Parameters:
request - the request to execute
Returns:
auto-generated keys
Throws:
AllBackendsFailedException - if all backends failed to execute the query
java.sql.SQLException - if an error occurs

loadBalanceExecWriteRequest

public int loadBalanceExecWriteRequest(AbstractWriteRequest request)
                                throws AllBackendsFailedException,
                                       java.sql.SQLException
Send the given query to the load balancer. If the request fails, the scheduler is properly notified.

Parameters:
request - the request to execute
Returns:
number of modified lines
Throws:
AllBackendsFailedException - if all backends failed to execute the query
java.sql.SQLException - if an error occurs

updateAndNotifyExecWriteRequest

public void updateAndNotifyExecWriteRequest(AbstractWriteRequest request)
                                     throws java.sql.SQLException
Update the cache, notify the recovery log, update the database schema if needed and finally notify the scheduler. Note that if an error occurs, the scheduler is always notified.

Parameters:
request - the request to execute
Throws:
java.sql.SQLException - if an error occurs

execReadStoredProcedure

public ControllerResultSet execReadStoredProcedure(StoredProcedure proc)
                                            throws AllBackendsFailedException,
                                                   java.sql.SQLException
Call a stored procedure that returns a ResultSet.

Parameters:
proc - the stored procedure call
Returns:
a ControllerResultSet value
Throws:
AllBackendsFailedException - if all backends failed to execute the stored procedure
java.sql.SQLException - if an error occurs

execWriteStoredProcedure

public int execWriteStoredProcedure(StoredProcedure proc)
                             throws AllBackendsFailedException,
                                    java.sql.SQLException
Call a stored procedure that performs an update.

Parameters:
proc - the stored procedure call
Returns:
number of rows affected
Throws:
AllBackendsFailedException - if all backends failed to execute the stored procedure
java.sql.SQLException - if an error occurs

scheduleStoredProcedure

public void scheduleStoredProcedure(StoredProcedure proc)
                             throws java.sql.SQLException
This method does some sanity check on the given stored procedure and then tries to schedule it. Note that it is more likely that on a stored procedure the scheduler will lock in write the entire database as it does not know which tables are accessed by the procedure.

Parameters:
proc - the stored procedure to schedule
Throws:
java.sql.SQLException - if an error occurs

loadBalanceReadStoredProcedure

public ControllerResultSet loadBalanceReadStoredProcedure(StoredProcedure proc)
                                                   throws java.sql.SQLException,
                                                          AllBackendsFailedException
Execute a read stored procedure on the load balancer. Note that we flush the cache before calling the load balancer.

Parameters:
proc - the stored procedure to call
Returns:
the corresponding ControllerResultSet
Throws:
java.sql.SQLException - if an error occurs
AllBackendsFailedException - if all backends failed to execute the stored procedure

loadBalanceWriteStoredProcedure

public int loadBalanceWriteStoredProcedure(StoredProcedure proc)
                                    throws AllBackendsFailedException,
                                           java.sql.SQLException
Execute a write stored procedure on the load balancer. Note that we flush the cache before calling the load balancer.

Parameters:
proc - the stored procedure to call
Returns:
the number of updated rows
Throws:
java.sql.SQLException - if an error occurs
AllBackendsFailedException - if all backends failed to execute the stored procedure

flushCacheAndLogStoredProcedure

public void flushCacheAndLogStoredProcedure(StoredProcedure proc,
                                            boolean isRead)
Flush the cache and log the stored procedure execution in the recovery log.

Parameters:
proc - the stored procedure to log
isRead - true is this is an execReadStoredProcedure, false for an execWriteStoredProcedure

begin

public long begin(java.lang.String login)
           throws java.sql.SQLException
Begin a new transaction and return the corresponding transaction identifier. This method is called from the driver when setAutoCommit(false) is called.

Note that the transaction begin is not logged in the recovery log by this method, you will have to call logLazyTransactionBegin.

Parameters:
login - the login used by the connection
Returns:
int a unique transaction identifier
Throws:
java.sql.SQLException - if an error occurs
See Also:
logLazyTransactionBegin(long)

logLazyTransactionBegin

public void logLazyTransactionBegin(long transactionId)
                             throws java.sql.SQLException
Log the begin of a transaction that is started lazily. In fact, we just log the begin when we execute the first write request in a transaction to prevent logging begin/commit for read-only transactions. This also prevents a problem with backends that are disabled with a checkpoint when no request has been played in the transaction but the begin statement has already been logged. In that case, the transaction would not be properly replayed at restore time.

Parameters:
transactionId - the transaction id begin to log
Throws:
java.sql.SQLException - if an error occurs

abort

public void abort(long transactionId,
                  boolean logAbort)
           throws java.sql.SQLException
Abort a transaction that has been started but in which no query was executed. As we use lazy transaction begin, there is no need to rollback such transaction but just to cleanup the metadata associated with this not effectively started transaction.

Parameters:
transactionId - id of the transaction to abort
logAbort - true if the abort (in fact rollback) should be logged in the recovery log
Throws:
java.sql.SQLException - if an error occurs

getTransactionMarker

public TransactionMarkerMetaData getTransactionMarker(java.lang.Long tid)
                                               throws java.sql.SQLException
Get the TransactionMarkerMetaData for the given transaction id.

Parameters:
tid - transaction id
Returns:
the TransactionMarkerMetaData
Throws:
java.sql.SQLException - if no marker has been found for this transaction

completeTransaction

public void completeTransaction(java.lang.Long tid)
Complete the transaction by removing it from the tidLoginTable.

Parameters:
tid - transaction id

commit

public void commit(long transactionId,
                   boolean logCommit)
            throws java.sql.SQLException
Commit a transaction given its id.

Parameters:
transactionId - the transaction id
logCommit - true if the commit should be logged in the recovery log
Throws:
java.sql.SQLException - if an error occurs

rollback

public void rollback(long transactionId,
                     boolean logRollback)
              throws java.sql.SQLException
Rollback a transaction given its id.

Parameters:
transactionId - the transaction id
logRollback - true if the rollback should be logged in the recovery log
Throws:
java.sql.SQLException - if an error occurs

rollback

public void rollback(long transactionId,
                     java.lang.String savepointName)
              throws java.sql.SQLException
Rollback a transaction given its id to a savepoint given its name.

Parameters:
transactionId - the transaction id
savepointName - the name of the savepoint
Throws:
java.sql.SQLException - if an error occurs

setSavepoint

public int setSavepoint(long transactionId)
                 throws java.sql.SQLException
Sets a unnamed savepoint to a transaction given its id.

Parameters:
transactionId - the transaction id
Returns:
the generated id of the new savepoint
Throws:
java.sql.SQLException - if an error occurs

setSavepoint

public void setSavepoint(long transactionId,
                         java.lang.String name)
                  throws java.sql.SQLException
Sets a savepoint given its desired name to a transaction given its id.

Parameters:
transactionId - the transaction id
name - the desired name of the savepoint
Throws:
java.sql.SQLException - if an error occurs

releaseSavepoint

public void releaseSavepoint(long transactionId,
                             java.lang.String name)
                      throws java.sql.SQLException
Releases a savepoint given its name from a transaction given its id.

Parameters:
transactionId - the transaction id
name - the name of the savepoint
Throws:
java.sql.SQLException - if an error occurs

addSavepoint

public void addSavepoint(java.lang.Long tid,
                         java.lang.String savepointName)
Adds a given savepoint to a given transaction

Parameters:
tid - transaction id
savepointName - name of the savepoint

removeSavepoint

public void removeSavepoint(java.lang.Long tid,
                            java.lang.String savepointName)
Removes a given savepoint for a given transaction

Parameters:
tid - transaction id
savepointName - name of the savepoint

removeSavepoints

public void removeSavepoints(java.lang.Long tid,
                             java.lang.String savepointName)
Removes all the savepoints set after a given savepoint for a given transaction

Parameters:
tid - transaction id
savepointName - name of the savepoint

hasSavepoint

public boolean hasSavepoint(java.lang.Long tid,
                            java.lang.String savepointName)
Check if a given savepoint has been set for a given transaction

Parameters:
tid - transaction id
savepointName - name of the savepoint
Returns:
true if the savepoint exists

enableBackend

public void enableBackend(DatabaseBackend db)
                   throws java.sql.SQLException
Enable a backend that has been previously added to this virtual database and that is in the disabled state.

The backend is enabled without further check.

The enableBackend method of the load balancer is called.

Parameters:
db - The database backend to enable
Throws:
java.sql.SQLException - if an error occurs

enableBackendFromCheckpoint

public RecoverThread enableBackendFromCheckpoint(DatabaseBackend db,
                                                 java.lang.String checkpointName)
                                          throws java.sql.SQLException
The backend must have been previously added to this virtual database and be in the disabled state.

All the queries since the given checkpoint are played and the backend state is set to enabled when it is completely synchronized.

Note that the job is performed in background by a RecoverThread. You can synchronize on thread termination if you need to wait for completion of this task and listen to JMX notifications for the success status.

Parameters:
db - The database backend to enable
checkpointName - The checkpoint name to restart from
Returns:
the JDBC reocver thread synchronizing the backend
Throws:
java.sql.SQLException - if an error occurs

disableBackend

public void disableBackend(DatabaseBackend db)
                    throws java.sql.SQLException
Disable a backend that is currently enabled on this virtual database.

The backend is disabled without further check.

The load balancer disabled method is called on the specified backend.

Parameters:
db - The database backend to disable
Throws:
java.sql.SQLException - if an error occurs

disableBackendForCheckpoint

public void disableBackendForCheckpoint(DatabaseBackend db,
                                        java.lang.String checkpointName)
                                 throws java.sql.SQLException
The backend must belong to this virtual database and be in the enabled state.

The backend is disabled once all the pending write queries are executed. A checkpoint is inserted in the recovery log.

Parameters:
db - The database backend to enable
checkpointName - The checkpoint name to restart from
Throws:
java.sql.SQLException - if an error occurs

disableBackendsForCheckpoint

public void disableBackendsForCheckpoint(java.util.ArrayList backendsArrayList,
                                         java.lang.String checkpointName)
                                  throws java.sql.SQLException
Disable a list of backends. Only to store only one checkpoint, and to disable all the backends at the same time so the the system is in a coherent state. Consider only the backends that were enabled. The others are left in the state they were before.

Parameters:
backendsArrayList - backends to disable
checkpointName - to store
Throws:
java.sql.SQLException - if an error occurs

backupBackend

public void backupBackend(DatabaseBackend backend,
                          java.lang.String login,
                          java.lang.String password,
                          java.lang.String dumpName,
                          java.lang.String backuperName,
                          java.lang.String path,
                          java.util.ArrayList tables)
                   throws java.sql.SQLException
Create a backup from the content of a backend.

Parameters:
backend - the target backend to backup
login - the login to use to connect to the database for the backup operation
password - the password to use to connect to the database for the backup operation
dumpName - the name of the dump to create
backuperName - the logical name of the backuper to use
path - the path where to store the dump
tables - the list of tables to backup, null means all tables
Throws:
java.sql.SQLException - if the backup fails

restoreBackendFromBackupCheckpoint

public void restoreBackendFromBackupCheckpoint(DatabaseBackend backend,
                                               java.lang.String login,
                                               java.lang.String password,
                                               java.lang.String dumpName,
                                               java.util.ArrayList tables)
                                        throws BackupException
Restore a dump on a specific backend. The proper Backuper is retrieved automatically according to the dump format stored in the recovery log dump table.

This method disables the backend and leave it disabled after recovery process. The user has to call the enableBackendFromCheckpoint after this.

Parameters:
backend - the backend to restore
login - the login to use to connect to the database for the restore operation
password - the password to use to connect to the database for the restore operation
dumpName - the name of the dump to restore
tables - the list of tables to restore, null means all tables
Throws:
BackupException - if the restore operation failed

storeBackendsInfo

public void storeBackendsInfo(java.lang.String databaseName,
                              java.util.ArrayList backends)
Store all the backends checkpoint in the recoverylog

Parameters:
databaseName - the virtual database name
backends - the Arraylist of backends

removeCheckpoint

public void removeCheckpoint(java.lang.String checkpointName)
                      throws java.sql.SQLException
Remove a checkpoint and corresponding entries from the log table

Parameters:
checkpointName - to remove
Throws:
java.sql.SQLException - if fails

getDatabaseSchema

public DatabaseSchema getDatabaseSchema()
Get the DatabaseSchema used by this Request Manager.

Returns:
a DatabaseSchema value

mergeDatabaseSchema

public void mergeDatabaseSchema(DatabaseSchema backendSchema)
Merge the given schema with the existing database schema.

Parameters:
backendSchema - The virtual database schema to merge.

setDatabaseSchema

public void setDatabaseSchema(DatabaseSchema schema,
                              boolean isStatic)
Sets the DatabaseSchema to be able to parse the requests and find dependencies.

Parameters:
schema - a DatabaseSchema value
isStatic - true if the given schema is static

setSchemaIsDirty

public void setSchemaIsDirty(boolean schemaIsDirty)
Sets the schemaIsDirty value if the backend schema needs to be refreshed.

Parameters:
schemaIsDirty - The schemaIsDirty to set.

getVirtualDatabase

public VirtualDatabase getVirtualDatabase()
Returns the vdb value.

Returns:
Returns the vdb.

setBackupManager

public void setBackupManager(BackupManager currentBackupManager)
Sets the backup manager for this recovery log

Parameters:
currentBackupManager - an instance of BackupManager

getBackupManager

public BackupManager getBackupManager()
Returns the backupManager value.

Returns:
Returns the backupManager.

getLoadBalancer

public AbstractLoadBalancer getLoadBalancer()
Get the Request Load Balancer used in this Request Controller.

Returns:
an AbstractLoadBalancer value

setLoadBalancer

public void setLoadBalancer(AbstractLoadBalancer loadBalancer)
Set the Request Load Balancer to use in this Request Controller.

Parameters:
loadBalancer - a Request Load Balancer implementation

getResultCache

public AbstractResultCache getResultCache()
Get the result cache (if any) used in this Request Manager.

Returns:
an AbstractResultCache value or null if no Reqsult Cache has been defined

getMetadataCache

public MetadataCache getMetadataCache()
Returns the metadataCache value.

Returns:
Returns the metadataCache.

setMetadataCache

public void setMetadataCache(MetadataCache metadataCache)
Sets the metadataCache value.

Parameters:
metadataCache - The metadataCache to set.

setParsingCache

public void setParsingCache(ParsingCache parsingCache)
Sets the ParsingCache.

Parameters:
parsingCache - The parsingCache to set.

getRecoveryLog

public RecoveryLog getRecoveryLog()
Returns the Recovery Log Manager.

Returns:
RecoveryLog

setRecoveryLog

public void setRecoveryLog(RecoveryLog recoveryLog)
Sets the Recovery Log Manager.

Parameters:
recoveryLog - The log recovery to set

setResultCache

public void setResultCache(AbstractResultCache cache)
Set the Request Cache to use in this Request Controller.

Parameters:
cache - a Request Cache implementation

getScheduler

public AbstractScheduler getScheduler()
Get the Request Scheduler (if any) used in this Request Controller.

Returns:
an AbstractScheduler value or null if no Request Scheduler has been defined

setScheduler

public void setScheduler(AbstractScheduler scheduler)
Set the Request Scheduler to use in this Request Controller.

Parameters:
scheduler - a Request Scheduler implementation

setCaseSensitiveParsing

public void setCaseSensitiveParsing(boolean isCaseSensitiveParsing)
Sets the parsing case sensitivity. If true the request are parsed in a case sensitive way (table/column name must match exactly the case of the names fetched from the database or enforced by a static schema).

Specified by:
setCaseSensitiveParsing in interface RequestManagerMBean
Parameters:
isCaseSensitiveParsing - true if parsing is case sensitive

getXml

public java.lang.String getXml()
Get xml information about this Request Manager

Specified by:
getXml in interface XmlComponent
Returns:
String in xml formatted text

getBackendStateListener

public BackendStateListener getBackendStateListener()
Returns the backendStateListener value.

Returns:
Returns the backendStateListener.

getBeginTimeout

public long getBeginTimeout()
Returns the beginTimeout value.

Specified by:
getBeginTimeout in interface RequestManagerMBean
Returns:
Returns the beginTimeout.

setBeginTimeout

public void setBeginTimeout(long beginTimeout)
Sets the beginTimeout value.

Specified by:
setBeginTimeout in interface RequestManagerMBean
Parameters:
beginTimeout - The beginTimeout to set.

getCacheParsingranularity

public int getCacheParsingranularity()
Returns the cacheParsingranularity value.

Specified by:
getCacheParsingranularity in interface RequestManagerMBean
Returns:
Returns the cacheParsingranularity.

setCacheParsingranularity

public void setCacheParsingranularity(int cacheParsingranularity)
Sets the cacheParsingranularity value.

Specified by:
setCacheParsingranularity in interface RequestManagerMBean
Parameters:
cacheParsingranularity - The cacheParsingranularity to set.

getCommitTimeout

public long getCommitTimeout()
Returns the commitTimeout value.

Specified by:
getCommitTimeout in interface RequestManagerMBean
Returns:
Returns the commitTimeout.

setCommitTimeout

public void setCommitTimeout(long commitTimeout)
Sets the commitTimeout value.

Specified by:
setCommitTimeout in interface RequestManagerMBean
Parameters:
commitTimeout - The commitTimeout to set.

getLoadBalancerParsingranularity

public int getLoadBalancerParsingranularity()
Returns the loadBalancerParsingranularity value.

Specified by:
getLoadBalancerParsingranularity in interface RequestManagerMBean
Returns:
Returns the loadBalancerParsingranularity.

setLoadBalancerParsingranularity

public void setLoadBalancerParsingranularity(int loadBalancerParsingranularity)
Sets the loadBalancerParsingranularity value.

Specified by:
setLoadBalancerParsingranularity in interface RequestManagerMBean
Parameters:
loadBalancerParsingranularity - The loadBalancerParsingranularity to set.

getRequiredParsingGranularity

public int getRequiredParsingGranularity()
Returns the requiredParsingGranularity value.

Specified by:
getRequiredParsingGranularity in interface RequestManagerMBean
Returns:
Returns the requiredParsingGranularity.

setRequiredParsingGranularity

public void setRequiredParsingGranularity(int requiredGranularity)
Sets the requiredParsingGranularity value.

Specified by:
setRequiredParsingGranularity in interface RequestManagerMBean
Parameters:
requiredGranularity - The requiredParsingGranularity to set.

getRollbackTimeout

public long getRollbackTimeout()
Returns the rollbackTimeout value.

Specified by:
getRollbackTimeout in interface RequestManagerMBean
Returns:
Returns the rollbackTimeout.

setRollbackTimeout

public void setRollbackTimeout(long rollbackTimeout)
Sets the rollbackTimeout value.

Specified by:
setRollbackTimeout in interface RequestManagerMBean
Parameters:
rollbackTimeout - The rollbackTimeout to set.

getSchedulerParsingranularity

public int getSchedulerParsingranularity()
Returns the schedulerParsingranularity value.

Specified by:
getSchedulerParsingranularity in interface RequestManagerMBean
Returns:
Returns the schedulerParsingranularity.

setSchedulerParsingranularity

public void setSchedulerParsingranularity(int schedulerParsingranularity)
Sets the schedulerParsingranularity value.

Specified by:
setSchedulerParsingranularity in interface RequestManagerMBean
Parameters:
schedulerParsingranularity - The schedulerParsingranularity to set.

isSchemaIsStatic

public boolean isSchemaIsStatic()
Returns the schemaIsStatic value.

Specified by:
isSchemaIsStatic in interface RequestManagerMBean
Returns:
Returns the schemaIsStatic.

setSchemaIsStatic

public void setSchemaIsStatic(boolean schemaIsStatic)
Sets the schemaIsStatic value.

Specified by:
setSchemaIsStatic in interface RequestManagerMBean
Parameters:
schemaIsStatic - The schemaIsStatic to set.

isCaseSensitiveParsing

public boolean isCaseSensitiveParsing()
Returns the isCaseSensitiveParsing value.

Specified by:
isCaseSensitiveParsing in interface RequestManagerMBean
Returns:
Returns the isCaseSensitiveParsing.

getAssociatedString

public java.lang.String getAssociatedString()
Description copied from class: AbstractStandardMBean
Allow to retrieve internationalization description on mbeans as well

Specified by:
getAssociatedString in class AbstractStandardMBean
Returns:
part of the key to look for in the translation file.
See Also:
AbstractStandardMBean.getAssociatedString()


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.