|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask
Defines an abstract task to be processed by a
BackendWorkerThread
.
Field Summary | |
private java.util.ArrayList |
exceptions
List of exceptions of failed nodes |
private int |
executionStarted
Number of thread that have started the execution of the task |
private int |
failed
Number of backendThread that have failed |
private java.sql.ResultSet |
generatedKeysResultSet
|
private boolean |
hasTid
|
private int |
nbToComplete
Number of threads that must succeed before returning. |
private int |
success
Number of backendThread that have succeeded |
private boolean |
timeoutExpired
|
private int |
totalNb
Total number of threads. |
Constructor Summary | |
AbstractTask(int nbToComplete,
int totalNb)
Sets the number of threads among the total number of threads that must successfully complete the execution of this AbstractTask before returning. |
Method Summary | |
void |
execute(BackendWorkerThread backendThread)
The task code executed by the backendThread. |
abstract void |
executeTask(BackendWorkerThread backendThread)
The implementation specific task code to be executed by backendThread. |
java.util.ArrayList |
getExceptions()
Returns the exceptions lists. |
int |
getExecutionStarted()
Returns the number of threads that have started the execution of the task. |
int |
getFailed()
Returns the failed. |
java.sql.ResultSet |
getGeneratedKeysResultSet()
Returns the generatedKeysResultSet value. |
int |
getNbToComplete()
Returns the number of threads that must succeed before returning. |
int |
getSuccess()
Returns the success. |
int |
getTotalNb()
Returns the total number of threads. |
boolean |
hasCompleted()
Returns true if the task has been sucessfully completed by nbToComplete nodes (set in the constructor) of if everyone has completed (succesfully or not), false otherwise. |
boolean |
hasFullyCompleted()
Returns true if the task has completed (succesfully or not) or false if we are still expecting answers from some backends. |
boolean |
hasTid()
Returns true if this task has a tid attached to it. |
void |
notifyCompletion()
This is used to notify the completion of this task without success or failure. |
boolean |
notifyFailure(BackendWorkerThread backendThread,
long timeout,
java.lang.Exception e)
Notifies that the specified backendThread failed to execute this task. |
void |
notifySuccess()
Notifies the successful completion of this task. |
boolean |
setExpiredTimeout()
Set the flag to tell that the timeout has expired on this task. |
void |
setGeneratedKeysResultSet(java.sql.ResultSet generatedKeysResultSet)
Sets the generatedKeysResultSet value. |
void |
setHasTid(boolean hasTid)
Sets the hasTid value. |
void |
setTotalNb(int totalNb)
Sets the total number of threads. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private int totalNb
private int nbToComplete
private int executionStarted
private int success
private int failed
private java.util.ArrayList exceptions
private boolean hasTid
private java.sql.ResultSet generatedKeysResultSet
private boolean timeoutExpired
Constructor Detail |
public AbstractTask(int nbToComplete, int totalNb)
nbToComplete
- number of threads that must succeed before returningtotalNb
- total number of threadsMethod Detail |
public void execute(BackendWorkerThread backendThread) throws java.sql.SQLException
backendThread
- The backend thread executing this task
java.sql.SQLException
- if an error occurspublic abstract void executeTask(BackendWorkerThread backendThread) throws java.sql.SQLException
backendThread
- The backend thread executing this task
java.sql.SQLException
- if an error occurspublic void notifySuccess()
public void notifyCompletion()
Therefore, this only decrements by one the number of threads that needs to complete.
public boolean notifyFailure(BackendWorkerThread backendThread, long timeout, java.lang.Exception e) throws java.sql.SQLException
false
meaning that the
problem was due to the task and not to the thread. If the method returns
true
, it can mean that this thread failed and is no more
coherent, therefore the backend associated to this thread should be
disabled.
backendThread
- the backend thread that has failedtimeout
- time in milliseconds to wait for other threads to signal
success or failuree
- the exception causing the failure
true
if at least one node succeeded to execute this
task, false
if all threads failed
java.sql.SQLException
- if an error occured in the notification processpublic java.util.ArrayList getExceptions()
ArrayList
public int getExecutionStarted()
public int getFailed()
int
valuepublic int getNbToComplete()
int
valuepublic int getSuccess()
int
valuepublic int getTotalNb()
int
valuesetTotalNb(int)
public void setTotalNb(int totalNb)
totalNb
- the total number of threads to setgetTotalNb()
public boolean hasCompleted()
AbstractTask(int, int)
public boolean hasFullyCompleted()
public boolean hasTid()
Used internally by BackendWorkerThread.
public void setHasTid(boolean hasTid)
Used internally by BackendWorkerThread.
hasTid
- The hasTid to set.public java.sql.ResultSet getGeneratedKeysResultSet()
public void setGeneratedKeysResultSet(java.sql.ResultSet generatedKeysResultSet)
generatedKeysResultSet
- The generatedKeysResultSet to set.public boolean setExpiredTimeout()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |