|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.management.StandardMBean
org.objectweb.cjdbc.controller.jmx.AbstractStandardMBean
org.objectweb.cjdbc.controller.requestmanager.RequestManager
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.
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 AbstractRecoveryLog |
recoveryLog
An optional recovery log |
protected int |
requiredGranularity
|
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 |
schemaIsStatic
|
protected java.util.Hashtable |
tidLoginTable
Transaction id/Login 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_DB, XML_VERSION |
Constructor Summary | |
RequestManager(VirtualDatabase vdb,
AbstractScheduler scheduler,
AbstractResultCache cache,
AbstractLoadBalancer loadBalancer,
AbstractRecoveryLog recoveryLog,
long beginTimeout,
long commitTimeout,
long rollbackTimeout)
Creates a new RequestManager instance. |
Method Summary | |
void |
abort(long transactionId)
Abort a transaction that has been started but in which no query was executed. |
private void |
assignAndCheckSchedulerLoadBalancerValidity(AbstractScheduler scheduler,
AbstractLoadBalancer loadBalancer)
Check that Scheduler and Load Balancer are not null and have compatible RAIDb levels. |
void |
backupBackendWithCheckpoint(DatabaseBackend db,
java.lang.String checkpointName,
java.util.ArrayList tables,
boolean enableAfter,
boolean wait4Result,
BackupListener listener)
Creates a new backup with the corresponding checkpoint Note that this will disable the backend for the time of the backup |
long |
begin(java.lang.String login)
Begin a new transaction and return the corresponding transaction identifier. |
void |
callBackupManager(boolean backup,
DatabaseBackend db,
java.lang.String checkpoint,
java.util.ArrayList tables,
boolean enableAfter,
BackupListener listener)
Call the backup manager on the given backend. |
void |
commit(long transactionId)
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. |
void |
enableBackendFromCheckpoint(DatabaseBackend db,
java.lang.String checkpointName,
boolean threaded)
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. |
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. |
AbstractRecoveryLog |
getRecoveryLog()
Returns the Recovery Log Manager. |
int |
getRequiredGranularity()
Returns the requiredGranularity value. |
int |
getRequiredParsingGranularity()
|
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 |
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. |
void |
mergeDatabaseSchema(DatabaseSchema backendSchema)
Merge the given schema with the existing database schema. |
void |
removeCheckpoint(java.lang.String checkpointName)
Remove a checkpoint and corresponding entries from the log table |
void |
restoreBackendFromBackupCheckpoint(DatabaseBackend db,
java.lang.String checkpointName,
boolean wait4Result,
BackupListener listener)
Recopy all the data of a previous dump recorded by octopus into the named backend. |
void |
rollback(long transactionId)
Rollback a transaction given its id. |
void |
scheduleExecWriteRequest(AbstractWriteRequest request)
Schedule a request for execution. |
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(AbstractRecoveryLog recoveryLog)
Sets the Recovery Log Manager. |
void |
setRequiredGranularity(int requiredGranularity)
Sets the requiredGranularity value. |
void |
setResultCache(AbstractResultCache cache)
Set the Request Cache to use in this Request Controller. |
void |
setRollbackTimeout(long rollbackTimeout)
Sets the rollbackTimeout value. |
void |
setScheduler(AbstractScheduler scheduler)
Set the Request Scheduler to use in this Request Controller. |
void |
setSchedulerParsingranularity(int schedulerParsingranularity)
Sets the schedulerParsingranularity value. |
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,
boolean notifyRecoveryLogAndScheduler)
Update the cache, notify the recovery log and finally 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 |
protected long beginTimeout
protected long commitTimeout
protected long rollbackTimeout
protected VirtualDatabase vdb
protected AbstractScheduler scheduler
protected AbstractResultCache resultCache
protected AbstractLoadBalancer loadBalancer
protected AbstractRecoveryLog recoveryLog
protected BackupManager backupManager
protected DatabaseSchema dbs
private boolean schemaIsStatic
private boolean isCaseSensitiveParsing
protected ParsingCache parsingCache
private MetadataCache metadataCache
protected int schedulerParsingranularity
private int cacheParsingranularity
private int loadBalancerParsingranularity
protected int requiredGranularity
protected java.util.Hashtable tidLoginTable
protected static Trace logger
private BackendStateListener backendStateListener
Constructor Detail |
public RequestManager(VirtualDatabase vdb, AbstractScheduler scheduler, AbstractResultCache cache, AbstractLoadBalancer loadBalancer, AbstractRecoveryLog recoveryLog, long beginTimeout, long commitTimeout, long rollbackTimeout) throws java.sql.SQLException, javax.management.NotCompliantMBeanException
RequestManager
instance.
vdb
- the virtual database this request manager belongs toscheduler
- the Request Scheduler to usecache
- a Query Cache implementationloadBalancer
- the Request Load Balancer to userecoveryLog
- the Log Recovery to usebeginTimeout
- timeout in seconds for begincommitTimeout
- timeout in seconds for commitrollbackTimeout
- timeout in seconds for rollback
java.sql.SQLException
- if an error occurs
javax.management.NotCompliantMBeanException
- if the MBean is not JMX compliantMethod Detail |
private void setBackendsLastKnownCheckpointFromRecoveryLog()
private void assignAndCheckSchedulerLoadBalancerValidity(AbstractScheduler scheduler, AbstractLoadBalancer loadBalancer) throws java.sql.SQLException
scheduler
- loadBalancer
-
java.sql.SQLException
- if an error occursprivate void initRequestManagerVariables(VirtualDatabase vdb, long beginTimeout, long commitTimeout, long rollbackTimeout)
vdb
- beginTimeout
- commitTimeout
- rollbackTimeout
- public ControllerResultSet execReadRequest(SelectRequest request) throws java.sql.SQLException
request
- the request to execute
ControllerResultSet
value
java.sql.SQLException
- if an error occurspublic int execWriteRequest(AbstractWriteRequest request) throws java.sql.SQLException
request
- the request to execute
java.sql.SQLException
- if an error occurspublic ControllerResultSet execWriteRequestWithKeys(AbstractWriteRequest request) throws java.sql.SQLException
request
- the request to execute
java.sql.SQLException
- if an error occurspublic void scheduleExecWriteRequest(AbstractWriteRequest request) throws java.sql.SQLException
request
- the request to execute
java.sql.SQLException
- if an error occurspublic ControllerResultSet loadBalanceExecWriteRequestWithKeys(AbstractWriteRequest request) throws AllBackendsFailedException, java.sql.SQLException
request
- the request to execute
AllBackendsFailedException
- if all backends failed to execute the
query
java.sql.SQLException
- if an error occurspublic int loadBalanceExecWriteRequest(AbstractWriteRequest request) throws AllBackendsFailedException, java.sql.SQLException
request
- the request to execute
AllBackendsFailedException
- if all backends failed to execute the
query
java.sql.SQLException
- if an error occurspublic void updateAndNotifyExecWriteRequest(AbstractWriteRequest request, boolean notifyRecoveryLogAndScheduler) throws java.sql.SQLException
request
- the request to executenotifyRecoveryLogAndScheduler
- true if the recovery log and the
scheduler must be notified
java.sql.SQLException
- if an error occurspublic ControllerResultSet execReadStoredProcedure(StoredProcedure proc) throws java.sql.SQLException
proc
- the stored procedure call
ControllerResultSet
value
java.sql.SQLException
- if an error occurspublic int execWriteStoredProcedure(StoredProcedure proc) throws java.sql.SQLException
proc
- the stored procedure call
java.sql.SQLException
- if an error occurspublic long begin(java.lang.String login) throws java.sql.SQLException
login
- the login used by the connection
java.sql.SQLException
- if an error occurspublic void abort(long transactionId) throws java.sql.SQLException
transactionId
- id of the transaction to abort
java.sql.SQLException
- if an error occurspublic TransactionMarkerMetaData getTransactionMarker(java.lang.Long tid) throws java.sql.SQLException
tid
- transaction id
java.sql.SQLException
- if no marker has been found for this transactionpublic void completeTransaction(java.lang.Long tid)
tid
- transaction idpublic void commit(long transactionId) throws java.sql.SQLException
transactionId
- the transaction id
java.sql.SQLException
- if an error occurspublic void rollback(long transactionId) throws java.sql.SQLException
transactionId
- the transaction id
java.sql.SQLException
- if an error occurspublic void enableBackend(DatabaseBackend db) throws java.sql.SQLException
The backend is enabled without further check.
The enableBackend method of the load balancer is called.
db
- The database backend to enable
java.sql.SQLException
- if an error occurspublic void enableBackendFromCheckpoint(DatabaseBackend db, java.lang.String checkpointName, boolean threaded) throws java.sql.SQLException
All the queries since the given checkpoint are played and the backend state is set to enabled when it is completely synchronized.
db
- The database backend to enablecheckpointName
- The checkpoint name to restart fromthreaded
- true force the recory to be executed in a fire
and forget mode
java.sql.SQLException
- if an error occurspublic void disableBackend(DatabaseBackend db) throws java.sql.SQLException
The backend is disabled without further check.
The load balancer disabled method is called on the specified backend.
db
- The database backend to disable
java.sql.SQLException
- if an error occurspublic void disableBackendForCheckpoint(DatabaseBackend db, java.lang.String checkpointName) throws java.sql.SQLException
The backend is disabled once all the pending write queries are executed. A checkpoint is inserted in the recovery log.
db
- The database backend to enablecheckpointName
- The checkpoint name to restart from
java.sql.SQLException
- if an error occurspublic void disableBackendsForCheckpoint(java.util.ArrayList backendsArrayList, java.lang.String checkpointName) throws java.sql.SQLException
backendsArrayList
- backends to disablecheckpointName
- to store
java.sql.SQLException
- if an error occurspublic void callBackupManager(boolean backup, DatabaseBackend db, java.lang.String checkpoint, java.util.ArrayList tables, boolean enableAfter, BackupListener listener) throws java.lang.Exception
backup
- true if this is a backup, false if this is a restore processdb
- backend objectcheckpoint
- the name of the checkpoint associated with the processtables
- the tables to consider while performing the copyenableAfter
- should be enable the backend automatically afterlistener
- backup listener for callback
java.lang.Exception
- if failspublic void backupBackendWithCheckpoint(DatabaseBackend db, java.lang.String checkpointName, java.util.ArrayList tables, boolean enableAfter, boolean wait4Result, BackupListener listener) throws java.sql.SQLException
db
- the backend to backupcheckpointName
- the checkpoint to insert in the logtables
- to copy or null for copy allenableAfter
- if the backend should be enable after backupwait4Result
- if the method should block until the backup is overlistener
- object for callback
java.sql.SQLException
- if failspublic void restoreBackendFromBackupCheckpoint(DatabaseBackend db, java.lang.String checkpointName, boolean wait4Result, BackupListener listener) throws OctopusException, BackupException
enableBackendFromCheckpoint
after this.
db
- the backend to restorecheckpointName
- the name of the checkpoint that has a dumpwait4Result
- should we blocked this method until the restore is
finishedlistener
- object for callback
OctopusException
- if backup failed while in octopus mode
BackupException
- if backup failed for other reasonspublic void storeBackendsInfo(java.lang.String databaseName, java.util.ArrayList backends)
databaseName
- the virtual database namebackends
- the Arraylist
of backendspublic void removeCheckpoint(java.lang.String checkpointName) throws java.sql.SQLException
checkpointName
- to remove
java.sql.SQLException
- if failspublic VirtualDatabase getVirtualDatabase()
public void setDatabaseSchema(DatabaseSchema schema, boolean isStatic)
DatabaseSchema
to be able to parse the requests and
find dependencies.
schema
- a DatabaseSchema
valueisStatic
- true if the given schema is staticpublic void mergeDatabaseSchema(DatabaseSchema backendSchema)
backendSchema
- The virtual database schema to merge.public void setBackupManager(BackupManager currentBackupManager)
currentBackupManager
- an instance of BackupManager
public BackupManager getBackupManager()
public DatabaseSchema getDatabaseSchema()
DatabaseSchema
used by this Request Manager.
DatabaseSchema
valuepublic AbstractLoadBalancer getLoadBalancer()
AbstractLoadBalancer
valuepublic void setLoadBalancer(AbstractLoadBalancer loadBalancer)
loadBalancer
- a Request Load Balancer implementationpublic AbstractResultCache getResultCache()
AbstractResultCache
value or null if no Reqsult
Cache has been definedpublic MetadataCache getMetadataCache()
public void setMetadataCache(MetadataCache metadataCache)
metadataCache
- The metadataCache to set.public void setParsingCache(ParsingCache parsingCache)
parsingCache
- The parsingCache to set.public AbstractRecoveryLog getRecoveryLog()
public void setRecoveryLog(AbstractRecoveryLog recoveryLog)
recoveryLog
- The log recovery to setpublic void setResultCache(AbstractResultCache cache)
cache
- a Request Cache implementationpublic AbstractScheduler getScheduler()
AbstractScheduler
value or null if no Request
Scheduler has been definedpublic void setScheduler(AbstractScheduler scheduler)
scheduler
- a Request Scheduler implementationpublic void setCaseSensitiveParsing(boolean isCaseSensitiveParsing)
setCaseSensitiveParsing
in interface RequestManagerMBean
isCaseSensitiveParsing
- true if parsing is case sensitivepublic int getRequiredParsingGranularity()
getRequiredParsingGranularity
in interface RequestManagerMBean
public java.lang.String getXml()
getXml
in interface XmlComponent
String
in xml formatted textpublic BackendStateListener getBackendStateListener()
public long getBeginTimeout()
getBeginTimeout
in interface RequestManagerMBean
public void setBeginTimeout(long beginTimeout)
setBeginTimeout
in interface RequestManagerMBean
beginTimeout
- The beginTimeout to set.public int getCacheParsingranularity()
getCacheParsingranularity
in interface RequestManagerMBean
public void setCacheParsingranularity(int cacheParsingranularity)
setCacheParsingranularity
in interface RequestManagerMBean
cacheParsingranularity
- The cacheParsingranularity to set.public long getCommitTimeout()
getCommitTimeout
in interface RequestManagerMBean
public void setCommitTimeout(long commitTimeout)
setCommitTimeout
in interface RequestManagerMBean
commitTimeout
- The commitTimeout to set.public int getLoadBalancerParsingranularity()
getLoadBalancerParsingranularity
in interface RequestManagerMBean
public void setLoadBalancerParsingranularity(int loadBalancerParsingranularity)
setLoadBalancerParsingranularity
in interface RequestManagerMBean
loadBalancerParsingranularity
- The loadBalancerParsingranularity to
set.public int getRequiredGranularity()
getRequiredGranularity
in interface RequestManagerMBean
public void setRequiredGranularity(int requiredGranularity)
setRequiredGranularity
in interface RequestManagerMBean
requiredGranularity
- The requiredGranularity to set.public long getRollbackTimeout()
getRollbackTimeout
in interface RequestManagerMBean
public void setRollbackTimeout(long rollbackTimeout)
setRollbackTimeout
in interface RequestManagerMBean
rollbackTimeout
- The rollbackTimeout to set.public int getSchedulerParsingranularity()
getSchedulerParsingranularity
in interface RequestManagerMBean
public void setSchedulerParsingranularity(int schedulerParsingranularity)
setSchedulerParsingranularity
in interface RequestManagerMBean
schedulerParsingranularity
- The schedulerParsingranularity to set.public boolean isSchemaIsStatic()
isSchemaIsStatic
in interface RequestManagerMBean
public void setSchemaIsStatic(boolean schemaIsStatic)
setSchemaIsStatic
in interface RequestManagerMBean
schemaIsStatic
- The schemaIsStatic to set.public boolean isCaseSensitiveParsing()
isCaseSensitiveParsing
in interface RequestManagerMBean
public java.lang.String getAssociatedString()
AbstractStandardMBean
getAssociatedString
in class AbstractStandardMBean
AbstractStandardMBean.getAssociatedString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |