|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer
org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1
RAIDb-1 load balancer.
This class is an abstract call because the read requests coming from the request controller are NOT treated here but in the subclasses. Transaction management and write requests are broadcasted to all backends.
Field Summary | |
protected java.util.ArrayList |
backendBlockingThreads
|
protected ReadPrioritaryFIFOWriteLock |
backendBlockingThreadsRWLock
|
protected java.util.ArrayList |
backendNonBlockingThreads
|
protected ReadPrioritaryFIFOWriteLock |
backendNonBlockingThreadsRWLock
|
private int |
execWriteRequestResult
|
private java.sql.ResultSet |
execWriteRequestWithKeysResult
|
protected static Trace |
logger
|
private WaitForCompletionPolicy |
waitForCompletionPolicy
|
Fields inherited from class org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer |
parsingGranularity, raidbLevel, vdb |
Constructor Summary | |
RAIDb1(VirtualDatabase vdb,
WaitForCompletionPolicy waitForCompletionPolicy)
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)
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)
Enables a Backend that was previously disabled. |
abstract java.sql.ResultSet |
execReadRequest(SelectRequest request)
Perform a read request. |
java.sql.ResultSet |
execReadStoredProcedure(StoredProcedure proc)
Call a stored procedure that returns a ResultSet. |
protected java.sql.ResultSet |
executeRequest(SelectRequest request,
DatabaseBackend backend)
Execute a read request on the selected backend. |
int |
execWriteRequest(AbstractWriteRequest request)
Performs a write request. |
private void |
execWriteRequest(AbstractWriteRequest request,
boolean useKeys)
Common code for execWriteRequest(AbstractWriteRequest) and execWriteRequestWithKeys(AbstractWriteRequest). |
java.sql.ResultSet |
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. |
private int |
getNbToWait(int nbOfThreads)
Returns the number of nodes to wait for according to the defined waitForCompletion policy. |
protected abstract java.lang.String |
getRaidb1Xml()
Surrounding raidb1 tags can be treated by |
java.lang.String |
getXmlInformation()
Get information about the Request Load Balancer in xml |
java.lang.String |
getXmlWaitPolicy()
get xml formatted wait policy according to c-jdbc.dtd |
void |
rollback(TransactionMarkerMetaData tm)
Rollbacks a transaction. |
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,
int 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(int 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.loadbalancer.AbstractLoadBalancer |
getInformation, getParsingGranularity, getRAIDbLevel, setParsingGranularity, setRAIDbLevel, setWeight |
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
private WaitForCompletionPolicy waitForCompletionPolicy
protected static Trace logger
private int execWriteRequestResult
private java.sql.ResultSet execWriteRequestWithKeysResult
Constructor Detail |
public RAIDb1(VirtualDatabase vdb, WaitForCompletionPolicy waitForCompletionPolicy) throws java.sql.SQLException
vdb
- the virtual database this load balancer belongs to.waitForCompletionPolicy
- How many backends must complete before
returning the result?
java.sql.SQLException
- if an error occursMethod Detail |
private final int getNbToWait(int nbOfThreads)
waitForCompletion
policy.
nbOfThreads
- total number of threads
public abstract java.sql.ResultSet execReadRequest(SelectRequest request) throws java.sql.SQLException
AbstractLoadBalancer
execReadRequest
in class AbstractLoadBalancer
request
- an SelectRequest
java.sql.ResultSet
java.sql.SQLException
- if an error occursAbstractLoadBalancer.execReadRequest(SelectRequest)
protected java.sql.ResultSet executeRequest(SelectRequest request, DatabaseBackend backend) throws java.sql.SQLException
request
- the request to executebackend
- the backend that will execute the request
java.sql.SQLException
- if an error occurspublic int execWriteRequest(AbstractWriteRequest request) throws java.sql.SQLException
execWriteRequest
in class AbstractLoadBalancer
request
- an AbstractWriteRequest
java.sql.SQLException
- if an error occurspublic java.sql.ResultSet execWriteRequestWithKeys(AbstractWriteRequest request) throws java.sql.SQLException
execWriteRequestWithKeys
in class AbstractLoadBalancer
request
- the request to execute
java.sql.SQLException
- if an error occursprivate void execWriteRequest(AbstractWriteRequest request, boolean useKeys) throws java.sql.SQLException
request
- the request to executeuseKeys
- true if this must give an auto generated keys ResultSet
java.sql.SQLException
- if an error occurspublic java.sql.ResultSet execReadStoredProcedure(StoredProcedure proc) throws java.sql.SQLException
AbstractLoadBalancer
execReadStoredProcedure
in class AbstractLoadBalancer
proc
- the stored procedure call
java.sql.ResultSet
value
java.sql.SQLException
- if an error occursAbstractLoadBalancer.execReadStoredProcedure(org.objectweb.cjdbc.sql.StoredProcedure)
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(org.objectweb.cjdbc.sql.StoredProcedure)
private AbstractTask callStoredProcedure(StoredProcedure proc, boolean isRead) throws java.sql.SQLException
proc
- the stored procedure to callisRead
- true if the call returns a ResultSet
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 occursprotected void waitForAllWritesToComplete(int transactionId) throws java.sql.SQLException
java.sql.SQLException
protected void waitForAllWritesToComplete(DatabaseBackend backend, int transactionId) throws java.sql.SQLException
java.sql.SQLException
executeRequest(SelectRequest, DatabaseBackend)
protected void waitForAllWritesToComplete(DatabaseBackend backend) throws java.sql.SQLException
java.sql.SQLException
executeRequest(SelectRequest, DatabaseBackend)
public void enableBackend(DatabaseBackend db) 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 enable
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 java.lang.String getXmlInformation()
AbstractLoadBalancer
getXmlInformation
in class AbstractLoadBalancer
String
containing information, xml formattedAbstractLoadBalancer.getXmlInformation()
public java.lang.String getXmlWaitPolicy()
protected abstract java.lang.String getRaidb1Xml()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |