クラス org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTask

org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTaskに対する継承グラフ

Inheritance graph
[凡例]
org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTaskのコラボレーション図

Collaboration graph
[凡例]
すべてのメンバ一覧

説明

Task to begin a transaction.

作者:
Emmanuel Cecchet

Julie Marguerite

バージョン:
1.0

BeginTask.java39 行で定義されています。

Public メソッド

 BeginTask (int nbToComplete, int totalNb, long timeout, String login, int transactionId)
void execute (BackendWorkerThread backendThread) throws SQLException
String toString ()
boolean hasTid ()
synchronized void notifySuccess ()
synchronized boolean notifyFailure (BackendWorkerThread backendThread, long timeout, SQLException e) throws SQLException
ArrayList getExceptions ()
int getFailed ()
int getNbToComplete ()
int getSuccess ()
int getTotalNb ()
void setTotalNb (int totalNb)
void setHasTid (boolean hasTid)

Private 変数

String login
int transactionId
long timeout


コンストラクタとデストラクタ

org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTask.BeginTask int  nbToComplete,
int  totalNb,
long  timeout,
String  login,
int  transactionId
 

Begins a new transaction given a login and a transaction id.

引数:
nbToComplete number of threads that must succeed before returning
totalNb total number of threads
timeout request timeout in milliseconds
login the login used by the connection
transactionId a unique transaction identifier

BeginTask.java59 行で定義されています。

00061   {
00062     super(nbToComplete, totalNb);
00063     this.login = login;
00064     this.transactionId = transactionId;
00065     this.timeout = timeout;
00066   }


メソッド

void org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTask.execute BackendWorkerThread  backendThread  )  throws SQLException [virtual]
 

Begins a new transaction with the given backend thread.

引数:
backendThread the backend thread that will execute the task
例外:
SQLException if an error occurs

org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTaskに実装されています.

BeginTask.java74 行で定義されています。

参照先 org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.notifyFailure(), と org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.notifySuccess().

00075   {
00076     try
00077     {
00078       Connection c = backendThread.getBackend().getConnectionManager(login)
00079           .getConnection(transactionId);
00080 
00081       // Sanity check
00082       if (c == null)
00083       { // Bad connection
00084         SQLException se = new SQLException(
00085             "No more connection to start a new transaction.");
00086         try
00087         { // All backends failed, just ignore
00088           if (!notifyFailure(backendThread, timeout, se))
00089             return;
00090         }
00091         catch (SQLException ignore)
00092         {
00093         }
00094       }
00095 
00096       c.setAutoCommit(false);
00097       notifySuccess();
00098       backendThread.getBackend().startTransaction(new Long(transactionId));
00099     }
00100     catch (Exception e)
00101     {
00102       try
00103       {
00104         if (!notifyFailure(backendThread, timeout, new SQLException(e
00105             .getMessage())))
00106           return;
00107       }
00108       catch (SQLException ignore)
00109       {
00110       }
00111       String msg = "Failed to begin transaction " + transactionId
00112           + " on backend " + backendThread.getBackend().getName() + " (" + e
00113           + ")";
00114       backendThread.getLogger().error(msg);
00115       throw new SQLException(msg);
00116     }
00117   }

ArrayList org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.getExceptions  )  [inherited]
 

Returns the exceptions lists.

戻り値:
an ArrayList

AbstractTask.java167 行で定義されています。

参照先 org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.exceptions.

00168   {
00169     return exceptions;
00170   }

int org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.getFailed  )  [inherited]
 

Returns the failed.

戻り値:
an int value

AbstractTask.java177 行で定義されています。

参照先 org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.failed.

参照元 org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2.callStoredProcedure(), org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1.callStoredProcedure(), 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.raidb1.RAIDb1.execWriteRequest(), org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2.rollback(), org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1.rollback(), と org.objectweb.cjdbc.controller.loadbalancer.raidb0.RAIDb0.rollback().

00178   {
00179     return failed;
00180   }

int org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.getNbToComplete  )  [inherited]
 

Returns the number of threads that must succeed before returning.

戻り値:
an int value

AbstractTask.java187 行で定義されています。

参照先 org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.nbToComplete.

00188   {
00189     return nbToComplete;
00190   }

int org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.getSuccess  )  [inherited]
 

Returns the success.

戻り値:
an int value

AbstractTask.java197 行で定義されています。

参照先 org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.success.

参照元 org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2.callStoredProcedure(), org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1.callStoredProcedure(), 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.tasks.WriteStoredProcedureTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteRequestWithKeysTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteRequestTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.RollbackTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.ReadStoredProcedureTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.CommitTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1.execWriteRequest(), org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2.rollback(), org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1.rollback(), と org.objectweb.cjdbc.controller.loadbalancer.raidb0.RAIDb0.rollback().

