Java Code Examples for javax.transaction.xa.XAResource#TMFAIL
The following examples show how to use
javax.transaction.xa.XAResource#TMFAIL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalXAResource.java From ByteJTA with GNU Lesser General Public License v3.0 | 6 votes |
public synchronized void end(Xid xid, int flags) throws XAException { if (xid == null) { throw new XAException(XAException.XAER_INVAL); } else if (this.currentXid == null) { throw new XAException(XAException.XAER_PROTO); } else if (!this.currentXid.equals(xid)) { throw new XAException(XAException.XAER_PROTO); } else if (flags == XAResource.TMSUSPEND) { this.suspendXid = xid; this.suspendAutoCommit = this.originalAutoCommit; this.currentXid = null; this.originalAutoCommit = true; } else if (flags == XAResource.TMSUCCESS) { // delay the logging operation to the commit phase. // this.createTransactionLogIfNecessary(xid); } else if (flags == XAResource.TMFAIL) { logger.debug("Error occurred while ending local-xa-resource."); } else { throw new XAException(XAException.XAER_PROTO); } }
Example 2
Source File: TxLogManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ public void end(Xid xid, int flags) throws XAException { log.tracef("end(%s, %d)", xid, flags); if (flags == XAResource.TMSUCCESS) { addTxState(TX_XA_END_TMSUCCESS); } else if (flags == XAResource.TMFAIL) { addTxState(TX_XA_END_TMFAIL); } else if (flags == XAResource.TMSUSPEND) { addTxState(TX_XA_END_TMSUSPEND); } else { addTxState(TX_XA_END_UNKNOWN); } }
Example 3
Source File: FBManagedConnection.java From jaybird with GNU Lesser General Public License v2.1 | 6 votes |
/** * Dissociates a resource from a global transaction. * * @throws XAException * Occurs when the state was not correct (end called twice), or the transaction ID is wrong. */ private void end(Xid id, int flags) throws XAException { if (flags != XAResource.TMSUCCESS && flags != XAResource.TMFAIL && flags != XAResource.TMSUSPEND) throw new FBXAException("flag not allowed in this context: " + flags + ", valid flags are TMSUCCESS, TMFAIL, TMSUSPEND", XAException.XAER_PROTO); internalEnd(id, flags); mcf.notifyEnd(this, id); inDistributedTransaction = false; try { // This will reset the managed environment of the associated connections and set the transaction coordinator to local // TODO This is a bit of a hack; need to find a better way setManagedEnvironment(isManagedEnvironment()); } catch (SQLException ex) { throw new FBXAException("Reset of managed state failed", XAException.XAER_RMERR, ex); } }
Example 4
Source File: ClientSessionImpl.java From activemq-artemis with Apache License 2.0 | 6 votes |
private String convertTXFlag(final int flags) { if (flags == XAResource.TMSUSPEND) { return "SESS_XA_SUSPEND"; } else if (flags == XAResource.TMSUCCESS) { return "TMSUCCESS"; } else if (flags == XAResource.TMFAIL) { return "TMFAIL"; } else if (flags == XAResource.TMJOIN) { return "TMJOIN"; } else if (flags == XAResource.TMRESUME) { return "TMRESUME"; } else if (flags == XAResource.TMNOFLAGS) { // Don't need to flush since the previous end will have done this return "TMNOFLAGS"; } else { return "XAER_INVAL(" + flags + ")"; } }
Example 5
Source File: MultiThreadedTx.java From reladomo with Apache License 2.0 | 5 votes |
@Override public int preDelistCheck(MultiThreadedTx tx, int incomingFlag) { if (incomingFlag == XAResource.TMFAIL) { logger.warn("transaction marked for rollback due to TMFAIL"); tx.status.set(MARKED_ROLLBACK); } return incomingFlag; }
Example 6
Source File: NetXAConnectionReply.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
protected int readXaEndUnitOfWork(NetConnection conn) throws DisconnectException { // We have ended the XA unit of work, the next logical connection // should be reset using the normal procedure. conn.xares_.setKeepCurrentIsolationLevel(false); NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_]; int xaFlags = callInfo.xaFlags_; startSameIdChainParse(); parseSYNCCTLreply(conn); endOfSameIdChainData(); if (xaFlags == XAResource.TMFAIL) { return javax.transaction.xa.XAException.XA_RBROLLBACK; } return javax.transaction.xa.XAResource.XA_OK; }
Example 7
Source File: AtomikosTransactionAssistantImplTest.java From genericconnector with Apache License 2.0 | 5 votes |
private void testCloseDelistsResource(final int result) throws Exception { final UserTransactionManager tm = mock(UserTransactionManager.class); final Transaction tx = mock(Transaction.class); when(tm.getTransaction()).thenReturn(tx); MicroserviceXAResource ms = getMs(); final AtomicInteger count = new AtomicInteger(); ms.start(getXid(), 0); AtomikosTransactionAssistantImpl impl = new AtomikosTransactionAssistantImpl(ms){ @Override protected UserTransactionManager getTransactionManager() { return tm; } }; try{ //TEST impl.executeInActiveTransaction(new ExecuteCallback<Void>() { @Override public Void execute(String txid) throws Exception { count.incrementAndGet(); if(result == XAResource.TMSUCCESS){ return null; //no exception => TMSUCCESS }else{ throw new Exception(); // => TMFAIL } } }); if(result == XAResource.TMFAIL) fail("no exception"); }catch(Exception e){ if(result == XAResource.TMSUCCESS) fail("exception not expected"); } //TEST impl.close(); assertEquals(1, count.get()); verify(tx, times(1)).delistResource(eq(ms), eq(result)); }
Example 8
Source File: EhcacheXAResource.java From ehcache3 with Apache License 2.0 | 5 votes |
@Override public void end(Xid xid, int flag) throws XAException { if (flag != XAResource.TMSUCCESS && flag != XAResource.TMFAIL) { throw new EhcacheXAException("End flag not supported : " + xaResourceFlagsToString(flag), XAException.XAER_INVAL); } if (currentXid == null) { throw new EhcacheXAException("Not started on : " + xid, XAException.XAER_PROTO); } TransactionId transactionId = new TransactionId(currentXid); XATransactionContext<K, V> transactionContext = transactionContextFactory.get(transactionId); if (transactionContext == null) { throw new EhcacheXAException("Cannot end unknown XID : " + xid, XAException.XAER_NOTA); } boolean destroyContext = false; if (flag == XAResource.TMFAIL) { destroyContext = true; } currentXid = null; try { if (transactionContext.hasTimedOut()) { destroyContext = true; throw new EhcacheXAException("Transaction timeout for XID : " + xid, XAException.XA_RBTIMEOUT); } } finally { if (destroyContext) { transactionContextFactory.destroy(transactionId); } } }
Example 9
Source File: NetXAConnectionReply.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
protected int readXaEndUnitOfWork(NetConnection conn) throws DisconnectException { // We have ended the XA unit of work, the next logical connection // should be reset using the normal procedure. conn.xares_.setKeepCurrentIsolationLevel(false); NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_]; int xaFlags = callInfo.xaFlags_; startSameIdChainParse(); parseSYNCCTLreply(conn); endOfSameIdChainData(); if (xaFlags == XAResource.TMFAIL) { return javax.transaction.xa.XAException.XA_RBROLLBACK; } return javax.transaction.xa.XAResource.XA_OK; }
Example 10
Source File: FBManagedConnection.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * The {@code internalEnd} method ends the xid as requested if appropriate and throws a XAException including the * appropriate XA error code and a message if not. The caller can decode the exception as necessary. * * @param xid * a {@code Xid} value * @param flags * an {@code int} value * @throws XAException * if an error occurs */ void internalEnd(Xid xid, int flags) throws XAException { if (log.isDebugEnabled()) log.debug("End called: " + xid); FbTransaction endingTr = xidMap.get(xid); if (endingTr == null) { throw new FBXAException("Unrecognized transaction", XAException.XAER_NOTA); } if (flags == XAResource.TMFAIL) { try { endingTr.rollback(); getGDSHelper().setCurrentTransaction(null); } catch (SQLException ex) { throw new FBXAException("can't rollback transaction", XAException.XAER_RMFAIL, ex); } } else if (flags == XAResource.TMSUCCESS) { if (gdsHelper != null && endingTr == gdsHelper.getCurrentTransaction()) { gdsHelper.setCurrentTransaction(null); } else { throw new FBXAException("You are trying to end a transaction that is not the current transaction", XAException.XAER_INVAL); } } else if (flags == XAResource.TMSUSPEND) { if (gdsHelper != null && endingTr == gdsHelper.getCurrentTransaction()) { gdsHelper.setCurrentTransaction(null); } else { throw new FBXAException("You are trying to suspend a transaction that is not the current transaction", XAException.XAER_INVAL); } } }
Example 11
Source File: NetXAConnectionReply.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
protected int readXaEndUnitOfWork(NetConnection conn) throws DisconnectException { // We have ended the XA unit of work, the next logical connection // should be reset using the normal procedure. conn.xares_.setKeepCurrentIsolationLevel(false); NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_]; int xaFlags = callInfo.xaFlags_; startSameIdChainParse(); parseSYNCCTLreply(conn); endOfSameIdChainData(); if (xaFlags == XAResource.TMFAIL) { return javax.transaction.xa.XAException.XA_RBROLLBACK; } return javax.transaction.xa.XAResource.XA_OK; }
Example 12
Source File: LocalTx.java From reladomo with Apache License 2.0 | 4 votes |
@Override public int getEndFlag() { return XAResource.TMFAIL; }
Example 13
Source File: LocalTx.java From reladomo with Apache License 2.0 | 4 votes |
@Override public int getEndFlag() { return XAResource.TMFAIL; }
Example 14
Source File: LocalTx.java From reladomo with Apache License 2.0 | 4 votes |
@Override public int getEndFlag() { return XAResource.TMFAIL; }
Example 15
Source File: LocalTx.java From reladomo with Apache License 2.0 | 4 votes |
@Override public int getEndFlag() { return XAResource.TMFAIL; }
Example 16
Source File: LocalTx.java From reladomo with Apache License 2.0 | 4 votes |
@Override public int preDelistCheck(LocalTx tx, int incomingFlag) { return XAResource.TMFAIL; }
Example 17
Source File: MultiThreadedTx.java From reladomo with Apache License 2.0 | 4 votes |
@Override public int getEndFlag() { return XAResource.TMFAIL; }
Example 18
Source File: MultiThreadedTx.java From reladomo with Apache License 2.0 | 4 votes |
@Override public int getEndFlag() { return XAResource.TMFAIL; }
Example 19
Source File: MultiThreadedTx.java From reladomo with Apache License 2.0 | 4 votes |
@Override public int getEndFlag() { return XAResource.TMFAIL; }
Example 20
Source File: MultiThreadedTx.java From reladomo with Apache License 2.0 | 4 votes |
@Override public int getEndFlag() { return XAResource.TMFAIL; }