|
|||||||||||
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 org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2
RAIDb-2 load balancer.
This class is an abstract call because the read requests coming from the Request Manager are NOT treated here but in the subclasses. Transaction management and write requests are broadcasted to all backends owning the written table.
Nested Class Summary |
Nested classes inherited from class javax.management.StandardMBean |
|
Field Summary | |
protected java.util.ArrayList |
backendBlockingThreads
|
protected ReadPrioritaryFIFOWriteLock |
backendBlockingThreadsRWLock
|
protected java.util.ArrayList |
backendNonBlockingThreads
|
protected ReadPrioritaryFIFOWriteLock |
backendNonBlockingThreadsRWLock
|
protected CreateTablePolicy |
createTablePolicy
|
protected static Trace |
logger
|
protected WaitForCompletionPolicy |
waitForCompletionPolicy
|
Fields inherited from class org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer |
macroHandler, parsingGranularity, raidbLevel, totalOrderQueue, 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 | |
RAIDb2(VirtualDatabase vdb,
WaitForCompletionPolicy waitForCompletionPolicy,
CreateTablePolicy createTablePolicy)
Creates a new RAIDb-1 Round Robin request load balancer. |
Method Summary | |
void |
begin(TransactionMarkerMetaData tm)
Begins a new transaction. |
private AbstractTask |
callStoredProcedure(StoredProcedure proc,
boolean isRead,
MetadataCache metadataCache)
Post the stored procedure call in the threads task list. |
void |
commit(TransactionMarkerMetaData tm)
Commits a transaction. |
void |
disableBackend(DatabaseBackend db)
Disables a backend that was previously enabled. |
void |
enableBackend(DatabaseBackend db,
boolean writeEnabled)
Enables a Backend that was previously disabled. |
abstract ControllerResultSet |
execReadRequest(SelectRequest request,
MetadataCache metadataCache)
Implementation specific load balanced read execution. |
ControllerResultSet |
execReadStoredProcedure(StoredProcedure proc,
MetadataCache metadataCache)
Call a stored procedure that returns a ResultSet. |
protected ControllerResultSet |
executeRequestOnBackend(SelectRequest request,
DatabaseBackend backend,
MetadataCache metadataCache)
Execute a read request on the selected backend. |
protected ControllerResultSet |
executeStoredProcedureOnBackend(StoredProcedure proc,
DatabaseBackend backend,
MetadataCache metadataCache)
Execute a stored procedure on the selected backend. |
int |
execWriteRequest(AbstractWriteRequest request)
Performs a write request. |
private AbstractTask |
execWriteRequest(AbstractWriteRequest request,
boolean useKeys,
MetadataCache metadataCache)
Common code for execWriteRequest(AbstractWriteRequest) and execWriteRequestWithKeys(AbstractWriteRequest). |
ControllerResultSet |
execWriteRequestWithKeys(AbstractWriteRequest request,
MetadataCache metadataCache)
Perform a write request and return the auto generated keys. |
int |
execWriteStoredProcedure(StoredProcedure proc)
Call a stored procedure that performs an update. |
private int |
getNbToWait(int nbOfThreads)
Returns the number of nodes to wait for according to the defined waitForCompletion policy. |
int |
getNumberOfEnabledBackends()
Get the number of currently enabled backends. 0 means that no backend is available. |
abstract java.lang.String |
getRaidb2Xml()
return xml formatted information about this raidb2 load balancer |
java.lang.String |
getXmlImpl()
Get information about the Request Load Balancer in xml |
void |
releaseSavepoint(TransactionMarkerMetaData tm,
java.lang.String name)
Release a savepoint from a transaction |
void |
rollback(TransactionMarkerMetaData tm)
Rollbacks a transaction. |
void |
rollback(TransactionMarkerMetaData tm,
java.lang.String savepointName)
Rollback a transaction to a savepoint |
void |
setSavepoint(TransactionMarkerMetaData tm,
java.lang.String name)
Set a savepoint to a transaction. |
private void |
waitForAllWritesToBePostedOnBackendBlockingThreads()
Wait for all writes to be posted on BackendBlockingThreads by simply acquiring the RW lock in write and releasing it. |
protected void |
waitForAllWritesToComplete(DatabaseBackend backend)
Waits for all writes in the blocking thread queue of the given backend to complete. |
protected void |
waitForAllWritesToComplete(DatabaseBackend backend,
long transactionId)
Waits for all writes of the given transaction in the blocking thread queue of the given backend to complete before being able to complete the transaction. |
protected void |
waitForAllWritesToComplete(long transactionId)
Waits for all writes of the given transaction in the blocking thread queue to complete before being able to complete the transaction. |
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 java.util.ArrayList backendBlockingThreads
protected java.util.ArrayList backendNonBlockingThreads
protected ReadPrioritaryFIFOWriteLock backendBlockingThreadsRWLock
protected ReadPrioritaryFIFOWriteLock backendNonBlockingThreadsRWLock
protected WaitForCompletionPolicy waitForCompletionPolicy
protected CreateTablePolicy createTablePolicy
protected static Trace logger
Constructor Detail |
public RAIDb2(VirtualDatabase vdb, WaitForCompletionPolicy waitForCompletionPolicy, CreateTablePolicy createTablePolicy) throws java.lang.Exception
vdb
- the virtual database this load balancer belongs to.waitForCompletionPolicy
- how many backends must complete before
returning the result ?createTablePolicy
- the policy defining how 'create table' statements
should be handled
java.lang.Exception
- if an error occursMethod Detail |
private int getNbToWait(int nbOfThreads)
waitForCompletion
policy.
nbOfThreads
- total number of threads
public int execWriteRequest(AbstractWriteRequest request) throws AllBackendsFailedException, java.sql.SQLException
execWriteRequest
in class AbstractLoadBalancer
request
- an AbstractWriteRequest
AllBackendsFailedException
- if all backends failed to execute the
request
java.sql.SQLException
- if an error occurspublic ControllerResultSet execWriteRequestWithKeys(AbstractWriteRequest request, MetadataCache metadataCache) throws AllBackendsFailedException, java.sql.SQLException
execWriteRequestWithKeys
in class AbstractLoadBalancer
request
- the request to executemetadataCache
- the metadataCache if any or null
AllBackendsFailedException
- if all backends failed to execute the
request
java.sql.SQLException
- if an error occursprivate AbstractTask execWriteRequest(AbstractWriteRequest request, boolean useKeys, MetadataCache metadataCache) throws AllBackendsFailedException, java.sql.SQLException
Note that macros are processed here.
The result is given back in AbstractTask.getResult().
request
- the request to executeuseKeys
- true if this must give an auto generated keys ResultSetmetadataCache
- the metadataCache if any or null
AllBackendsFailedException
- if all backends failed to execute the
request
java.sql.SQLException
- if an error occurspublic abstract ControllerResultSet execReadRequest(SelectRequest request, MetadataCache metadataCache) throws java.sql.SQLException
execReadRequest
in class AbstractLoadBalancer
request
- an SelectRequest
metadataCache
- the metadataCache if any or null
java.sql.ResultSet
java.sql.SQLException
- if an error occursprotected ControllerResultSet executeRequestOnBackend(SelectRequest request, DatabaseBackend backend, MetadataCache metadataCache) throws java.sql.SQLException, UnreachableBackendException
request
- the request to executebackend
- the backend that will execute the requestmetadataCache
- a metadataCache if any or null
java.sql.SQLException
- if an error occurs
UnreachableBackendException
protected ControllerResultSet executeStoredProcedureOnBackend(StoredProcedure proc, DatabaseBackend backend, MetadataCache metadataCache) throws java.sql.SQLException, UnreachableBackendException
proc
- the stored procedure to executebackend
- the backend that will execute the requestmetadataCache
- the metadataCache if any or null
java.sql.SQLException
- if an error occurs
UnreachableBackendException
public ControllerResultSet execReadStoredProcedure(StoredProcedure proc, MetadataCache metadataCache) throws java.sql.SQLException
AbstractLoadBalancer
execReadStoredProcedure
in class AbstractLoadBalancer
proc
- the stored procedure callmetadataCache
- MetadataCache (null if none)
ControllerResultSet
value
java.sql.SQLException
- if an error occursAbstractLoadBalancer.execReadStoredProcedure(StoredProcedure,
MetadataCache)
public int execWriteStoredProcedure(StoredProcedure proc) throws java.sql.SQLException
AbstractLoadBalancer
execWriteStoredProcedure
in class AbstractLoadBalancer
proc
- the stored procedure call
java.sql.SQLException
- if an error occursAbstractLoadBalancer.execWriteStoredProcedure(StoredProcedure)
private AbstractTask callStoredProcedure(StoredProcedure proc, boolean isRead, MetadataCache metadataCache) throws java.sql.SQLException
Note that macros are processed here.
proc
- the stored procedure to callisRead
- true if the call returns a ResultSetmetadataCache
- the metadataCache if any or null
java.sql.SQLException
- if an error occurspublic final void begin(TransactionMarkerMetaData tm) throws java.sql.SQLException
begin
in class AbstractLoadBalancer
tm
- the transaction marker metadata
java.sql.SQLException
- if an error occurspublic void commit(TransactionMarkerMetaData tm) throws java.sql.SQLException
commit
in class AbstractLoadBalancer
tm
- the transaction marker metadata
java.sql.SQLException
- if an error occurspublic void rollback(TransactionMarkerMetaData tm) throws java.sql.SQLException
rollback
in class AbstractLoadBalancer
tm
- the transaction marker metadata
java.sql.SQLException
- if an error occurspublic void rollback(TransactionMarkerMetaData tm, java.lang.String savepointName) throws AllBackendsFailedException, java.sql.SQLException
rollback
in class AbstractLoadBalancer
tm
- The transaction marker metadatasavepointName
- The name of the savepoint
AllBackendsFailedException
- if all backends failed to perform the
rollback
java.sql.SQLException
- if an error occurspublic void releaseSavepoint(TransactionMarkerMetaData tm, java.lang.String name) throws java.sql.SQLException
releaseSavepoint
in class AbstractLoadBalancer
tm
- The transaction marker metadataname
- The name of the savepoint ro release
java.sql.SQLException
- if an error occurspublic void setSavepoint(TransactionMarkerMetaData tm, java.lang.String name) throws java.sql.SQLException
setSavepoint
in class AbstractLoadBalancer
tm
- The transaction marker metadataname
- The name of the new savepoint
java.sql.SQLException
- if an error occursprivate void waitForAllWritesToBePostedOnBackendBlockingThreads() throws java.sql.SQLException
java.sql.SQLException
- if we fail to acquire the lockprotected void waitForAllWritesToComplete(long transactionId) throws java.sql.SQLException
java.sql.SQLException
- if a locking error occursprotected void waitForAllWritesToComplete(DatabaseBackend backend, long transactionId) throws java.sql.SQLException
java.sql.SQLException
- if we fail to acquire the lockexecuteRequestOnBackend(org.objectweb.cjdbc.common.sql.SelectRequest, org.objectweb.cjdbc.controller.backend.DatabaseBackend, org.objectweb.cjdbc.controller.cache.metadata.MetadataCache)
protected void waitForAllWritesToComplete(DatabaseBackend backend) throws java.sql.SQLException
java.sql.SQLException
- if we fail to acquire the lockexecuteRequestOnBackend(org.objectweb.cjdbc.common.sql.SelectRequest, org.objectweb.cjdbc.controller.backend.DatabaseBackend, org.objectweb.cjdbc.controller.cache.metadata.MetadataCache)
public void enableBackend(DatabaseBackend db, boolean writeEnabled) throws java.sql.SQLException
Ask the corresponding connection manager to initialize the connections if needed.
No sanity checks are performed by this function.
enableBackend
in class AbstractLoadBalancer
db
- The database backend to enablewriteEnabled
- True if the backend must be enabled for writes
java.sql.SQLException
- if an error occurspublic void disableBackend(DatabaseBackend db) throws java.sql.SQLException
Ask the corresponding connection manager to finalize the connections if needed.
No sanity checks are performed by this function.
disableBackend
in class AbstractLoadBalancer
db
- the database backend to disable
java.sql.SQLException
- if an error occurspublic int getNumberOfEnabledBackends()
AbstractLoadBalancer
getNumberOfEnabledBackends
in class AbstractLoadBalancer
AbstractLoadBalancer.getNumberOfEnabledBackends()
public java.lang.String getXmlImpl()
AbstractLoadBalancer
getXmlImpl
in class AbstractLoadBalancer
String
containing information, xml formattedAbstractLoadBalancer.getXmlImpl()
public abstract java.lang.String getRaidb2Xml()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |