/** * <p> * Calling {@link JBossXATerminator} to cancel the work for us. * <p> * There should not be need any action to be processed by wildfly transaction client. */ @Override public void cancelWork(Work work, Xid xid) { jbossXATerminator.cancelWork(work, xid); }
private XAException initializeSuppressed(final XAException ex, final ImportedTransaction transaction) { if(ex != null && transaction.supportsDeferredThrowables()) { for(Throwable suppressedThrowable: transaction.getDeferredThrowables()) { ex.addSuppressed(suppressedThrowable); } } return ex; } }
protected int getCurrentTransactionTimeout(final EJBComponent component) throws SystemException { final TransactionManager tm = component.getTransactionManager(); if (tm instanceof TransactionTimeoutConfiguration) { return ((TransactionTimeoutConfiguration) tm).getTransactionTimeout(); } return 0; }
if (doNotImport) { imported = false; transaction = ext.getTransaction(xid); final TransactionImportResult result = ext.importTransaction(xid, timeout); transaction = result.getTransaction(); imported = result.isNewImportedTransaction();
JBossLocalTransactionProvider(final ExtendedJBossXATerminator ext, final int staleTransactionTime, final TransactionManager tm, final XAResourceRecoveryRegistry registry, final Path xaRecoveryDirRelativeToPath) { Assert.checkMinimumParameter("setTransactionTimeout", 0, staleTransactionTime); this.staleTransactionTime = staleTransactionTime; this.ext = Assert.checkNotNullParam("ext", ext); this.tm = Assert.checkNotNullParam("tm", tm); try { ext.doRecover(null, null); } catch (Exception e) { // the recover method is called to load transactions from Narayana object store at startup // if it fails we ignore, troubles will be adjusted during runtime Log.log.doRecoverFailureOnIntialization(e); } this.fileSystemXAResourceRegistry = new FileSystemXAResourceRegistry(this, xaRecoveryDirRelativeToPath); registry.addXAResourceRecovery(fileSystemXAResourceRegistry::getInDoubtXAResources); }
final int tpo = importedTransaction.doPrepare(); switch (tpo) { case PREPARE_READONLY: ext.removeImportedTransaction(gtid); return XAResource.XA_RDONLY; importedTransaction.doRollback(); } catch (HeuristicCommitException | HeuristicMixedException | HeuristicRollbackException | SystemException e) { ext.removeImportedTransaction(gtid); ext.removeImportedTransaction(gtid); throw initializeSuppressed(Log.log.resourceManagerErrorXa(XAException.XAER_RMERR, t), importedTransaction);
if (importedTransaction.activated()) try { importedTransaction.doRollback(); } catch (HeuristicCommitException e) { throw Log.log.heuristicCommitXa(XAException.XA_HEURCOM, e); throw Log.log.resourceManagerErrorXa(XAException.XAER_RMERR, e); } finally { ext.removeImportedTransaction(gtid);
final Field field = TransactionManagerLocator.class.getDeclaredField("tm"); field.setAccessible(true); field.set(TransactionManagerLocator.getInstance(), jtaEnvironmentBean.getValue().getTransactionManager()); } catch (IllegalAccessException e) { throw new IllegalAccessError(e.getMessage());
try { if (onePhase) { importedTransaction.doOnePhaseCommit(); } else { if (! importedTransaction.doCommit()) { dropLocal(importedTransaction); ext.doRecover(null, null); throw new XAException(XAException.XA_RETRY);
@Override public XAResourceRecovery get() { Cache<?, ?> cache = this.cache.get(); XAResourceRecovery recovery = new InfinispanXAResourceRecovery(cache); if (cache.getCacheConfiguration().transaction().recovery().enabled()) { this.registry.get().addXAResourceRecovery(recovery); } return recovery; }
public static Transaction importTPC(Object tpc) { return getTPCImporter().importTransactionPropagationContext(tpc); } }
@Override public void accept(XAResourceRecovery recovery) { if (this.cache.get().getCacheConfiguration().transaction().recovery().enabled()) { this.registry.get().removeXAResourceRecovery(recovery); } }
/** * <p> * Interception of register work call to get transaction being imported to wildfly transacton client. * <p> * For importing a transaction Wildfly transaction client eventually calls {@link SubordinationManager} * as Narayana {@link XATerminator}s do. This wrapping then let wildfly transacton client to register the transaction * for itself, wildfly transacton client then import transaction to Narayana too and finally this method * uses Narayana's {@link XATerminator} to register all {@link Work}s binding.<br> * Narayana's {@link XATerminator} tries to import transaction too but as transaction is already * imported it just gets instance of transaction already imported via call of wildfly transacton client. */ @Override public void registerWork(Work work, Xid xid, long timeout) throws WorkCompletedException { try { // jca provides timeout in milliseconds, SubordinationManager expects seconds int timeout_seconds = (int) timeout/1000; // unlimited timeout for jca means -1 which fails in wfly client if(timeout_seconds <= 0) timeout_seconds = ContextTransactionManager.getGlobalDefaultTransactionTimeout(); localTransactionContext.findOrImportTransaction(xid, timeout_seconds); } catch (XAException xae) { throw TransactionLogger.ROOT_LOGGER.cannotFindOrImportInflowTransaction(xid, work, xae); } jbossXATerminator.registerWork(work, xid, timeout); }
public void forget() throws XAException { final Transaction transaction = this.transaction; if (! (transaction instanceof ImportedTransaction)) { throw Log.log.notImportedXa(XAException.XAER_NOTA); } final ImportedTransaction importedTransaction = (ImportedTransaction) transaction; try { importedTransaction.doForget(); } catch (IllegalStateException e) { throw Log.log.illegalStateXa(XAException.XAER_NOTA, e); } catch (Throwable /* RuntimeException | SystemException */ e) { throw Log.log.resourceManagerErrorXa(XAException.XAER_RMERR, e); } }
@NotNull public Xid[] recover(final int flag, final String parentNodeName) throws XAException { try { try { final Xid[] xids = ext.doRecover(null, parentNodeName); return xids == null ? SimpleXid.NO_XIDS : xids; } catch (NotSupportedException e) { throw new XAException(XAException.XAER_RMFAIL); } } catch (XAException e) { throw e; } catch (Throwable t) { throw Log.log.resourceManagerErrorXa(XAException.XAER_RMFAIL, t); } } }
public void beforeCompletion() throws XAException { final Transaction transaction = this.transaction; if (! (transaction instanceof ImportedTransaction)) { throw Log.log.notImportedXa(XAException.XAER_NOTA); } final ImportedTransaction importedTransaction = (ImportedTransaction) transaction; try { if (! importedTransaction.doBeforeCompletion()) { throw new XAException(XAException.XAER_RMERR); } } catch (IllegalStateException e) { throw Log.log.illegalStateXa(XAException.XAER_NOTA, e); } catch (Throwable /* RuntimeException | SystemException */ e) { throw Log.log.resourceManagerErrorXa(XAException.XAER_RMERR, e); } }
public Transaction findExistingTransaction(final Xid xid) throws XAException { try { final SimpleXid simpleXid = SimpleXid.of(xid); final SimpleXid gtid = simpleXid.withoutBranch(); final ConcurrentMap<SimpleXid, Entry> known = JBossLocalTransactionProvider.this.known; Entry entry = known.get(gtid); if (entry != null) { return entry.getTransaction(); } final Transaction transaction = ext.getTransaction(xid); if (transaction == null) { return null; } return known.computeIfAbsent(gtid, g -> getEntryFor(transaction, g)).getTransaction(); } catch (XAException e) { throw e; } catch (Throwable t) { throw Log.log.resourceManagerErrorXa(XAException.XAER_RMFAIL, t); } }
int getTransactionManagerTimeout() throws SystemException { final TransactionManager tm = getTransactionManager(); if (tm instanceof TransactionTimeoutConfiguration) { return ((TransactionTimeoutConfiguration) tm).getTransactionTimeout(); } else if (tm instanceof TransactionManagerImple) { return ((TransactionManagerImple) tm).getTimeout(); } else { return 0; } }
/** * <p> * Suspending transaction and canceling the work. * <p> * Suspend transaction has to be called on the wildfly transaction manager * and the we delegate work cancellation to {@link JBossXATerminator}.<br> * First we have to cancel the work for jboss terminator would not work with * suspended transaction. */ @Override public void endWork(Work work, Xid xid) { jbossXATerminator.cancelWork(work, xid); try { ContextTransactionManager.getInstance().suspend(); } catch (SystemException se) { throw TransactionLogger.ROOT_LOGGER.cannotSuspendInflowTransactionUnexpectedError(work, se); } }
int getTransactionManagerTimeout() throws SystemException { final TransactionManager tm = getTransactionManager(); if (tm instanceof TransactionTimeoutConfiguration) { return ((TransactionTimeoutConfiguration) tm).getTransactionTimeout(); } else if (tm instanceof TransactionManagerImple) { return ((TransactionManagerImple) tm).getTimeout(); } else { return 0; } }