javax.transaction.xa.XAResource Java Examples
The following examples show how to use
javax.transaction.xa.XAResource.
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: XAResourceWrapperImpl.java From lams with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ public boolean isSameRM(XAResource resource) throws XAException { if (overrideRmValue != null) { if (log.isTraceEnabled()) { log.trace("Executing isSameRM with override value" + overrideRmValue + " for XAResourceWrapper" + this); } return overrideRmValue.booleanValue(); } else { if (resource instanceof org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper) { org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper other = (org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper)resource; return xaResource.isSameRM(other.getResource()); } else { return xaResource.isSameRM(resource); } } }
Example #2
Source File: NetXAConnection.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public void readRollback() throws SqlException { NetXACallInfo callInfo = netCon.xares_.callInfoArray_ [netCon.currXACallInfoOffset_]; callInfo.xaRetVal_ = XAResource.XA_OK; // initialize XARETVAL readLocalXARollback_(); if (callInfo.xaRetVal_ != XAResource.XA_OK) { // xaRetVal has possible error, format it callInfo.xaFunction_ = NetXAResource.XAFUNC_ROLLBACK; netCon.xares_.xaRetValErrorAccumSQL(callInfo, 0); callInfo.xaRetVal_ = XAResource.XA_OK; // re-initialize XARETVAL throw netCon.xares_.exceptionsOnXA; } // for all XA connectiions // TODO:KATHEY - Do we need this? netCon.setXAState(netCon.XA_T0_NOT_ASSOCIATED); }
Example #3
Source File: WebSphereTmFactory.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public boolean enlistResource(final XAResource xaRes) throws RollbackException, IllegalStateException, SystemException { if (xaRes == null) return false; // final XAResource res = new IgniteOnePhaseXAResource(xaRes); Object ibmProxy = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {onePhaseXAResourceCls}, new InvocationHandler() { @Override public Object invoke(Object proxy, Method mtd, Object[] args) throws Throwable { return mtd.invoke(xaRes, args); } }); return tx.enlistResource((XAResource)ibmProxy); }
Example #4
Source File: CompensablePrimaryFilter.java From ByteTCC with GNU Lesser General Public License v3.0 | 6 votes |
public Result providerInvoke(Invoker<?> invoker, Invocation invocation) throws RpcException, RemotingException { String interfaceClazz = RpcContext.getContext().getUrl().getServiceInterface(); boolean participantFlag = TransactionParticipant.class.getName().equals(interfaceClazz); boolean xaResourceFlag = XAResource.class.getName().equals(interfaceClazz); boolean coordinatorFlag = RemoteCoordinator.class.getName().equals(interfaceClazz); if (participantFlag == false && xaResourceFlag == false && coordinatorFlag == false) { return this.providerInvokeForSVC(invoker, invocation); } else if (StringUtils.equals(invocation.getMethodName(), KEY_XA_RESOURCE_START)) { return this.providerInvokeForKey(invoker, invocation); } else if (StringUtils.equals(invocation.getMethodName(), KEY_XA_GET_IDENTIFIER)) { return this.providerInvokeForKey(invoker, invocation); } else if (StringUtils.equals(invocation.getMethodName(), KEY_XA_GET_APPLICATION)) { return this.providerInvokeForKey(invoker, invocation); } else if (StringUtils.equals(invocation.getMethodName(), KEY_XA_GET_REMOTEADDR)) { return this.providerInvokeForKey(invoker, invocation); } else if (StringUtils.equals(invocation.getMethodName(), KEY_XA_GET_REMOTENODE)) { return this.providerInvokeForKey(invoker, invocation); } else { return this.providerInvokeForTCC(invoker, invocation); } }
Example #5
Source File: EhcacheXAResource.java From ehcache3 with Apache License 2.0 | 6 votes |
@Override public Xid[] recover(int flags) throws XAException { if (flags != XAResource.TMNOFLAGS && flags != XAResource.TMSTARTRSCAN && flags != XAResource.TMENDRSCAN && flags != (XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN)) { throw new EhcacheXAException("Recover flags not supported : " + xaResourceFlagsToString(flags), XAException.XAER_INVAL); } if ((flags & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) { List<Xid> xids = new ArrayList<>(); Set<TransactionId> transactionIds = journal.recover().keySet(); for (TransactionId transactionId : transactionIds) { // filter-out in-flight tx if (!transactionContextFactory.contains(transactionId)) { xids.add(transactionId.getSerializableXid()); } } return xids.toArray(new Xid[xids.size()]); } return new Xid[0]; }
Example #6
Source File: TestSingleThreadedLocalTm.java From reladomo with Apache License 2.0 | 6 votes |
public void testCommitOneResource() throws Exception { ExecutionOrder.start(); this.tm.begin(); Transaction tx = this.tm.getTransaction(); ExceptionThrowingXaResource res = new ExceptionThrowingXaResource(false); assertTrue(tx.enlistResource(res)); assertTrue(tx.delistResource(res, XAResource.TMSUCCESS)); tx.commit(); ExecutionOrder.verifyForThread(res, "start"); ExecutionOrder.verifyForThread(res, "end"); ExecutionOrder.verifyForThread(res, "commit"); res.verify(); res.verifyStartEndCommit(XAResource.TMNOFLAGS, XAResource.TMSUCCESS, true); postTransactionVerify(); }
Example #7
Source File: TestFBXAResource.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void test2PCXATrans() throws Exception { FBManagedConnectionFactory mcf = initMcf(); FBManagedConnection mc = mcf.createManagedConnection(); XAResource xa = mc.getXAResource(); Xid xid = new XidImpl(); xa.start(xid, XAResource.TMNOFLAGS); assertNotNull("no db handle after start xid", mc.getGDSHelper().getCurrentDatabase()); xa.end(xid, XAResource.TMSUCCESS); xa.prepare(xid); xa.commit(xid, false); mc.destroy(); }
Example #8
Source File: CloudSpannerXAConnectionTest.java From spanner-jdbc with MIT License | 5 votes |
@Test public void testPrepareWithOtherXid() throws SQLException, XAException { thrown.expect(CloudSpannerXAException.class); thrown.expectMessage(CloudSpannerXAException.PREPARE_WITH_SAME); CloudSpannerXAConnection subject = createSubject(); Xid xid = getRandomXid(); subject.start(xid, XAResource.TMNOFLAGS); subject.end(xid, XAResource.TMSUCCESS); subject.prepare(getRandomXid()); }
Example #9
Source File: CloudSpannerXAConnectionTest.java From spanner-jdbc with MIT License | 5 votes |
@Test public void testJoinWithDifferentXid() throws SQLException, XAException { thrown.expect(CloudSpannerXAException.class); thrown.expectMessage(CloudSpannerXAException.INTERLEAVING_NOT_IMPLEMENTED); CloudSpannerXAConnection subject = createSubject(); Xid xid = getRandomXid(); subject.start(xid, XAResource.TMNOFLAGS); subject.end(xid, XAResource.TMSUCCESS); subject.start(getRandomXid(), XAResource.TMJOIN); }
Example #10
Source File: ActiveMQXAResourceWrapper.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public boolean setTransactionTimeout(final int seconds) throws XAException { XAResource xaResource = getDelegate(false); if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { ActiveMQXARecoveryLogger.LOGGER.debug("setTransactionTimeout " + xaResource + " xid "); } try { return xaResource.setTransactionTimeout(seconds); } catch (XAException e) { throw check(e); } }
Example #11
Source File: ClientXAConnection.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public XAResource getXAResource() throws SQLException { if (logWriter_ != null) { logWriter_.traceExit(this, "getXAResource", xares_); } return xares_; }
Example #12
Source File: TransactionAssistanceXAResource.java From genericconnector with Apache License 2.0 | 5 votes |
@Override public boolean isSameRM(XAResource xares) throws XAException { log.log(Level.FINEST, "isSameRM " + xares); //TODO hmm not sure about this if(xares instanceof TransactionAssistanceXAResource){ TransactionAssistanceXAResource other = (TransactionAssistanceXAResource) xares; if(this.conn.getManagedConnectionFactoryId().equals(other.conn.getManagedConnectionFactoryId())){ return true; } } return false; }
Example #13
Source File: TxLogManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ public boolean isSameRM(XAResource xares) throws XAException { log.tracef("isSameRM(%s)", xares); if (this == xares) return true; return false; }
Example #14
Source File: XAStatementHandler.java From clearpool with GNU General Public License v3.0 | 5 votes |
@Override protected void beforeInvoke(String methodName) throws XAException, SystemException { if (this.needTransaction(methodName)) { Transaction ts = TransactionManagerImpl.getManager().getTransaction(); if (ts != null) { try { XAResource xaRes = this.xaCon.getXAResource(); ts.enlistResource(xaRes); } catch (Exception e) { throw new ConnectionPoolException(e); } } } }
Example #15
Source File: ClientXAConnection.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public XAResource getXAResource() throws SQLException { if (logWriter_ != null) { logWriter_.traceExit(this, "getXAResource", xares_); } return xares_; }
Example #16
Source File: ResourceAdapterImpl.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
@Override public Xid[] recover(int flags) throws StandardException { XAXactId[] ret_xid_list; if ((flags & XAResource.TMSTARTRSCAN) != 0) { XAXactId[] xid_list = new XAXactId[connectionTable.size()]; int num_prepared = 0; // Need to hold sync while linear searching the hash table. synchronized (connectionTable) { int i = 0; for (Enumeration e = connectionTable.elements(); e.hasMoreElements(); i++) { XATransactionState xaTxnState = (XATransactionState)e.nextElement(); if (xaTxnState.isPrepared()) { xid_list[i] = xaTxnState.getXId(); num_prepared++; } } } // now need to squish the nulls out of the array to return. ret_xid_list = new XAXactId[num_prepared]; int ret_index = 0; for (int i = xid_list.length; i-- > 0;) { if (xid_list[i] != null) ret_xid_list[ret_index++] = xid_list[i]; } if (SanityManager.DEBUG) { SanityManager.ASSERT(ret_index == num_prepared); } } else { ret_xid_list = new XAXactId[0]; } return (ret_xid_list); }
Example #17
Source File: BasicXaTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testFailXID() throws Exception { Xid xid = newXID(); ClientSession session = sessionFactory.createSession(true, false, false); session.start(xid, XAResource.TMNOFLAGS); session.end(xid, XAResource.TMFAIL); session.rollback(xid); session.close(); }
Example #18
Source File: TestXAResource.java From FHIR with Apache License 2.0 | 5 votes |
public boolean isSameRM(XAResource xares) throws XAException { log.entering(this.getClass().getName(), methodLabel("isSameRM")); try { return delegate.isSameRM(xares); } finally { log.exiting(this.getClass().getName(), methodLabel("isSameRM")); } }
Example #19
Source File: XATester.java From spanner-jdbc with MIT License | 5 votes |
private void testXATransaction(CloudSpannerXAConnection xaConnection, CommitMode mode) throws SQLException, XAException { log.info("Starting XA simple transaction test"); Connection connection = xaConnection.getConnection(); Xid xid = getRandomXid(); xaConnection.start(xid, XAResource.TMNOFLAGS); String sql = "insert into test (id, uuid, active, amount, description, created_date, last_updated) values (?, ?, ?, ?, ?, ?, ?)"; PreparedStatement statement = connection.prepareStatement(sql); setParameterValues(statement, 1000000); statement.executeUpdate(); xaConnection.end(xid, XAResource.TMSUCCESS); xaConnection.prepare(xid); if (mode != CommitMode.None) { xaConnection.commit(xid, mode == CommitMode.OnePhase); } if (mode != CommitMode.None) { boolean found = false; try (ResultSet rs = connection.createStatement().executeQuery("select * from test where id=1000000")) { if (rs.next()) found = true; } Assert.assertTrue(found); } log.info("Finished XA simple transaction test"); }
Example #20
Source File: CloudSpannerXAConnectionTest.java From spanner-jdbc with MIT License | 5 votes |
@Test public void testCommitTwoPhase() throws SQLException, XAException { CloudSpannerXAConnection subject = createSubject(); Xid xid = createXid(); subject.start(xid, XAResource.TMNOFLAGS); subject.end(xid, XAResource.TMSUCCESS); subject.prepare(xid); subject.commit(xid, false); }
Example #21
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 #22
Source File: XAResourceArchive.java From ByteJTA with GNU Lesser General Public License v3.0 | 5 votes |
public boolean isSameRM(XAResource xares) throws XAException { if (XAResourceArchive.class.isInstance(xares)) { XAResourceArchive archive = (XAResourceArchive) xares; return descriptor.isSameRM(archive.getDescriptor()); } else { return descriptor.isSameRM(xares); } }
Example #23
Source File: DataSourceXAResourceRecoveryHelper.java From narayana-spring-boot with Apache License 2.0 | 5 votes |
@Override public XAResource[] getXAResources() { if (connect()) { return new XAResource[]{ this }; } return NO_XA_RESOURCES; }
Example #24
Source File: GenericRecoveryIT.java From narayana-spring-boot with Apache License 2.0 | 5 votes |
private void setupXaMocks() throws Exception { List<Xid> xids = new LinkedList<>(); // Save Xid provided during prepare when(this.xaResource.prepare(any(Xid.class))) .then(i -> { xids.add((Xid) i.getArguments()[0]); return XAResource.XA_OK; }); // Return Xids when recovering when(this.xaResource.recover(anyInt())) .then(i -> xids.toArray(new Xid[xids.size()])); // Return XAResource when recovering when(this.xaResourceRecoveryHelper.getXAResources()) .thenReturn(new XAResource[]{ this.xaResource }); }
Example #25
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 #26
Source File: JtaTransactionPolicy.java From tomee with Apache License 2.0 | 5 votes |
public void enlistResource(final XAResource xaResource) throws SystemException { final Transaction transaction = getCurrentTransaction(); if (transaction != null) { try { if (transaction.enlistResource(xaResource)) { return; } } catch (final Exception e) { throw new SystemException("Unable to enlist xa resource in the transaction", e); } } throw new SystemException("Unable to enlist xa resource in the transaction"); }
Example #27
Source File: NetXAConnectionReply.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
protected void readXaStartUnitOfWork(NetConnection conn) throws DisconnectException { startSameIdChainParse(); parseSYNCCTLreply(conn); // If we are joining or resuming a global transaction, we let the // server set the transcation isolation state for us. // Otherwise we do a normal reset. NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_]; boolean keep = callInfo.xaFlags_ == XAResource.TMJOIN || callInfo.xaFlags_ == XAResource.TMRESUME; conn.xares_.setKeepCurrentIsolationLevel(keep); endOfSameIdChainData(); }
Example #28
Source File: XAResourceWrapperImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Creates a new wrapper instance. * @param resource xaresource * @param override override * @param productName product name * @param productVersion product version * @param jndiName jndi name */ public XAResourceWrapperImpl(XAResource resource, Boolean override, String productName, String productVersion, String jndiName) { this.xaResource = resource; this.overrideRmValue = override; this.productName = productName; this.productVersion = productVersion; this.jndiName = jndiName; }
Example #29
Source File: TestXAConnection.java From FHIR with Apache License 2.0 | 5 votes |
public XAResource getXAResource() throws SQLException { log.entering(this.getClass().getName(), methodLabel("getXAResource")); try { XAResource resource = delegate.getXAResource(); XAResource result = new TestXAResource(resource, dsLabel, failStep, failCount); return result; } finally { log.exiting(this.getClass().getName(), methodLabel("getXAResource")); } }
Example #30
Source File: JackRabbitUserTransaction.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
/** * Create a new instance of this class. Takes a session as parameter. * @param session session. If session is not of type {@link XAResource}, an * <code>IllegalArgumentException</code> is thrown */ public JackRabbitUserTransaction(Session session) { // if (session instanceof XASession) { // xares = ((XASession) session).getXAResource(); if (session instanceof XAResource) { xares = (XAResource) session; } else { throw new IllegalArgumentException("Session not of type XASession"); } }