@Override protected void handleImpl(HttpServerExchange exchange, ImportResult<LocalTransaction> transaction) throws Exception { transaction.getTransaction().rollback(); } }
/** * Get a copy of this import result, with a new transaction object. * * @param transaction the transaction object (must not be {@code null}) * @param <S> the new transaction type * @return the new import result (not {@code null}) */ public <S extends Transaction> ImportResult<S> withTransaction(S transaction) { return new ImportResult<S>(Assert.checkNotNullParam("transaction", transaction), control, isNew); } }
@Override protected void handleImpl(HttpServerExchange exchange, ImportResult<LocalTransaction> transaction) throws Exception { transaction.getControl().rollback(); } }
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(); }
/** * 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)); }
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) {
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(); }
/** * 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)); }
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().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(); }
/** * 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)); }
@Override protected void handleImpl(HttpServerExchange exchange, ImportResult<LocalTransaction> transaction) throws Exception { transaction.getControl().beforeCompletion(); } }
Entry entry = known.get(gtid); if (entry != null) { return new ImportResult<Transaction>(entry.getTransaction(), entry, false); if (appearing != null) { return new ImportResult<Transaction>(transaction, appearing, imported); } else { return new ImportResult<Transaction>(transaction, entry, imported);
importResult.getTransaction().performConsumer(SubordinateTransactionControl::rollback, importResult.getControl()); writeSimpleResponse(M_RESP_XA_ROLLBACK, i); } catch (SystemException e) {
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; } }
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(); }
@Override protected void handleImpl(HttpServerExchange exchange, ImportResult<LocalTransaction> transaction) throws Exception { transaction.getControl().prepare(); } }
ExceptionSupplier<ImportResult<?>, SystemException> readTransaction(final DataInput input) throws IOException { final int type = input.readUnsignedByte(); if (type == 0) { return null; } else if (type == 1) { // remote user transaction final int id = input.readInt(); final int timeout = PackedInteger.readPackedInteger(input); return () -> new ImportResult<Transaction>(transactionServer.getOrBeginTransaction(id, timeout), SubordinateTransactionControl.EMPTY, false); } else if (type == 2) { final int fmt = PackedInteger.readPackedInteger(input); final byte[] gtid = new byte[input.readUnsignedByte()]; input.readFully(gtid); final byte[] bq = new byte[input.readUnsignedByte()]; input.readFully(bq); final int timeout = PackedInteger.readPackedInteger(input); return () -> { try { return transactionServer.getTransactionService().getTransactionContext().findOrImportTransaction(new SimpleXid(fmt, gtid, bq), timeout); } catch (XAException e) { throw new SystemException(e.getMessage()); } }; } else { throw Logs.REMOTING.invalidTransactionType(type); } }