StoredProcedure
call.
WriteStoredProcedureTask.java の 43 行で定義されています。
Public メソッド | |
WriteStoredProcedureTask (int nbToComplete, int totalNb, StoredProcedure proc) | |
void | execute (BackendWorkerThread backendThread) throws SQLException |
int | getResult () |
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 変数 | |
StoredProcedure | proc |
int | result |
|
Creates a new
WriteStoredProcedureTask.java の 55 行で定義されています。
00057 {
00058 super(nbToComplete, totalNb);
00059 this.proc = proc;
00060 }
|
|
Executes a write request with the given backend thread.
org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTaskに実装されています. WriteStoredProcedureTask.java の 68 行で定義されています。 参照先 org.objectweb.cjdbc.controller.backend.DatabaseBackend.disable(), org.objectweb.cjdbc.controller.connection.AbstractConnectionManager.getConnection(), org.objectweb.cjdbc.controller.backend.DatabaseBackend.getConnectionManager(), org.objectweb.cjdbc.common.sql.AbstractRequest.getLogin(), org.objectweb.cjdbc.controller.backend.DatabaseBackend.getName(), org.objectweb.cjdbc.common.sql.AbstractRequest.getSQL(), org.objectweb.cjdbc.common.sql.AbstractRequest.getSQLShortForm(), org.objectweb.cjdbc.controller.backend.DatabaseBackend.getSQLShortFormLength(), org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.getSuccess(), org.objectweb.cjdbc.common.sql.AbstractRequest.getTimeout(), org.objectweb.cjdbc.common.sql.AbstractRequest.getTransactionId(), org.objectweb.cjdbc.common.sql.AbstractRequest.isAutoCommit, org.objectweb.cjdbc.controller.backend.DatabaseBackend.isStartedTransaction(), org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.notifyFailure(), org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.notifySuccess(), org.objectweb.cjdbc.controller.connection.AbstractConnectionManager.releaseConnection(), org.objectweb.cjdbc.controller.connection.AbstractConnectionManager.retrieveConnection(), と org.objectweb.cjdbc.controller.backend.DatabaseBackend.startTransaction().
00069 { 00070 DatabaseBackend backend = backendThread.getBackend(); 00071 00072 AbstractConnectionManager cm = backend 00073 .getConnectionManager(proc.getLogin()); 00074 00075 if (proc.isAutoCommit()) 00076 { // Use a connection just for this request 00077 Connection c = null; 00078 try 00079 { 00080 c = cm.getConnection(); 00081 } 00082 catch (UnreachableBackendException e1) 00083 { 00084 backendThread.getLogger().error( 00085 "Disabling backend " + backend.getName() 00086 + " because it is no more reachable."); 00087 backend.disable(); 00088 throw new SQLException("Backend " + backend.getName() 00089 + " is no more reachable."); 00090 } 00091 00092 // Sanity check 00093 if (c == null) 00094 { 00095 SQLException se = new SQLException("No more connections"); 00096 try 00097 { // All backends failed, just ignore 00098 if (!notifyFailure(backendThread, (long) proc.getTimeout() * 1000, se)) 00099 return; 00100 } 00101 catch (SQLException ignore) 00102 { 00103 } 00104 // Disable this backend (it is no more in sync) by killing the backend 00105 // thread 00106 backendThread.kill(); 00107 String msg = "Stored procedure '" 00108 + proc.getSQLShortForm(backend.getSQLShortFormLength()) 00109 + "' failed on backend " + backend.getName() + " but " 00110 + getSuccess() + " succeeded (" + se + ")"; 00111 backendThread.getLogger().error(msg); 00112 throw new SQLException(msg); 00113 } 00114 00115 // Execute Query 00116 try 00117 { 00118 CallableStatement cs = c.prepareCall(proc.getSQL()); 00119 if (backendThread.getBackend().getDriverCompliance() 00120 .supportSetQueryTimeout()) 00121 cs.setQueryTimeout(proc.getTimeout()); 00122 result = cs.executeUpdate(); 00123 00124 // Warning! No way to detect if schema has been modified unless 00125 // we ask the backend again using DatabaseMetaData.getTables(). 00126 00127 } 00128 catch (SQLException e) 00129 { 00130 try 00131 { // All backends failed, just ignore 00132 if (!notifyFailure(backendThread, (long) proc.getTimeout() * 1000, e)) 00133 return; 00134 } 00135 catch (SQLException ignore) 00136 { 00137 } 00138 // Disable this backend (it is no more in sync) by killing the backend 00139 // thread 00140 backendThread.kill(); 00141 String msg = "Stored procedure '" 00142 + proc.getSQLShortForm(backend.getSQLShortFormLength()) 00143 + "' failed on backend " + backend.getName() + " but " 00144 + getSuccess() + " succeeded (" + e + ")"; 00145 backendThread.getLogger().error(msg); 00146 throw new SQLException(msg); 00147 } 00148 finally 00149 { 00150 cm.releaseConnection(c); 00151 } 00152 } 00153 else 00154 { // Re-use the connection used by this transaction 00155 Connection c; 00156 long tid = proc.getTransactionId(); 00157 Long lTid = new Long(tid); 00158 00159 if (!backend.isStartedTransaction(lTid)) 00160 { // Transaction has not been started yet, this is a lazy begin 00161 try 00162 { 00163 c = cm.getConnection(); 00164 } 00165 catch (UnreachableBackendException e1) 00166 { 00167 backendThread.getLogger().error( 00168 "Disabling backend " + backend.getName() 00169 + " because it is no more reachable."); 00170 backend.disable(); 00171 throw new SQLException("Backend " + backend.getName() 00172 + " is no more reachable."); 00173 } 00174 00175 // Sanity check 00176 if (c == null) 00177 { // Bad connection 00178 SQLException se = new SQLException( 00179 "Unable to get connection for transaction " + tid); 00180 try 00181 { // All backends failed, just ignore 00182 if (!notifyFailure(backendThread, (long) proc.getTimeout() * 1000, 00183 se)) 00184 return; 00185 } 00186 catch (SQLException ignore) 00187 { 00188 } 00189 // Disable this backend (it is no more in sync) by killing the 00190 // backend thread 00191 backendThread.kill(); 00192 String msg = "Stored procedure '" 00193 + proc.getSQLShortForm(backend.getSQLShortFormLength()) 00194 + "' failed on backend " + backend.getName() + " but " 00195 + getSuccess() + " succeeded (" + se + ")"; 00196 backendThread.getLogger().error(msg); 00197 throw new SQLException(msg); 00198 } 00199 00200 // begin transaction 00201 backend.startTransaction(lTid); 00202 c.setAutoCommit(false); 00203 } 00204 else 00205 { // Transaction has already been started, retrieve connection 00206 c = cm.retrieveConnection(tid); 00207 00208 // Sanity check 00209 if (c == null) 00210 { // Bad connection 00211 SQLException se = new SQLException( 00212 "Unable to retrieve connection for transaction " + tid); 00213 try 00214 { // All backends failed, just ignore 00215 if (!notifyFailure(backendThread, (long) proc.getTimeout() * 1000, 00216 se)) 00217 return; 00218 } 00219 catch (SQLException ignore) 00220 { 00221 } 00222 // Disable this backend (it is no more in sync) by killing the 00223 // backend thread 00224 backendThread.kill(); 00225 String msg = "Stored procedure '" 00226 + proc.getSQLShortForm(backend.getSQLShortFormLength()) 00227 + "' failed on backend " + backend.getName() + " but " 00228 + getSuccess() + " succeeded (" + se + ")"; 00229 backendThread.getLogger().error(msg); 00230 throw new SQLException(msg); 00231 } 00232 } 00233 00234 // Execute Query 00235 try 00236 { 00237 CallableStatement cs = c.prepareCall(proc.getSQL()); 00238 if (backendThread.getBackend().getDriverCompliance() 00239 .supportSetQueryTimeout()) 00240 cs.setQueryTimeout(proc.getTimeout()); 00241 result = cs.executeUpdate(); 00242 00243 // Warning! No way to detect if schema has been modified unless 00244 // we ask the backend again using DatabaseMetaData.getTables(). 00245 00246 } 00247 catch (SQLException e) 00248 { 00249 try 00250 { // All backends failed, just ignore 00251 if (!notifyFailure(backendThread, (long) proc.getTimeout() * 1000, e)) 00252 return; 00253 } 00254 catch (SQLException ignore) 00255 { 00256 } 00257 // Disable this backend (it is no more in sync) by killing the backend 00258 // thread 00259 backendThread.kill(); 00260 String msg = "Stored procedure '" 00261 + proc.getSQLShortForm(backend.getSQLShortFormLength()) 00262 + "' failed on backend " + backend.getName() + " but " 00263 + getSuccess() + " succeeded (" + e + ")"; 00264 backendThread.getLogger().error(msg); 00265 throw new SQLException(msg); 00266 } 00267 } 00268 notifySuccess(); 00269 } |
|
Returns the exceptions lists.
AbstractTask.java の 167 行で定義されています。 参照先 org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.exceptions.
00168 {
00169 return exceptions;
00170 }
|
|
|
Returns the number of threads that must succeed before returning.
AbstractTask.java の 187 行で定義されています。 参照先 org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.nbToComplete.
00188 {
00189 return nbToComplete;
00190 }
|
|
Returns the result.
WriteStoredProcedureTask.java の 276 行で定義されています。 参照元 org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2.execWriteStoredProcedure(), と org.objectweb.cjdbc.controller.loadbalancer.raidb1.RAIDb1.execWriteStoredProcedure().
00277 { 00278 return result; 00279 } |
|
|
Returns the total number of threads.
AbstractTask.java の 208 行で定義されています。 参照先 org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.totalNb.
00209 {
00210 return totalNb;
00211 }
|
|
Returns true if this task has a tid attached to it. Used internally by BackendWorkerThread.
AbstractTask.java の 231 行で定義されています。
00232 { 00233 return hasTid; 00234 } |
|
Notifies that the specified backendThread failed to execute this task. If all nodes failed, this method return
AbstractTask.java の 127 行で定義されています。 参照先 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 } |
|
|
Sets the hasTid value. Used internally by BackendWorkerThread.
AbstractTask.java の 243 行で定義されています。 参照元 org.objectweb.cjdbc.controller.loadbalancer.BackendWorkerThread.addPriorityTask(), と org.objectweb.cjdbc.controller.loadbalancer.BackendWorkerThread.addTask().
00244 {
00245 this.hasTid = hasTid;
00246 }
|
|
Sets the total number of threads.
AbstractTask.java の 219 行で定義されています。 参照元 org.objectweb.cjdbc.controller.loadbalancer.raidb2.RAIDb2.callStoredProcedure().
00220 {
00221 this.totalNb = totalNb;
00222 }
|
|
WriteStoredProcedureTask.java の 284 行で定義されています。 参照先 org.objectweb.cjdbc.common.sql.AbstractRequest.getSQL().
00285 { 00286 return "WriteStoredProcedureTask (" + proc.getSQL() + ")"; 00287 } |
|
WriteStoredProcedureTask.java の 45 行で定義されています。 |
|
WriteStoredProcedureTask.java の 46 行で定義されています。 |