public void rollbackTransaction(AbstractTransactionContext context) throws ResourceManagerException { assureReady(); synchronized (context) { if (logger.isDebugEnabled()) { logger.debug("Rolling back transaction " + context); } try { context.status = Status.STATUS_ROLLING_BACK; doRollback(context); context.status = Status.STATUS_ROLLEDBACK; } catch (Error e) { setDirty(context, e); throw e; } catch (RuntimeException e) { setDirty(context, e); throw e; } catch (ResourceManagerSystemException e) { setDirty(context, e); throw e; } finally { globalTransactions.remove(context); context.finalCleanUp(); // tell shutdown thread this tx is finished context.notifyFinish(); } if (logger.isDebugEnabled()) { logger.debug("Rolled back transaction " + context); } } }
public int prepareTransaction(AbstractTransactionContext context) throws ResourceManagerException { assureReady(); synchronized (context) { if (logger.isDebugEnabled()) { logger.debug("Preparing transaction " + context); } context.status = Status.STATUS_PREPARING; int status = doPrepare(context); context.status = Status.STATUS_PREPARED; if (logger.isDebugEnabled()) { logger.debug("Prepared transaction " + context); } return status; } }
public void commitTransaction(AbstractTransactionContext context) throws ResourceManagerException { assureReady(); if (context.status == Status.STATUS_MARKED_ROLLBACK) { throw new ResourceManagerException(new Message(Messages.TX_MARKED_FOR_ROLLBACK)); } synchronized (context) { if (logger.isDebugEnabled()) { logger.debug("Committing transaction " + context); } try { context.status = Status.STATUS_COMMITTING; doCommit(context); context.status = Status.STATUS_COMMITTED; } catch (Error e) { setDirty(context, e); throw e; } catch (RuntimeException e) { setDirty(context, e); throw e; } catch (ResourceManagerSystemException e) { setDirty(context, e); throw e; } catch (ResourceManagerException e) { logger.warn("Could not commit tx " + context + ", rolling back instead", e); doRollback(context); } finally { globalTransactions.remove(context); context.finalCleanUp(); // tell shutdown thread this tx is finished context.notifyFinish(); } if (logger.isDebugEnabled()) { logger.debug("Committed transaction " + context); } } }
public void beginTransaction(AbstractTransactionContext context) throws ResourceManagerException { assureStarted(); // can only start a new transaction when not already // stopping synchronized (context) { if (logger.isDebugEnabled()) { logger.debug("Beginning transaction " + context); } doBegin(context); context.status = Status.STATUS_ACTIVE; if (logger.isDebugEnabled()) { logger.debug("Begun transaction " + context); } } globalTransactions.add(context); }
public void setTransactionRollbackOnly(AbstractTransactionContext context) throws ResourceManagerException { context.status = Status.STATUS_MARKED_ROLLBACK; }