Public Member Functions | |
RollbackTask (int nbToComplete, int totalNb, long timeout, String login, long transactionId) | |
void | executeTask (BackendWorkerThread backendThread) throws SQLException |
String | toString () |
Definition at line 41 of file RollbackTask.java.
|
Rollbacks a transaction given a login and a transaction id.
Definition at line 61 of file RollbackTask.java. 00063 { 00064 super(nbToComplete, totalNb); 00065 this.login = login; 00066 this.transactionId = transactionId; 00067 this.timeout = timeout; 00068 }
|
|
Rollbacks a transaction with the given backend thread.
Implements org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask. Definition at line 76 of file RollbackTask.java. References org.objectweb.cjdbc.controller.backend.DatabaseBackend.getConnectionManager(), org.objectweb.cjdbc.controller.backend.DatabaseBackend.getName(), org.objectweb.cjdbc.controller.loadbalancer.tasks.AbstractTask.getSuccess(), 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(), and org.objectweb.cjdbc.controller.backend.DatabaseBackend.stopTransaction(). 00077 { 00078 DatabaseBackend db = backendThread.getBackend(); 00079 Long lTid = new Long(transactionId); 00080 00081 AbstractConnectionManager cm = db.getConnectionManager(login); 00082 if (cm == null) 00083 { 00084 SQLException se = new SQLException( 00085 "No Connection Manager for Virtual Login:" + login); 00086 try 00087 { 00088 notifyFailure(backendThread, 1, se); 00089 } 00090 catch (SQLException ignore) 00091 { 00092 00093 } 00094 throw se; 00095 } 00096 00097 Connection c = cm.retrieveConnection(transactionId); 00098 00099 // Sanity check 00100 if (c == null) 00101 { // Bad connection 00102 db.stopTransaction(lTid); 00103 SQLException se = new SQLException( 00104 "Unable to retrieve connection for transaction " + transactionId); 00105 try 00106 { // All backends failed, just ignore 00107 if (!notifyFailure(backendThread, timeout, se)) 00108 return; 00109 } 00110 catch (SQLException ignore) 00111 { 00112 } 00113 // Disable this backend (it is no more in sync) by killing the backend 00114 // thread 00115 backendThread.kill(); 00116 String msg = "Failed to rollback transaction " + transactionId 00117 + " on backend " + db.getName() + " but " + getSuccess() 00118 + " succeeded (" + se + ")"; 00119 backendThread.getLogger().error(msg); 00120 throw new SQLException(msg); 00121 } 00122 00123 // Execute Query 00124 try 00125 { 00126 c.rollback(); 00127 c.setAutoCommit(true); 00128 } 00129 catch (Exception e) 00130 { 00131 try 00132 { 00133 if (!notifyFailure(backendThread, timeout, new SQLException(e 00134 .getMessage()))) 00135 return; 00136 } 00137 catch (SQLException ignore) 00138 { 00139 } 00140 // Disable this backend (it is no more in sync) by killing the backend 00141 // thread 00142 backendThread.kill(); 00143 String msg = "Failed to rollback transaction " + transactionId 00144 + " on backend " + db.getName() + " but " + getSuccess() 00145 + " succeeded (" + e + ")"; 00146 backendThread.getLogger().error(msg); 00147 throw new SQLException(msg); 00148 } 00149 finally 00150 { 00151 cm.releaseConnection(transactionId); 00152 db.stopTransaction(lTid); 00153 } 00154 notifySuccess(); 00155 }
|
|
Definition at line 160 of file RollbackTask.java. 00161 { 00162 return "RollbackTask (" + transactionId + ")"; 00163 }
|