/** * Global Transaction */ public void commit(final String threadId, XidImpl xid, boolean onePhase, boolean singleTM) throws XATransactionException { TransactionContext tc = checkXAState(threadId, xid, true, false); try { if (singleTM || (onePhase && XAResource.XA_RDONLY == prepare(threadId, xid, singleTM))) { return; //nothing to do } //TODO: we have no way of knowing for sure if we can safely use the onephase optimization this.xaImporter.commit(tc.getXid(), false); } catch (XAException e) { throw new XATransactionException(QueryPlugin.Event.TEIID30507, e); } finally { this.transactions.removeTransactionContext(tc); } }
/** * Global Transaction */ public void commit(final String threadId, XidImpl xid, boolean onePhase, boolean singleTM) throws XATransactionException { TransactionContext tc = checkXAState(threadId, xid, true, false); try { if (singleTM || (onePhase && XAResource.XA_RDONLY == prepare(threadId, xid, singleTM))) { return; //nothing to do } //TODO: we have no way of knowing for sure if we can safely use the onephase optimization this.xaTerminator.commit(tc.getXid(), false); } catch (XAException e) { throw new XATransactionException(QueryPlugin.Event.TEIID30507, e); } finally { this.transactions.removeTransactionContext(tc); } }
/** * Global Transaction */ public void commit(final String threadId, XidImpl xid, boolean onePhase, boolean singleTM) throws XATransactionException { TransactionContext tc = checkXAState(threadId, xid, true, false); try { if (singleTM || (onePhase && XAResource.XA_RDONLY == prepare(threadId, xid, singleTM))) { return; //nothing to do } //TODO: we have no way of knowing for sure if we can safely use the onephase optimization this.xaImporter.commit(tc.getXid(), false); } catch (XAException e) { throw new XATransactionException(QueryPlugin.Event.TEIID30507, e); } finally { this.transactions.removeTransactionContext(tc); } }
@Test public void testGlobalOnePhase_teiid_multiple() throws Exception { server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false); TransactionContext tc = server.getOrCreateTransactionContext(THREAD1); server.end(THREAD1, XID1, XAResource.TMSUCCESS, false); server.prepare(THREAD1, XID1, false); server.commit(THREAD1, XID1, true, false); // since there are two sources the commit is not single phase Mockito.verify(xaImporter).commit(tc.getXid(), false); }
@Test public void testGlobalOnePhaseRoolback() throws Exception { server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false); TransactionContext tc = server.getOrCreateTransactionContext(THREAD1); server.end(THREAD1, XID1, XAResource.TMSUCCESS, false); server.prepare(THREAD1, XID1, false); server.rollback(THREAD1, XID1, false); // since there are two sources the commit is not single phase Mockito.verify(xaImporter).rollback(tc.getXid()); }
@Test public void testGlobalPrepare() throws Exception { server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false); TransactionContext tc = server.getOrCreateTransactionContext(THREAD1); server.end(THREAD1, XID1, XAResource.TMSUCCESS, false); server.prepare(THREAD1, XID1, false); Mockito.verify(xaImporter).prepare(tc.getXid()); server.commit(THREAD1, XID1, true, false); }
@Test public void testGlobalOnePhaseCommit() throws Exception { server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false); TransactionContext tc = server.getOrCreateTransactionContext(THREAD1); server.end(THREAD1, XID1, XAResource.TMSUCCESS, false); server.prepare(THREAD1, XID1, false); server.commit(THREAD1, XID1, true, false); Mockito.verify(xaImporter).commit(tc.getXid(), false); }
@Test public void testPrepareWithSuspended() throws Exception { server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false); server.end(THREAD1, XID1, XAResource.TMSUSPEND,false); try { server.prepare(THREAD1, XID1,false); fail("exception expected"); //$NON-NLS-1$ } catch (XATransactionException ex) { assertEquals("TEIID30505 Suspended work still exists on transaction Teiid-Xid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$ } }