@Override public void rollback(Xid xid) throws XAException { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Rolling back transaction: " + xid); } Xid originalxid = xid; xid = createGSXid(xid); // this is a patch because prepare calls rollback in our implementation // and the transaction manager calls it too. So we make it work once. if (transactionsTable.containsKey(xid)) { super.rollback(originalxid); transactionsTable.remove(xid); } }
@Override public boolean isSameRM(XAResource xares) throws XAException { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Comparing XAResource to: " + xares); } if (xares == this) { return true; } try { if (super.isSameRM(xares) && xares instanceof XAResourceJMSImpl) { XAResourceJMSImpl xaresImpl = (XAResourceJMSImpl) xares; return session.equals(xaresImpl.session); } } catch (Exception e) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Exception while comparing XAResource to: " + xares); } } return false; }
public Xid[] recover(int flag) throws XAException { return recoverImpl(flag, false); }
public void rollback(Xid xid) throws XAException { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "XAResourceImpl:rollback(), the Xid is:" + xid + " rmid=" + _rmid + " thread=" + Thread.currentThread().getId()); } xid = createGSXid(xid); try { m_txnManger.abort(xid, COMMIT_ABORT_DEFAULT_TIMEOUT); } catch (UnknownTransactionException e) { if (failOnInvalidRollback) _logger.log(Level.SEVERE, "XAResourceImpl:rollback() , unknownTxnException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XA_RBPROTO, e); } catch (CannotAbortException e) { _logger.log(Level.SEVERE, "XAResourceImpl:rollback() , CannotAbortException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XA_RBPROTO, e); } catch (RemoteException e) { _logger.log(Level.SEVERE, "XAResourceImpl:rollback() , remoteException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XA_RBCOMMFAIL, e); } catch (TimeoutExpiredException e) { _logger.log(Level.SEVERE, "XAResourceImpl:rollback() , timeoutException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XAER_RMFAIL, e); } finally { _activeEmptyTransactions.remove(xid); _suspendedXtns.remove(xid); if (_resourcePerSingleTxn) _relevantTx = false; } }
public void end(Xid xid, int flag) throws XAException { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "XAResourceImpl:end(), the Xid is:" + xid + ", flag is:" + flag + " rmid=" + _rmid + " thread=" + Thread.currentThread().getId()); } xid = createGSXid(xid); switch (flag) { case TMSUSPEND: { Transaction.Created suspended = _proxy.getContextTransaction(); if (suspended == null) { _logger.log(Level.SEVERE, "XAResourceImpl:end() + suspend and current is NULL , Xid = :" + xid + ", flag is:" + flag + " rmid=" + _rmid + " thread=" + Thread.currentThread().getId()); throw new RuntimeException("XAResourceImpl:end() + suspend and current is NULL , Xid = :" + xid + ", flag is:" + flag + " rmid=" + _rmid + " thread=" + Thread.currentThread().getId()); } _suspendedXtns.put(xid, suspended); break; } case TMSUCCESS: break; case TMFAIL: rollback(xid); } _proxy.replaceContextTransaction(null); }
case TMENDRSCAN + TMSTARTRSCAN: case TMNOFLAGS: { res = recoverGlobalXtns(); if (!fromInitialize) { List<Xid> r1 = new ArrayList<Xid>(); throw createsXAException(XAException.XAER_RMFAIL, e); } catch (CannotCommitException e) { _logger.log(Level.SEVERE, "XAResourceImpl:recover() , CannotCommitException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e); throw createsXAException(XAException.XAER_RMFAIL, e); } finally { if (_logger.isLoggable(Level.FINE)) {
Xid[] xr = new Xid[0]; if (_logger.isLoggable(Level.INFO)) { _logger.log(Level.INFO, "XAResourceImpl:constructor geting recover info rmid=" + getRmid() + " thread=" + Thread.currentThread().getId() + " proxy=" + _proxy); xr = recoverImpl(0, true); } catch (Exception ex) {
public Transaction.Created replaceContextTransaction(Transaction.Created txn, ActionListener currentActionListener, boolean delegatedXa) { if (_logger.isLoggable(Level.FINE)) { if (txn == null) { _logger.log(Level.FINE, "GS:replaceContextTransaction called with txn NULL thread=" + Thread.currentThread().getId() + " proxy=" + this); } else { XAResourceImpl xares = null; if (currentActionListener != null) xares = (XAResourceImpl) currentActionListener; if (xares != null) _logger.log(Level.FINE, "GS:replaceContextTransaction called with txn thread=" + Thread.currentThread().getId() + " rmid=" + xares.getRmid() + " proxy=" + this); else _logger.log(Level.FINE, "GS:replaceContextTransaction called with txn thread=" + Thread.currentThread().getId() + " rmid= = NULL" + " proxy=" + this); } } Transaction.Created oldTxn = getContextTransaction(); if (txn != null) { _supportsContextTransaction = true; _contextTransactions.set(new CurrentXtnProxyHolder(txn, currentActionListener, delegatedXa)); } else _contextTransactions.remove(); return oldTxn; }
public void start(Xid xid, int flag) throws XAException { startIn(xid, flag, true); }
@Override public void commit(Xid xid, boolean onePhase) throws XAException { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Committing transaction: " + xid); } // TODO: in case of onePhase, do we need to prepare here?? if (onePhase) { prepare(xid); } Xid originalxid = xid; xid = createGSXid(xid); super.commit(originalxid, onePhase); transactionsTable.remove(xid); }
@Override public int prepare(Xid xid) throws XAException { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Preparing transaction: " + xid); } Xid originalxid = xid; xid = createGSXid(xid); XATrasactionContext context = transactionsTable.get(xid); if (context != null) { try { session.sendMessages(context.getSentMessages(), context.getTransaction()); } catch (RemoteException e) { throw new XAException(XAException.XA_RBCOMMFAIL); } catch (Exception e) { throw new XAException(XAException.XA_RBROLLBACK); } } int result = super.prepare(originalxid); return result; }
public void commit(Xid xid, boolean onePhase) throws XAException { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "XAResourceImpl:commit(), the xid is:" + xid + ", the onePhase:" + onePhase + " rmid=" + _rmid + " thread=" + Thread.currentThread().getId()); } xid = createGSXid(xid); try { m_txnManger.commit(xid, COMMIT_ABORT_DEFAULT_TIMEOUT); } catch (UnknownTransactionException e) { _logger.log(Level.SEVERE, "XAResourceImpl:commit() , unknowntxnException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XAER_RMERR, e); } catch (CannotCommitException e) { _logger.log(Level.SEVERE, "XAResourceImpl:commit() , cannotcommitException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XAER_RMERR, e); } catch (RemoteException e) { _logger.log(Level.SEVERE, "XAResourceImpl:commit() , remoteException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XAER_RMFAIL, e); } catch (TimeoutExpiredException e) { _logger.log(Level.SEVERE, "XAResourceImpl:commit() , timeoutexpiredException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XAER_RMFAIL, e); } finally { _activeEmptyTransactions.remove(xid); _suspendedXtns.remove(xid); if (_resourcePerSingleTxn) _relevantTx = false; } }
public boolean isSameRM(XAResource xares) throws XAException { boolean res = false; XAResourceImpl other = null; if (_resourcePerSingleTxn && !_relevantTx) { // signal TM (atomikos) resource can be purged if (_logger.isLoggable(Level.FINEST)) _logger.fine("tx is not relevant,rmid " + _rmid); throw new XAException("Not relevant TX!"); } try { if (xares == this) { res = true; } else if (xares instanceof XAResourceImpl) { other = (XAResourceImpl) xares; //res = _rmid.equals(other.getRmid()); res = other.m_txnManger.equals(m_txnManger) && (_proxy.equals(other._proxy)); } } catch (Exception e) { // false } finally { if (_logger.isLoggable(Level.FINEST)) { if (other != null) _logger.log(Level.FINEST, "XAResourceImpl:isSameRM(), the XAResource is: " + xares + " our=" + _rmid + " other=" + other.getRmid() + " result=" + res + " thread=" + Thread.currentThread().getId()); else _logger.log(Level.FINEST, "XAResourceImpl:isSameRM(),othger is NULL the XAResource is: " + xares + " our=" + _rmid + " result=" + res + " thread=" + Thread.currentThread().getId()); } } return res; }
public int prepare(Xid xid) throws XAException { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "XAResourceImpl:prepare(), the Xid is: " + xid + " rmid=" + _rmid + " thread=" + Thread.currentThread().getId()); } xid = createGSXid(xid); if (_activeEmptyTransactions.remove(xid) != null) { // if empty than read_only return XA_RDONLY; } try { int result = m_txnManger.prepare(xid); switch (result) { // Try to prepare case TransactionParticipant.PREPARED: return XA_OK; case TransactionParticipant.NOTCHANGED: return XA_RDONLY; default: // Abort throw new XAException(XAException.XA_RBROLLBACK); } } catch (UnknownTransactionException e) { _logger.log(Level.SEVERE, "XAResourceImpl:prepare() , UnknownTransactionException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XA_RBROLLBACK, e); } catch (CannotCommitException e) { _logger.log(Level.SEVERE, "XAResourceImpl:prepare() , CannotCommitException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XA_RBROLLBACK, e); } catch (RemoteException e) { _logger.log(Level.SEVERE, "XAResourceImpl:prepare() , remoteException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XA_RBCOMMFAIL, e); } }
xid = createGSXid(xid); } catch (RemoteException e) { _logger.log(Level.SEVERE, "XAResourceImpl:startIn() , remoteException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XA_RBCOMMFAIL, e); } catch (LeaseDeniedException e) { _logger.log(Level.SEVERE, "XAResourceImpl:startIn() , LeaseDeniedException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XAER_INVAL, e);