/**** XAConnection interface ****/ public Connection getConnection() throws SQLException { if (logger.logDebug()) debug("PGXAConnection.getConnection called"); Connection conn = super.getConnection(); // When we're outside an XA transaction, autocommit // is supposed to be true, per usual JDBC convention. // When an XA transaction is in progress, it should be // false. if(state == STATE_IDLE) conn.setAutoCommit(true); /* * Wrap the connection in a proxy to forbid application from * fiddling with transaction state directly during an XA transaction */ ConnectionHandler handler = new ConnectionHandler(conn); return (Connection)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Connection.class, PGConnection.class}, handler); }
@Override public void commit(Xid xid, boolean onePhase) throws XAException { if (LOGGER.isLoggable(Level.FINEST)) { debug("committing xid = " + xid + (onePhase ? " (one phase) " : " (two phase)")); } if (xid == null) { throw new PGXAException(GT.tr("xid must not be null"), XAException.XAER_INVAL); } if (onePhase) { commitOnePhase(xid); } else { commitPrepared(xid); } }
public void rollback(Xid xid) throws XAException { if (LOGGER.isLoggable(Level.FINEST)) { debug("rolling back xid = " + xid); if (committedOrRolledBack || !xid.equals(preparedXid)) { if (LOGGER.isLoggable(Level.FINEST)) { debug("rolling back xid " + xid + " while the connection prepared xid is " + preparedXid + (committedOrRolledBack ? ", but the connection was already committed/rolled-back" : "")); debug("rollback connection failure (sql error code " + ex.getSQLState() + "), reconnection could be expected");
public void commit(Xid xid, boolean onePhase) throws XAException { if (logger.logDebug()) debug("committing xid = " + xid + (onePhase ? " (one phase) " : " (two phase)")); if (xid == null) throw new PGXAException(GT.tr("xid must not be null"), XAException.XAER_INVAL); if (onePhase) commitOnePhase(xid); else commitPrepared(xid); }
if (committedOrRolledBack || !xid.equals(preparedXid)) { if (LOGGER.isLoggable(Level.FINEST)) { debug("committing xid " + xid + " while the connection prepared xid is " + preparedXid + (committedOrRolledBack ? ", but the connection was already committed/rolled-back" : "")); debug("commit connection failure (sql error code " + ex.getSQLState() + "), reconnection could be expected");
public int prepare(Xid xid) throws XAException { if (LOGGER.isLoggable(Level.FINEST)) { debug("preparing transaction xid = " + xid); debug("Prepare xid " + xid + " but current connection is not attached to a transaction" + " while it was prepared in past with prepared xid " + preparedXid); debug("Error to prepare xid " + xid + ", the current connection already bound with xid " + currentXid);
debug("rolling back xid = " + xid);
public void end(Xid xid, int flags) throws XAException { if (LOGGER.isLoggable(Level.FINEST)) { debug("ending transaction xid = " + xid);
/** * Preconditions: * 1. Flags is one of TMSUCCESS, TMFAIL, TMSUSPEND * 2. xid != null * 3. Connection is associated with transaction xid * * Implementation deficiency preconditions: * 1. Flags is not TMSUSPEND * * Postconditions: * 1. connection is disassociated from the transaction. */ public void end(Xid xid, int flags) throws XAException { if (logger.logDebug()) debug("ending transaction xid = " + xid); // Check preconditions if (flags != XAResource.TMSUSPEND && flags != XAResource.TMFAIL && flags != XAResource.TMSUCCESS) throw new PGXAException(GT.tr("Invalid flags"), XAException.XAER_INVAL); if (xid == null) throw new PGXAException(GT.tr("xid must not be null"), XAException.XAER_INVAL); if (state != STATE_ACTIVE || !currentXid.equals(xid)) throw new PGXAException(GT.tr("tried to call end without corresponding start call"), XAException.XAER_PROTO); // Check implementation deficiency preconditions if (flags == XAResource.TMSUSPEND) throw new PGXAException(GT.tr("suspend/resume not implemented"), XAException.XAER_RMERR); // We ignore TMFAIL. It's just a hint to the RM. We could roll back immediately // if TMFAIL was given. // All clear. We don't have any real work to do. state = STATE_ENDED; }
debug("preparing transaction xid = " + xid);
public void start(Xid xid, int flags) throws XAException { if (LOGGER.isLoggable(Level.FINEST)) { debug("starting transaction xid = " + xid);
debug("starting transaction xid = " + xid);
/**** XAConnection interface ****/ public Connection getConnection() throws SQLException { if (logger.logDebug()) debug("PGXAConnection.getConnection called"); Connection conn = super.getConnection(); // When we're outside an XA transaction, autocommit // is supposed to be true, per usual JDBC convention. // When an XA transaction is in progress, it should be // false. if(state == STATE_IDLE) conn.setAutoCommit(true); return conn; }
/**** XAConnection interface ****/ public Connection getConnection() throws SQLException { if (logger.logDebug()) debug("PGXAConnection.getConnection called"); Connection conn = super.getConnection(); // When we're outside an XA transaction, autocommit // is supposed to be true, per usual JDBC convention. // When an XA transaction is in progress, it should be // false. if(state == STATE_IDLE) conn.setAutoCommit(true); /* * Wrap the connection in a proxy to forbid application from * fiddling with transaction state directly during an XA transaction */ ConnectionHandler handler = new ConnectionHandler(conn); return (Connection)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Connection.class, PGConnection.class}, handler); }
public void commit(Xid xid, boolean onePhase) throws XAException { if (logger.logDebug()) debug("committing xid = " + xid + (onePhase ? " (one phase) " : " (two phase)")); if (xid == null) throw new PGXAException(GT.tr("xid must not be null"), XAException.XAER_INVAL); if (onePhase) commitOnePhase(xid); else commitPrepared(xid); }
public void commit(Xid xid, boolean onePhase) throws XAException { if (logger.logDebug()) debug("committing xid = " + xid + (onePhase ? " (one phase) " : " (two phase)")); if (xid == null) throw new PGXAException(GT.tr("xid must not be null"), XAException.XAER_INVAL); if (onePhase) commitOnePhase(xid); else commitPrepared(xid); }
debug("rolling back xid = " + xid);
/** * Preconditions: * 1. Flags is one of TMSUCCESS, TMFAIL, TMSUSPEND * 2. xid != null * 3. Connection is associated with transaction xid * * Implementation deficiency preconditions: * 1. Flags is not TMSUSPEND * * Postconditions: * 1. connection is disassociated from the transaction. */ public void end(Xid xid, int flags) throws XAException { if (logger.logDebug()) debug("ending transaction xid = " + xid); // Check preconditions if (flags != XAResource.TMSUSPEND && flags != XAResource.TMFAIL && flags != XAResource.TMSUCCESS) throw new PGXAException(GT.tr("Invalid flags"), XAException.XAER_INVAL); if (xid == null) throw new PGXAException(GT.tr("xid must not be null"), XAException.XAER_INVAL); if (state != STATE_ACTIVE || !currentXid.equals(xid)) throw new PGXAException(GT.tr("tried to call end without corresponding start call"), XAException.XAER_PROTO); // Check implementation deficiency preconditions if (flags == XAResource.TMSUSPEND) throw new PGXAException(GT.tr("suspend/resume not implemented"), XAException.XAER_RMERR); // We ignore TMFAIL. It's just a hint to the RM. We could roll back immediately // if TMFAIL was given. // All clear. We don't have any real work to do. state = STATE_ENDED; }
/** * Preconditions: * 1. Flags is one of TMSUCCESS, TMFAIL, TMSUSPEND * 2. xid != null * 3. Connection is associated with transaction xid * * Implementation deficiency preconditions: * 1. Flags is not TMSUSPEND * * Postconditions: * 1. connection is disassociated from the transaction. */ public void end(Xid xid, int flags) throws XAException { if (logger.logDebug()) debug("ending transaction xid = " + xid); // Check preconditions if (flags != XAResource.TMSUSPEND && flags != XAResource.TMFAIL && flags != XAResource.TMSUCCESS) throw new PGXAException(GT.tr("Invalid flags"), XAException.XAER_INVAL); if (xid == null) throw new PGXAException(GT.tr("xid must not be null"), XAException.XAER_INVAL); if (state != STATE_ACTIVE || !currentXid.equals(xid)) throw new PGXAException(GT.tr("tried to call end without corresponding start call"), XAException.XAER_PROTO); // Check implementation deficiency preconditions if (flags == XAResource.TMSUSPEND) throw new PGXAException(GT.tr("suspend/resume not implemented"), XAException.XAER_RMERR); // We ignore TMFAIL. It's just a hint to the RM. We could roll back immediately // if TMFAIL was given. // All clear. We don't have any real work to do. state = STATE_ENDED; }
debug("preparing transaction xid = " + xid);