|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.management.StandardMBean org.objectweb.cjdbc.controller.jmx.AbstractStandardMBean org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer
The Request Load Balancer should implement the load balancing of the requests among the backend nodes.
The requests comes from the Request Controller and are sent to the Connection Managers.
Nested Class Summary |
Nested classes inherited from class javax.management.StandardMBean |
|
Field Summary | |
protected static Trace |
logger
|
protected MacrosHandler |
macroHandler
|
protected int |
parsingGranularity
|
protected int |
raidbLevel
|
protected java.util.LinkedList |
totalOrderQueue
Reference to distributed virtual database total order queue |
protected VirtualDatabase |
vdb
|
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 | |
protected |
AbstractLoadBalancer(VirtualDatabase vdb,
int raidbLevel,
int parsingGranularity)
Generic constructor that sets some member variables and checks that backends are in the disabled state |
Method Summary | |
abstract void |
begin(TransactionMarkerMetaData tm)
Begin a new transaction. |
abstract void |
commit(TransactionMarkerMetaData tm)
Commit a transaction. |
abstract void |
disableBackend(DatabaseBackend db)
Disable a backend without further check. |
abstract void |
enableBackend(DatabaseBackend db,
boolean writeEnabled)
Enable a backend without further check. |
abstract ControllerResultSet |
execReadOnlyReadStoredProcedure(StoredProcedure proc,
MetadataCache metadataCache)
Call a read-only stored procedure that returns a ResultSet. |
abstract ControllerResultSet |
execReadRequest(SelectRequest request,
MetadataCache metadataCache)
Perform a read request. |
abstract ControllerResultSet |
execReadStoredProcedure(StoredProcedure proc,
MetadataCache metadataCache)
Call a stored procedure that returns a ResultSet. |
static ControllerResultSet |
executeReadStoredProcedureOnBackend(StoredProcedure proc,
DatabaseBackend backend,
java.sql.Connection c,
MetadataCache metadataCache)
Execute a read stored procedure on the given backend. |
static ControllerResultSet |
executeSelectRequestOnBackend(SelectRequest request,
DatabaseBackend backend,
java.sql.Connection c,
MetadataCache metadataCache)
Execute a statement on a backend. |
static int |
executeUpdateRequestOnBackend(AbstractWriteRequest request,
DatabaseBackend backend,
java.sql.Connection c)
Execute an update prepared statement on a backend. |
static ControllerResultSet |
executeUpdateRequestOnBackendWithKeys(AbstractWriteRequest request,
DatabaseBackend backend,
java.sql.Connection c,
MetadataCache metadataCache)
Execute an update prepared statement on a backend. |
static int |
executeWriteStoredProcedureOnBackend(StoredProcedure proc,
DatabaseBackend backend,
java.sql.Connection c)
Execute a write stored procedure on the given backend. |
abstract int |
execWriteRequest(AbstractWriteRequest request)
Perform a write request. |
abstract ControllerResultSet |
execWriteRequestWithKeys(AbstractWriteRequest request,
MetadataCache metadataCache)
Perform a write request and return a ResultSet containing the auto generated keys. |
abstract 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 |
static java.sql.Connection |
getConnectionAndBeginTransaction(DatabaseBackend backend,
AbstractConnectionManager cm,
long tid,
int transactionIsolationLevel)
Factorized code to start a transaction on a backend and to retrieve a connection on this backend |
abstract java.lang.String |
getInformation()
Get information about the Request Load Balancer |
abstract int |
getNumberOfEnabledBackends()
Get the number of currently enabled backends. 0 means that no backend is available. |
int |
getParsingGranularity()
Get the needed query parsing granularity. |
int |
getRAIDbLevel()
Returns the RAIDbLevel. |
java.lang.String |
getXml()
Get xml formatted representation of this cjdbc component |
abstract java.lang.String |
getXmlImpl()
Get information about the Request Load Balancer in xml |
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 void |
releaseSavepoint(TransactionMarkerMetaData tm,
java.lang.String name)
Release a savepoint from a transaction |
void |
removeHeadFromAndNotifyTotalOrderQueue()
Remove the first entry of the total order queue and notify the queue so that the next queries can be scheduled. |
abstract void |
rollback(TransactionMarkerMetaData tm)
Rollback a transaction. |
abstract void |
rollback(TransactionMarkerMetaData tm,
java.lang.String savepointName)
Rollback a transaction to a savepoint |
void |
setMacroHandler(MacrosHandler handler)
This sets the macro handler for this load balancer. |
void |
setParsingGranularity(int parsingGranularity)
Set the needed query parsing granularity. |
void |
setRAIDbLevel(int raidbLevel)
Sets the RAIDbLevel. |
abstract void |
setSavepoint(TransactionMarkerMetaData tm,
java.lang.String name)
Set a savepoint to a transaction. |
void |
setWeight(java.lang.String name,
int w)
Associate a weight to a backend identified by its logical name. |
boolean |
waitForTotalOrder(java.lang.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. |
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 VirtualDatabase vdb
protected int raidbLevel
protected int parsingGranularity
protected java.util.LinkedList totalOrderQueue
protected static Trace logger
protected MacrosHandler macroHandler
Constructor Detail |
protected AbstractLoadBalancer(VirtualDatabase vdb, int raidbLevel, int parsingGranularity) throws java.sql.SQLException, javax.management.NotCompliantMBeanException
vdb
- The virtual database this load balancer belongs toraidbLevel
- The RAIDb level of this load balancerparsingGranularity
- The parsing granularity needed by this load
balancerMethod Detail |
public int getRAIDbLevel()
getRAIDbLevel
in interface AbstractLoadBalancerMBean
public void setRAIDbLevel(int raidbLevel)
setRAIDbLevel
in interface AbstractLoadBalancerMBean
raidbLevel
- The RAIDb level to setpublic int getParsingGranularity()
getParsingGranularity
in interface AbstractLoadBalancerMBean
public void setParsingGranularity(int parsingGranularity)
setParsingGranularity
in interface AbstractLoadBalancerMBean
parsingGranularity
- the granularity to setpublic void handleMacros(AbstractRequest request)
MacroHandler
set for this class) and modify either the
skeleton or the query itself. Note that the given object is directly
modified.
request
- the request to processpublic boolean waitForTotalOrder(java.lang.Object request, boolean errorIfNotFound)
request
- the request to wait for (can be any object but usually a
DistributedRequest, Commit or Rollback)errorIfNotFound
- true if an error message should be logged if the
request is not found in the total order queue
removeHeadFromAndNotifyTotalOrderQueue()
public void removeHeadFromAndNotifyTotalOrderQueue()
public abstract ControllerResultSet execReadRequest(SelectRequest request, MetadataCache metadataCache) throws java.sql.SQLException
request
- an SelectRequest
metadataCache
- MetadataCache (null if none)
ControllerResultSet
java.sql.SQLException
- if an error occurspublic abstract int execWriteRequest(AbstractWriteRequest request) throws AllBackendsFailedException, java.sql.SQLException
request
- an AbstractWriteRequest
AllBackendsFailedException
- if all backends failed to execute the
request
java.sql.SQLException
- if an error occurspublic abstract ControllerResultSet execWriteRequestWithKeys(AbstractWriteRequest request, MetadataCache metadataCache) throws AllBackendsFailedException, java.sql.SQLException
request
- an AbstractWriteRequest
metadataCache
- MetadataCache (null if none)
AllBackendsFailedException
- if all backends failed to execute the
request
java.sql.SQLException
- if an error occurspublic abstract ControllerResultSet execReadOnlyReadStoredProcedure(StoredProcedure proc, MetadataCache metadataCache) throws java.sql.SQLException
proc
- the stored procedure callmetadataCache
- MetadataCache (null if none)
ControllerResultSet
value
java.sql.SQLException
- if an error occurspublic abstract ControllerResultSet execReadStoredProcedure(StoredProcedure proc, MetadataCache metadataCache) throws AllBackendsFailedException, java.sql.SQLException
proc
- the stored procedure callmetadataCache
- MetadataCache (null if none)
ControllerResultSet
value
AllBackendsFailedException
- if all backends failed to execute the
request
java.sql.SQLException
- if an error occurspublic abstract int execWriteStoredProcedure(StoredProcedure proc) throws AllBackendsFailedException, java.sql.SQLException
proc
- the stored procedure call
AllBackendsFailedException
- if all backends failed to execute the
request
java.sql.SQLException
- if an error occurspublic static final ControllerResultSet executeSelectRequestOnBackend(SelectRequest request, DatabaseBackend backend, java.sql.Connection c, MetadataCache metadataCache) throws java.sql.SQLException, BadConnectionException
request
- the request to executebackend
- the backend on which the request is executedc
- connection used to create the statementmetadataCache
- MetadataCache (null if none)
java.sql.SQLException
- if an error occurs
BadConnectionException
- if the connection was badpublic static final int executeUpdateRequestOnBackend(AbstractWriteRequest request, DatabaseBackend backend, java.sql.Connection c) throws java.sql.SQLException, BadConnectionException
request
- the request to executebackend
- the backend on which the request is executedc
- connection used to create the statement
java.sql.SQLException
- if an error occurs
BadConnectionException
- if the connection was badpublic static final ControllerResultSet executeUpdateRequestOnBackendWithKeys(AbstractWriteRequest request, DatabaseBackend backend, java.sql.Connection c, MetadataCache metadataCache) throws java.sql.SQLException, BadConnectionException
request
- the request to executebackend
- the backend on which the request is executedc
- connection used to create the statementmetadataCache
- MetadataCache (null if none)
java.sql.SQLException
- if an error occurs
BadConnectionException
- if the connection was badpublic static final ControllerResultSet executeReadStoredProcedureOnBackend(StoredProcedure proc, DatabaseBackend backend, java.sql.Connection c, MetadataCache metadataCache) throws java.sql.SQLException, BadConnectionException
proc
- the stored procedure to executebackend
- the backend on which to execute the stored procedurec
- the connection on which to execute the stored proceduremetadataCache
- the matedatacache to build the ControllerResultSet
java.sql.SQLException
- if an error occurs
BadConnectionException
- if the connection was badpublic static final int executeWriteStoredProcedureOnBackend(StoredProcedure proc, DatabaseBackend backend, java.sql.Connection c) throws java.sql.SQLException, BadConnectionException
proc
- the stored procedure to executebackend
- the backend on which to execute the stored procedurec
- the connection on which to execute the stored procedure
java.sql.SQLException
- if an error occurs
BadConnectionException
- if the connection was badpublic abstract void begin(TransactionMarkerMetaData tm) throws java.sql.SQLException
tm
- The transaction marker metadata
java.sql.SQLException
- if an error occurspublic abstract void commit(TransactionMarkerMetaData tm) throws AllBackendsFailedException, java.sql.SQLException
tm
- The transaction marker metadata
AllBackendsFailedException
- if all backends failed to execute the
request
java.sql.SQLException
- if an error occurspublic abstract void rollback(TransactionMarkerMetaData tm) throws AllBackendsFailedException, java.sql.SQLException
tm
- The transaction marker metadata
AllBackendsFailedException
- if all backends failed to execute the
request
java.sql.SQLException
- if an error occurspublic abstract void rollback(TransactionMarkerMetaData tm, java.lang.String savepointName) throws AllBackendsFailedException, java.sql.SQLException
tm
- The transaction marker metadatasavepointName
- The name of the savepoint
AllBackendsFailedException
- if all backends failed to execute the
request
java.sql.SQLException
- if an error occurspublic abstract void setSavepoint(TransactionMarkerMetaData tm, java.lang.String name) throws AllBackendsFailedException, java.sql.SQLException
tm
- The transaction marker metadataname
- The name of the new savepoint
AllBackendsFailedException
- if all backends failed to execute the
request
java.sql.SQLException
- if an error occurspublic abstract void releaseSavepoint(TransactionMarkerMetaData tm, java.lang.String name) throws AllBackendsFailedException, java.sql.SQLException
tm
- The transaction marker metadataname
- The name of the savepoint ro release
AllBackendsFailedException
- if all backends failed to execute the
request
java.sql.SQLException
- if an error occurspublic static final java.sql.Connection getConnectionAndBeginTransaction(DatabaseBackend backend, AbstractConnectionManager cm, long tid, int transactionIsolationLevel) throws java.sql.SQLException, UnreachableBackendException
backend
- the backend needed to check valid connection against this
backend test statementcm
- the connection manager to use to retrieve connectionstid
- the id of the transaction to starttransactionIsolationLevel
- transaction isolation level to use for a
new transaction (does nothing if equals to
Connection.DEFAULT_TRANSACTION_ISOLATION_LEVEL)
java.sql.SQLException
- if the backend is valid but set autocommit cannot be
set to false
UnreachableBackendException
- if the backend is not reachable, ie not
valid connection can be retrievedConnection.DEFAULT_TRANSACTION_ISOLATION_LEVEL
public abstract void enableBackend(DatabaseBackend db, boolean writeEnabled) throws java.sql.SQLException
db
- The database backend to enablewriteEnabled
- True if the backend must be enabled for writes
java.sql.SQLException
- if an error occurspublic abstract void disableBackend(DatabaseBackend db) throws java.sql.SQLException
RequestManager.disableBackeknd(...)
method.
db
- The database backend to disable
java.sql.SQLException
- if an error occurspublic abstract int getNumberOfEnabledBackends()
public void setWeight(java.lang.String name, int w) throws java.sql.SQLException
setWeight
in interface AbstractLoadBalancerMBean
name
- the backend namew
- the weight
java.sql.SQLException
- if an error occurspublic abstract java.lang.String getInformation()
getInformation
in interface AbstractLoadBalancerMBean
String
containing informationpublic abstract java.lang.String getXmlImpl()
String
containing information, xml formattedpublic void setMacroHandler(MacrosHandler handler)
handler
- MacrosHandler
instancepublic java.lang.String getXml()
XmlComponent
getXml
in interface XmlComponent
XmlComponent.getXml()
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 |