|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.edg.security.voms.database.connection.ConnectionWrapper | +--org.edg.security.voms.database.connection.DirectUpdate
Database connection wrapper for read-write operations on tables without a history trace. These wrappers are usually used in autonomous nested transactions. Thus, in order to avoid nasty singlethreaded database deadlocks, connections of this type must not be used to query or update any of the traced tables and vice versa. (ADMIN and CA count as traced tables here.)
Tables for which DirectUpdate is safe include SEQUENCE, REALTIME and REQUEST.
The idiom for using a DirectUpdate is as follows:
DirectUpdate u = DirectUpdate.begin (); long transaction = u.getTransaction(); try { // Do something. u.commit (); } catch (Exception e) { // Do something } finally { if (u.isInTransaction (transaction)) { u.rollback (); } }
Nested Class Summary | |
private static class |
DirectUpdate.Counter
A trivial class for thread-safe counters. |
Field Summary | |
(package private) static DirectUpdate.Counter |
counter
Global transaction counter. |
private long |
transaction
Current transaction id. |
Fields inherited from class org.edg.security.voms.database.connection.ConnectionWrapper |
conn, id, inTransaction, log, pool, stmts |
Constructor Summary | |
DirectUpdate(java.sql.Connection c,
ConnectionPool pool,
int id)
|
Method Summary | |
static DirectUpdate |
begin()
Allocate a new direct update connection. |
(package private) void |
beginTransaction()
|
void |
commit()
Commit the current transaction, and release this connection. |
long |
getTransaction()
Return the current transaction id. |
boolean |
isInTransaction(long id)
Return true if the wrapper is still in the specified transaction. |
boolean |
isReadonly()
|
void |
rollback()
Roll back the current transaction, and release this connection. |
Methods inherited from class org.edg.security.voms.database.connection.ConnectionWrapper |
close, getConnection, getStatement, isClosed, isDirty, isFunctional, isInTransaction, setDirty, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
static DirectUpdate.Counter counter
private long transaction
Constructor Detail |
public DirectUpdate(java.sql.Connection c, ConnectionPool pool, int id)
Method Detail |
public static DirectUpdate begin() throws VOMSException
VOMSException
void beginTransaction() throws VOMSException
beginTransaction
in class ConnectionWrapper
VOMSException
public long getTransaction()
public boolean isInTransaction(long id)
public void rollback()
public void commit() throws GeneralDatabaseException
GeneralDatabaseException
public boolean isReadonly()
isReadonly
in class ConnectionWrapper
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |