|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread org.objectweb.cjdbc.controller.loadbalancer.BackendWorkerThread
Process sequentially a set of tasks and send them to a backend.
Field Summary | |
private DatabaseBackend |
backend
|
private AbstractTask |
currentlyProcessingTask
|
private java.lang.Long |
currentTaskTid
|
private boolean |
isKilled
|
private AbstractLoadBalancer |
loadBalancer
|
private Trace |
logger
|
private java.util.ArrayList |
taskList
|
private java.util.ArrayList |
tidList
|
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
BackendWorkerThread(DatabaseBackend backend,
AbstractLoadBalancer loadBalancer)
Creates a new BackendWorkerThread . |
|
BackendWorkerThread(java.lang.String name,
DatabaseBackend backend,
AbstractLoadBalancer loadBalancer)
Creates a new BackendWorkerThread . |
Method Summary | |
void |
addPriorityTask(AbstractTask task)
Adds a task upfront to the task list so that this task will be the next executed task. |
void |
addPriorityTask(AbstractTask task,
long transactionId)
Adds a task upfront to the task list so that this task will be the next executed task. |
void |
addTask(AbstractTask task)
Adds a task at the end of the task list. |
void |
addTask(AbstractTask task,
long transactionId)
Adds a task at the end of the task list. |
DatabaseBackend |
getBackend()
Returns the backend. |
Trace |
getLogger()
Returns the logger for tracing. |
boolean |
hasTaskForTransaction(java.lang.Long tid)
Returns true if the thread has pending tasks for the given transaction. |
void |
insertTaskAfterLastWriteForTransaction(AbstractTask task,
java.lang.Long transactionId)
Adds a task just after the last write task for the given transaction in the task list. |
void |
kill()
Kills this thread after the next task processing and forces the load balancer to disable the backend. |
private void |
kill(boolean forceDisable)
Kills this thread after the next task processing. |
void |
killWithoutDisablingBackend()
Kills this thread after the next task processing. |
void |
run()
Process the tasklist and call wait() (on itself) when the
tasklist becomes empty. |
void |
waitForAllTasksToComplete()
Waits for all current tasks to complete. |
void |
waitForAllTasksToComplete(long transactionId)
Waits for all tasks of the specified transaction to complete. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private AbstractLoadBalancer loadBalancer
private DatabaseBackend backend
private java.util.ArrayList taskList
private java.util.ArrayList tidList
private boolean isKilled
private AbstractTask currentlyProcessingTask
private java.lang.Long currentTaskTid
private Trace logger
Constructor Detail |
public BackendWorkerThread(DatabaseBackend backend, AbstractLoadBalancer loadBalancer) throws java.sql.SQLException
BackendWorkerThread
.
backend
- the backend this thread is associated to.loadBalancer
- the load balancer instanciating this thread
java.sql.SQLException
- if an error occurspublic BackendWorkerThread(java.lang.String name, DatabaseBackend backend, AbstractLoadBalancer loadBalancer) throws java.sql.SQLException
BackendWorkerThread
.
name
- the name to give to the threadbackend
- the backend this thread is associated to.loadBalancer
- the load balancer instanciating this thread
java.sql.SQLException
- if an error occursMethod Detail |
public void addTask(AbstractTask task)
task
- the task to addpublic void addTask(AbstractTask task, long transactionId)
task
- the task to addtransactionId
- transaction id in which this task executepublic void insertTaskAfterLastWriteForTransaction(AbstractTask task, java.lang.Long transactionId)
This method is usually used to insert a commit/rollback task when asynchrony is allowed between backends.
task
- the task to addtransactionId
- transaction id in which this task executepublic void addPriorityTask(AbstractTask task)
task
- the task to addpublic void addPriorityTask(AbstractTask task, long transactionId)
task
- the task to addtransactionId
- transaction id in which this task executepublic boolean hasTaskForTransaction(java.lang.Long tid)
tid
- the transaction identifier
public void waitForAllTasksToComplete(long transactionId)
transactionId
- the transaction identifierpublic void waitForAllTasksToComplete()
public void kill()
public void killWithoutDisablingBackend()
private void kill(boolean forceDisable)
forceDisable
- true if the task must call the load balancer to disable
the backendpublic void run()
wait()
(on itself) when the
tasklist becomes empty.
public DatabaseBackend getBackend()
DatabaseBackend
instancepublic Trace getLogger()
Trace
instance
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |