|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.cjdbc.controller.scheduler.AbstractScheduler
The Request Scheduler should schedule the request according to a given policy.
The requests comes from the Request Controller and are sent later to the next ccontroller omponents (cache and load balancer).
Field Summary | |
private java.lang.Object |
endOfCurrentTransactions
|
private java.lang.Object |
endOfCurrentWrites
|
protected static Trace |
logger
|
protected boolean |
needSQLMacroHandling
|
protected int |
parsingGranularity
|
private int |
pendingTransactions
|
private int |
pendingWrites
|
protected int |
raidbLevel
|
private boolean |
suspendedTransactions
|
private boolean |
suspendedWrites
|
private int |
tid
|
private java.lang.Object |
transactionSync
|
private java.lang.Object |
writesSync
|
Constructor Summary | |
AbstractScheduler(int raidbLevel,
int parsingGranularity,
boolean needSQLMacroHandling)
Default scheduler to assign scheduler RAIDb level, needed granularity and SQL macro handling (on the fly instanciation of NOW(), RAND(), ...). |
Method Summary | |
int |
begin(TransactionMarkerMetaData tm)
Begin a new transaction and return the corresponding transaction identifier. |
void |
beginCompleted(int transactionId)
Notify the completion of a begin command. |
void |
commit(TransactionMarkerMetaData tm)
Commit a transaction. |
void |
commitCompleted(int transactionId)
Notify the completion of a commit command. |
protected abstract void |
commitTransaction(int transactionId)
Commit a transaction given its id. |
abstract java.lang.String |
getInformation()
Get information about the Request Scheduler |
int |
getParsingGranularity()
Get the needed query parsing granularity. |
int |
getPendingWrites()
Returns the number of pending writes. |
int |
getRAIDbLevel()
Returns the RAIDbLevel. |
abstract java.lang.String |
getXmlInformation()
Get information about the Request Scheduler in xml format |
protected void |
handleSQLMacros(AbstractRequest request)
Replace all SQL macros with an instanciated value: - NOW() is replaced with a current timestamp |
protected boolean |
hasSQLMacros(AbstractRequest request)
Returns true if the query contains SQL macros. |
void |
mergeDatabaseSchema(DatabaseSchema dbs)
Merge the given DatabaseSchema with the current one. |
abstract void |
notifyWriteCompleted(AbstractWriteRequest request)
Notify the completion of a write statement. |
abstract void |
readCompleted(SelectRequest request)
Notify the completion of a read statement. |
void |
resumeNewTransactions()
Resume new transactions that were suspended by suspendNewTransactionsForCheckpoint(). |
void |
resumeWrites()
Resume the execution of write queries that were suspended by suspendWrites(). |
void |
rollback(TransactionMarkerMetaData tm)
Rollback a transaction. |
void |
rollbackCompleted(int transactionId)
Notify the completion of a rollback command. |
protected abstract void |
rollbackTransaction(int transactionId)
Rollback a transaction given its id. |
abstract void |
scheduleNonSuspendedWriteRequest(AbstractWriteRequest request)
Schedule a write request (implementation specific). |
abstract void |
scheduleReadRequest(SelectRequest request)
Schedule a read request (implementation specific). |
void |
scheduleReadRequest(SelectRequest request,
boolean queryCacheEnabled)
Schedules a read request. |
void |
scheduleWriteRequest(AbstractWriteRequest request)
Schedule a write request. |
void |
setDatabaseSchema(DatabaseSchema dbs)
Sets the DatabaseSchema of the current virtual database.
|
void |
setParsingGranularity(int parsingGranularity)
Set the needed query parsing granularity. |
void |
setRAIDbLevel(int raidbLevel)
Sets the RAIDb level. |
void |
suspendNewTransactionsForCheckpoint()
Suspend all calls to begin() until all current transactions are finished in order to store a checkpoint. |
void |
suspendWrites()
Suspend all write queries. |
void |
writeCompleted(AbstractWriteRequest request)
Notify the completion of a write statement. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int raidbLevel
protected int parsingGranularity
protected boolean needSQLMacroHandling
private int tid
private boolean suspendedTransactions
private int pendingTransactions
private java.lang.Object transactionSync
private java.lang.Object endOfCurrentTransactions
private boolean suspendedWrites
private int pendingWrites
private java.lang.Object writesSync
private java.lang.Object endOfCurrentWrites
protected static Trace logger
Constructor Detail |
public AbstractScheduler(int raidbLevel, int parsingGranularity, boolean needSQLMacroHandling)
raidbLevel
- RAIDb level of this schedulerparsingGranularity
- Parsing granularity needed by the schedulerneedSQLMacroHandling
- True if SQL macro processing is needed.Method Detail |
public final int getParsingGranularity()
public final void setParsingGranularity(int parsingGranularity)
parsingGranularity
- Parsing granularity needed by the schedulerpublic final int getPendingWrites()
public final int getRAIDbLevel()
public final void setRAIDbLevel(int raidbLevel)
raidbLevel
- The RAIDbLevel to setpublic void setDatabaseSchema(DatabaseSchema dbs)
DatabaseSchema
of the current virtual database.
This is only needed by some schedulers that will have to define their
own scheduler schema
dbs
- a DatabaseSchema
valueSchedulerDatabaseSchema
public void mergeDatabaseSchema(DatabaseSchema dbs)
DatabaseSchema
with the current one.
dbs
- a DatabaseSchema
valueSchedulerDatabaseSchema
public void scheduleReadRequest(SelectRequest request, boolean queryCacheEnabled) throws java.sql.SQLException
needSQLMacroHandling
set to true
then the
implementation specific handleSQLMacros(AbstractRequest)
function is called.
request
- Select request to schedulequeryCacheEnabled
- true
if a query cache is active
java.sql.SQLException
- if a timeout occurshandleSQLMacros(AbstractRequest)
public abstract void scheduleReadRequest(SelectRequest request) throws java.sql.SQLException
request
- Select request to schedule (SQL macros are already handled if needed)
java.sql.SQLException
- if a timeout occurspublic abstract void readCompleted(SelectRequest request)
request
- the completed requestpublic final void scheduleWriteRequest(AbstractWriteRequest request) throws java.sql.SQLException, RollbackException
request
- Write request to schedule
java.sql.SQLException
- if a timeout occurs
RollbackException
- if an error occursscheduleNonSuspendedWriteRequest(AbstractWriteRequest)
public abstract void scheduleNonSuspendedWriteRequest(AbstractWriteRequest request) throws java.sql.SQLException, RollbackException
request
- Write request to schedule (SQL macros are already handled if needed)
java.sql.SQLException
- if a timeout occurs
RollbackException
- if the transaction must be rollbackedpublic final void writeCompleted(AbstractWriteRequest request)
This method updates the number of pending writes and calls the implementation specific notifyWriteCompleted function.
Finally, the suspendWrites() function is notified if needed.
request
- the completed requestnotifyWriteCompleted(AbstractWriteRequest)
,
suspendWrites()
public abstract void notifyWriteCompleted(AbstractWriteRequest request)
request
- the completed requestwriteCompleted(AbstractWriteRequest)
protected boolean hasSQLMacros(AbstractRequest request)
request
- the request to check
protected void handleSQLMacros(AbstractRequest request)
request
- the request to handle macrospublic final int begin(TransactionMarkerMetaData tm) throws java.sql.SQLException
tm
- The transaction marker metadata
java.sql.SQLException
- if an error occurspublic final void beginCompleted(int transactionId)
transactionId
- of the completed beginpublic final void commit(TransactionMarkerMetaData tm) throws java.sql.SQLException
Calls the implementation specific commitTransaction()
tm
- The transaction marker metadata
java.sql.SQLException
- if an error occurscommitTransaction(int)
protected abstract void commitTransaction(int transactionId)
transactionId
- the transaction id
RemoteException
- if an error occurspublic final void commitCompleted(int transactionId)
transactionId
- of the completed commitpublic final void rollback(TransactionMarkerMetaData tm) throws java.sql.SQLException
Calls the implementation specific rollbackTransaction()
tm
- The transaction marker metadata
java.sql.SQLException
- if an error occursrollbackTransaction(int)
protected abstract void rollbackTransaction(int transactionId)
transactionId
- the transaction id
RemoteException
- if an error occurspublic final void rollbackCompleted(int transactionId)
transactionId
- of the rollback commitpublic final void suspendNewTransactionsForCheckpoint() throws java.sql.SQLException
New transactions remain suspended until resumeNewTransactions() is called.
java.sql.SQLException
resumeNewTransactions()
public final void resumeNewTransactions()
suspendNewTransactionsForCheckpoint()
public void suspendWrites() throws java.sql.SQLException
Writes execution is resumed by calling resumeWrites()
java.sql.SQLException
resumeWrites()
public void resumeWrites()
suspendWrites()
public abstract java.lang.String getInformation()
String
containing informationpublic abstract java.lang.String getXmlInformation()
String
containing information in xml
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |