@Override public Boolean call() throws Exception { txMgr.rollbackTransaction(txId); return true; }
@DELETE @Path("/{txId}") @Produces(MediaType.TEXT_PLAIN) @ApiOperation(value = "deleteTx: rolls back the specified user Transaction") public Response deleteTx(@PathParam("txId") long txId) { TransactionManagement txMgr = getTxManager(); try { txMgr.rollbackTransaction(txId); return Response.ok().build(); } catch (Exception ex) { logger.error("deleteTx.error", ex); throw new WebApplicationException(ex, Status.INTERNAL_SERVER_ERROR); } }
@Override public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { long txId = (Long) SequenceTool.convertToJava(arguments[0].head()); try { txMgr.rollbackTransaction(txId); return null; } catch (BagriException ex) { throw new XPathException(ex); } } };
@ManagedOperation(description="Rollback in-flight transaction") @ManagedOperationParameters({ @ManagedOperationParameter(name = "txId", description = "Tx identifier")}) public boolean rollbackTransaction(long txId) { try { txMgr.rollbackTransaction(txId); return true; } catch (BagriException ex) { logger.error("rollbackTransaction.error: " + ex.getMessage(), ex); } return false; }
@Override public void rollback() throws XQException { checkState(ex_connection_closed); if (autoCommit) { throw new XQException("The connection is in AutoCommit state, nothing to rollback explicitly.", String.valueOf(ecTransWrongState)); } if (transactional) { try { getTxManager().rollbackTransaction(txId); } catch (BagriException ex) { throw getXQException(ex); } txId = TX_NO; } }
private <V> V executeInTransaction(Callable<V> executor) throws BagriException, XQException { if (autoCommit || txId == TX_NO) { txId = getTxManager().beginTransaction(); } try { V result = executor.call(); if (autoCommit && txId != TX_NO) { getTxManager().commitTransaction(txId); txId = TX_NO; } return result; } catch (Throwable ex) { if (txId != TX_NO) { getTxManager().rollbackTransaction(txId); txId = TX_NO; } if (ex instanceof XQException) { throw (XQException) ex; } if (ex instanceof BagriException) { throw (BagriException) ex; } throw new BagriException(ex, BagriException.ecTransaction); } }