@Override protected void handleImpl(HttpServerExchange exchange, ImportResult<LocalTransaction> transaction) throws Exception { transaction.getTransaction().rollback(); } }
@Override protected void handleImpl(HttpServerExchange exchange, ImportResult<LocalTransaction> transaction) throws Exception { transaction.getTransaction().commit(); } }
public Transaction getTransaction() throws SystemException, IllegalStateException { if (finalTransactionSupplier == null) { return null; } if (txnCmd != 0) { throw new IllegalStateException(); } final ImportResult<?> importResult = finalTransactionSupplier.get(); if (importResult.isNew()) { txnCmd = 1; } else { txnCmd = 2; } return importResult.getTransaction(); }
public Transaction getTransaction() throws SystemException, IllegalStateException { final ExceptionSupplier<ImportResult<?>, SystemException> transactionSupplier = this.transactionSupplier; if (transactionSupplier == null) { return null; } if (txnCmd != 0) { throw new IllegalStateException(); } final ImportResult<?> importResult = transactionSupplier.get(); if (importResult.isNew()) { txnCmd = 1; } else { txnCmd = 2; } return importResult.getTransaction(); }
private ImportResult<LocalTransaction> getImportedTransaction(final Xid xid) throws XAException { final ImportResult<LocalTransaction> result = transactionContext.findOrImportTransaction(xid, 0, true); if (result == null) { throw Log.log.noTransactionXa(XAException.XAER_NOTA); } final LocalTransaction transaction = result.getTransaction(); if (! transaction.isImported()) { throw Log.log.noTransactionXa(XAException.XAER_NOTA); } return result; } }
/** * <p> * Start work gets imported transaction and assign it to current thread. * <p> * This method mimics behavior of Narayana's {@link JBossXATerminator}. */ @Override public void startWork(Work work, Xid xid) throws WorkCompletedException { LocalTransaction transaction = null; try { ImportResult<LocalTransaction> transactionImportResult = localTransactionContext.findOrImportTransaction(xid, 0); transaction = transactionImportResult.getTransaction(); ContextTransactionManager.getInstance().resume(transaction); } catch (XAException xae) { throw TransactionLogger.ROOT_LOGGER.cannotFindOrImportInflowTransaction(xid, work, xae); } catch (InvalidTransactionException ite) { throw TransactionLogger.ROOT_LOGGER.importedInflowTransactionIsInactive(xid, work, ite); } catch (SystemException se) { throw TransactionLogger.ROOT_LOGGER.cannotResumeInflowTransactionUnexpectedError(transaction, work, se); } }
/** * Attempt to import a transaction, which subsequently may be controlled by its XID or by the returned handle. * * @param xid the XID of the transaction to import (must not be {@code null}) * @param timeout the transaction timeout to use, if new * @param doNotImport {@code true} to indicate that a non-existing transaction should not be imported, {@code false} otherwise * @return the transaction import result, or {@code null} if (and only if) {@code doNotImport} is {@code true} and the transaction didn't exist locally * @throws XAException if a problem occurred while importing the transaction */ public ImportResult<LocalTransaction> findOrImportTransaction(Xid xid, int timeout, boolean doNotImport) throws XAException { Assert.checkNotNullParam("xid", xid); Assert.checkMinimumParameter("timeout", 0, timeout); XAImporter xaImporter = provider.getXAImporter(); final boolean requestsSuspended = this.requestsSuspended; final ImportResult<?> result = xaImporter.findOrImportTransaction(xid, timeout, doNotImport || requestsSuspended); if (result == null) { if (! doNotImport) { if (requestsSuspended) { throw Log.log.suspendedCannotImportXa(XAException.XAER_RMERR); } throw Log.log.providerCreatedNullTransaction(); } return null; } return result.withTransaction(getOrAttach(result.getTransaction(), result.isNew() ? CreationListener.CreatedBy.IMPORT : CreationListener.CreatedBy.MERGE)); }
try { ImportResult<LocalTransaction> result = localTransactionContext.findOrImportTransaction(txConfig.getXid(), txConfig.getRemainingTime()); transaction = result.getTransaction(); } catch (XAException e) { throw new IllegalStateException(e); //TODO: what to do here?
@Override public final void handleRequest(HttpServerExchange exchange) throws Exception { ContentType contentType = ContentType.parse(exchange.getRequestHeaders().getFirst(Headers.CONTENT_TYPE)); if (contentType == null || contentType.getVersion() != 1 || !contentType.getType().equals(TransactionConstants.XID)) { exchange.setStatusCode(StatusCodes.BAD_REQUEST); HttpRemoteTransactionMessages.MESSAGES.debugf("Exchange %s has incorrect or missing content type", exchange); return; } try { Unmarshaller unmarshaller = MARSHALLER_FACTORY.createUnmarshaller(createMarshallingConf()); unmarshaller.start(new InputStreamByteInput(exchange.getInputStream())); int formatId = unmarshaller.readInt(); int len = unmarshaller.readInt(); byte[] globalId = new byte[len]; unmarshaller.readFully(globalId); len = unmarshaller.readInt(); byte[] branchId = new byte[len]; unmarshaller.readFully(branchId); SimpleXid simpleXid = new SimpleXid(formatId, globalId, branchId); unmarshaller.finish(); ImportResult<LocalTransaction> transaction = transactionContext.findOrImportTransaction(simpleXid, 0); transaction.getTransaction().performFunction((ExceptionBiFunction<ImportResult<LocalTransaction>, HttpServerExchange, Void, Exception>) (o, exchange2) -> { handleImpl(exchange2, o); return null; }, transaction, exchange); } catch (Exception e) { sendException(exchange, StatusCodes.INTERNAL_SERVER_ERROR, e); } }
importResult.getTransaction().performConsumer(SubordinateTransactionControl::beforeCompletion, importResult.getControl()); writeSimpleResponse(M_RESP_XA_BEFORE, i); } catch (SystemException e) {
importResult.getTransaction().performConsumer(SubordinateTransactionControl::rollback, importResult.getControl()); writeSimpleResponse(M_RESP_XA_ROLLBACK, i); } catch (SystemException e) {
int result = ! importResult.getTransaction().isImported() ? XAResource.XA_RDONLY : importResult.getControl().prepare(); if (result == XAResource.XA_RDONLY) { writeSimpleResponse(M_RESP_XA_PREPARE, i, P_XA_RDONLY);
@Override protected void handleImpl(HttpServerExchange exchange, ImportResult<LocalTransaction> transaction) throws Exception { transaction.getTransaction().rollback(); } }
@Override protected void handleImpl(HttpServerExchange exchange, ImportResult<LocalTransaction> transaction) throws Exception { transaction.getTransaction().commit(); } }
public Transaction getTransaction() throws SystemException, IllegalStateException { if (finalTransactionSupplier == null) { return null; } if (txnCmd != 0) { throw new IllegalStateException(); } final ImportResult<?> importResult = finalTransactionSupplier.get(); if (importResult.isNew()) { txnCmd = 1; } else { txnCmd = 2; } return importResult.getTransaction(); }
public Transaction getTransaction() throws SystemException, IllegalStateException { if (finalTransactionSupplier == null) { return null; } if (txnCmd != 0) { throw new IllegalStateException(); } final ImportResult<?> importResult = finalTransactionSupplier.get(); if (importResult.isNew()) { txnCmd = 1; } else { txnCmd = 2; } return importResult.getTransaction(); }
public Transaction getTransaction() throws SystemException, IllegalStateException { final ExceptionSupplier<ImportResult<?>, SystemException> transactionSupplier = this.transactionSupplier; if (transactionSupplier == null) { return null; } if (txnCmd != 0) { throw new IllegalStateException(); } final ImportResult<?> importResult = transactionSupplier.get(); if (importResult.isNew()) { txnCmd = 1; } else { txnCmd = 2; } return importResult.getTransaction(); }
public Transaction getTransaction() throws SystemException, IllegalStateException { final ExceptionSupplier<ImportResult<?>, SystemException> transactionSupplier = this.transactionSupplier; if (transactionSupplier == null) { return null; } if (txnCmd != 0) { throw new IllegalStateException(); } final ImportResult<?> importResult = transactionSupplier.get(); if (importResult.isNew()) { txnCmd = 1; } else { txnCmd = 2; } return importResult.getTransaction(); }
private ImportResult<LocalTransaction> getImportedTransaction(final Xid xid) throws XAException { final ImportResult<LocalTransaction> result = transactionContext.findOrImportTransaction(xid, 0, true); if (result == null) { throw Log.log.noTransactionXa(XAException.XAER_NOTA); } final LocalTransaction transaction = result.getTransaction(); if (! transaction.isImported()) { throw Log.log.noTransactionXa(XAException.XAER_NOTA); } return result; } }
private ImportResult<LocalTransaction> getImportedTransaction(final Xid xid) throws XAException { final ImportResult<LocalTransaction> result = transactionContext.findOrImportTransaction(xid, 0, true); if (result == null) { throw Log.log.noTransactionXa(XAException.XAER_NOTA); } final LocalTransaction transaction = result.getTransaction(); if (! transaction.isImported()) { throw Log.log.noTransactionXa(XAException.XAER_NOTA); } return result; } }