Public Member Functions | |
AbstractTask (int nbToComplete, int totalNb) | |
void | execute (BackendWorkerThread backendThread) throws SQLException |
abstract void | executeTask (BackendWorkerThread backendThread) throws SQLException |
synchronized void | notifySuccess () |
synchronized void | notifyCompletion () |
synchronized boolean | notifyFailure (BackendWorkerThread backendThread, long timeout, Exception e) throws SQLException |
ArrayList | getExceptions () |
synchronized int | getExecutionStarted () |
int | getFailed () |
int | getNbToComplete () |
int | getSuccess () |
int | getTotalNb () |
void | setTotalNb (int totalNb) |
boolean | hasTid () |
void | setHasTid (boolean hasTid) |
ResultSet | getGeneratedKeysResultSet () |
void | setGeneratedKeysResultSet (ResultSet generatedKeysResultSet) |
synchronized boolean | setExpiredTimeout () |
BackendWorkerThread
.
Definition at line 42 of file AbstractTask.java.
|
Sets the number of threads among the total number of threads that must successfully complete the execution of this AbstractTask before returning.
Definition at line 87 of file AbstractTask.java. 00088 { 00089 this.nbToComplete = nbToComplete; 00090 this.totalNb = totalNb; 00091 success = 0; 00092 failed = 0; 00093 executionStarted = 0; 00094 }
|
|
The task code executed by the backendThread.
Definition at line 106 of file AbstractTask.java. 00107 { 00108 synchronized (this) 00109 { 00110 // If the task has expired and nobody has executed it yet, we ignore it 00111 // else we have to play it. 00112 // Note that the exception corresponding to the timeout is set by the 00113 // caller of setExpiredTimeout. 00114 if (timeoutExpired && (executionStarted == 0)) 00115 return; 00116 this.executionStarted++; 00117 } 00118 executeTask(backendThread); 00119 // Completed executions are handled by the task internal code that calls 00120 // notifyFailure or notifySuccess. 00121 }
|
|
The implementation specific task code to be executed by backendThread.
Implemented in org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTask, org.objectweb.cjdbc.controller.loadbalancer.tasks.CommitTask, org.objectweb.cjdbc.controller.loadbalancer.tasks.KillThreadTask, org.objectweb.cjdbc.controller.loadbalancer.tasks.ReadStoredProcedureTask, org.objectweb.cjdbc.controller.loadbalancer.tasks.RollbackTask, org.objectweb.cjdbc.controller.loadbalancer.tasks.SelectRequestTask, org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteRequestTask, org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteRequestWithKeysTask, and org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteStoredProcedureTask. |
|
Returns the exceptions lists.
Definition at line 234 of file AbstractTask.java. 00235 {
00236 return exceptions;
00237 }
|
|
Returns the number of threads that have started the execution of the task.
Definition at line 244 of file AbstractTask.java. 00245 {
00246 return executionStarted;
00247 }
|
|
Returns the failed.
Definition at line 254 of file AbstractTask.java. Referenced by org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2.commit(), org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1.commit(), org.objectweb.cjdbc.controller.loadbalancer.raidb0.RAIDb0.commit(), org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2.rollback(), org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1.rollback(), and org.objectweb.cjdbc.controller.loadbalancer.raidb0.RAIDb0.rollback(). 00255 {
00256 return failed;
00257 }
|
|
Returns the generatedKeysResultSet value.
Definition at line 330 of file AbstractTask.java. 00331 {
00332 return generatedKeysResultSet;
00333 }
|
|
Returns the number of threads that must succeed before returning.
Definition at line 264 of file AbstractTask.java. 00265 {
00266 return nbToComplete;
00267 }
|
|
|
Returns the total number of threads.
Definition at line 285 of file AbstractTask.java. 00286 {
00287 return totalNb;
00288 }
|
|
Returns true if this task has a tid attached to it. Used internally by BackendWorkerThread.
Definition at line 308 of file AbstractTask.java. 00309 {
00310 return hasTid;
00311 }
|
|
This is used to notify the completion of this task without success or failure. This is usually used when the task has been discarded for example by a backend that is currently disabling but still needs to execute the remaining queries in open transactions. Therefore, this only decrements by one the number of threads that needs to complete. Definition at line 159 of file AbstractTask.java. Referenced by org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteStoredProcedureTask.executeTask(), org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteRequestWithKeysTask.executeTask(), org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteRequestTask.executeTask(), and org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTask.executeTask(). 00160 { 00161 totalNb--; 00162 // Notify if needed 00163 if (success + failed == totalNb) 00164 { 00165 notifyAll(); // Notify all failed threads 00166 } 00167 }
|
|
Notifies that the specified backendThread failed to execute this task. If all nodes failed, this method return
Definition at line 185 of file AbstractTask.java. Referenced by org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteStoredProcedureTask.executeTask(), org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteRequestWithKeysTask.executeTask(), org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteRequestTask.executeTask(), org.objectweb.cjdbc.controller.loadbalancer.tasks.SelectRequestTask.executeTask(), org.objectweb.cjdbc.controller.loadbalancer.tasks.RollbackTask.executeTask(), org.objectweb.cjdbc.controller.loadbalancer.tasks.ReadStoredProcedureTask.executeTask(), org.objectweb.cjdbc.controller.loadbalancer.tasks.CommitTask.executeTask(), and org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTask.executeTask(). 00187 { 00188 failed++; 00189 00190 // Log the exception 00191 if (exceptions == null) 00192 exceptions = new ArrayList(); 00193 if (e instanceof SQLException) 00194 { 00195 SQLException sqlEx = (SQLException) e; 00196 exceptions 00197 .add(SQLExceptionFactory.getSQLException(sqlEx,"BackendThread " 00198 + backendThread.getBackend().getName() + " failed (" 00199 + sqlEx.getMessage() + ")")); 00200 } 00201 else 00202 exceptions.add(new SQLException("BackendThread " 00203 + backendThread.getBackend().getName() + " failed (" + e + ")")); 00204 00205 // Notify if needed 00206 if (success + failed == totalNb) 00207 { 00208 notifyAll(); // Notify all failed threads 00209 } 00210 else 00211 { 00212 try 00213 { // Wait to check if all other threads failed or not 00214 wait(timeout); 00215 } 00216 catch (InterruptedException ie) 00217 { 00218 throw new SQLException("Wait interrupted() in failed task of backend " 00219 + backendThread.getBackend().getName() + " (" + e + ")"); 00220 } 00221 } 00222 return success > 0; 00223 }
|
|
|
Set the flag to tell that the timeout has expired on this task. If no backend has started the task execution then the task will be canceled and the method will return true. Otherwise, all backends will execute the request and the method will return false.
Definition at line 354 of file AbstractTask.java. Referenced by org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2.commit(), org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1.commit(), org.objectweb.cjdbc.controller.loadbalancer.raidb0.RAIDb0.commit(), org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2.rollback(), org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1.rollback(), and org.objectweb.cjdbc.controller.loadbalancer.raidb0.RAIDb0.rollback(). 00355 { 00356 this.timeoutExpired = true; 00357 return executionStarted == 0; 00358 }
|
|
Sets the generatedKeysResultSet value.
Definition at line 340 of file AbstractTask.java. 00341 {
00342 this.generatedKeysResultSet = generatedKeysResultSet;
00343 }
|
|
Sets the hasTid value. Used internally by BackendWorkerThread.
Definition at line 320 of file AbstractTask.java. 00321 {
00322 this.hasTid = hasTid;
00323 }
|
|
Sets the total number of threads.
Definition at line 296 of file AbstractTask.java. 00297 {
00298 this.totalNb = totalNb;
00299 }
|