00198   {
00199     return success;
00200   }

int org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.getTotalNb  )  [inherited]
 

Returns the total number of threads.

戻り値:
an int value
参照:
setTotalNb

AbstractTask.java208 行で定義されています。

参照先 org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.totalNb.

00209   {
00210     return totalNb;
00211   }

boolean org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.hasTid  )  [inherited]
 

Returns true if this task has a tid attached to it.

Used internally by BackendWorkerThread.

戻り値:
Returns the hasTid.

AbstractTask.java231 行で定義されています。

00232   {
00233     return hasTid;
00234   }

synchronized boolean org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.notifyFailure BackendWorkerThread  backendThread,
long  timeout,
SQLException  e
throws SQLException [inherited]
 

Notifies that the specified backendThread failed to execute this task. If all nodes failed, this method return 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 failed
timeout time in milliseconds to wait for other threads to signal success or failure
e the exception causing the failure
戻り値:
true if at least one node succeeded to execute this task, false if all threads failed
例外:
SQLException if an error occured in the notification process

AbstractTask.java127 行で定義されています。

参照先 org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.exceptions, org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.failed, org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.success, と org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.totalNb.

参照元 org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteStoredProcedureTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteRequestWithKeysTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteRequestTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.SelectRequestTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.RollbackTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.ReadStoredProcedureTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.CommitTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTask.execute(), と org.objectweb.cjdbc.controller.loadbalancer.BackendWorkerThread.kill().

00129   {
00130     failed++;
00131 
00132     // Log the exception
00133     if (exceptions == null)
00134       exceptions = new ArrayList();
00135     exceptions.add(new SQLException("BackendThread "
00136         + backendThread.getBackend().getName() + " failed (" + e + ")"));
00137 
00138     // Notify if needed
00139     if (success + failed == totalNb)
00140     {
00141       notifyAll(); // Notify all failed threads
00142     }
00143     else
00144     {
00145       try
00146       { // Wait to check if all other threads failed or not
00147         wait(timeout);
00148       }
00149       catch (InterruptedException ie)
00150       {
00151         throw new SQLException("Wait interrupted() in failed task of backend "
00152             + backendThread.getBackend().getName() + " (" + e + ")");
00153       }
00154     }
00155     return success > 0;
00156   }

synchronized void org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.notifySuccess  )  [inherited]
 

Notifies the successful completion of this task.

AbstractTask.java96 行で定義されています。

参照先 org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.failed, org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.nbToComplete, org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.success, と org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.totalNb.

参照元 org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteStoredProcedureTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteRequestWithKeysTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.WriteRequestTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.SelectRequestTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.RollbackTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.ReadStoredProcedureTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.KillThreadTask.execute(), org.objectweb.cjdbc.controller.loadbalancer.tasks.CommitTask.execute(), と org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTask.execute().

00098   {
00099     success++;
00100 
00101     // Notify if needed
00102     if ((success == nbToComplete) || (success + failed == totalNb))
00103     {
00104       if (failed > 0)
00105         notifyAll(); // Notify all failed threads too
00106       else
00107         notify();
00108     }
00109   }

void org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.setHasTid boolean  hasTid  )  [inherited]
 

Sets the hasTid value.

Used internally by BackendWorkerThread.

引数:
hasTid The hasTid to set.

AbstractTask.java243 行で定義されています。

参照元 org.objectweb.cjdbc.controller.loadbalancer.BackendWorkerThread.addPriorityTask(), と org.objectweb.cjdbc.controller.loadbalancer.BackendWorkerThread.addTask().

00244   {
00245     this.hasTid = hasTid;
00246   }

void org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.setTotalNb int  totalNb  )  [inherited]
 

Sets the total number of threads.

引数:
totalNb the total number of threads to set
参照:
getTotalNb

AbstractTask.java219 行で定義されています。

参照元 org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2.callStoredProcedure().

00220   {
00221     this.totalNb = totalNb;
00222   }

String org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTask.toString  ) 
 

参照:
java.lang.Object#toString()

BeginTask.java122 行で定義されています。

00123   {
00124     return "BeginTask (" + transactionId + ")";
00125   }


変数

String org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTask.login [private]
 

Login used by the connection.

BeginTask.java42 行で定義されています。

long org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTask.timeout [private]
 

Request timeout in milliseconds.

BeginTask.java48 行で定義されています。

int org.objectweb.cjdbc.controller.loadbalancer.tasks.BeginTask.transactionId [private]
 

Unique transaction identifier.

BeginTask.java45 行で定義されています。


このクラスの説明は次のファイルから生成されました:
CJDBCversion1.0rc6に対してWed May 5 18:02:45 2004に生成されました。 doxygen 1.3.6