List of usage examples for javax.transaction Status STATUS_MARKED_ROLLBACK
int STATUS_MARKED_ROLLBACK
To view the source code for javax.transaction Status STATUS_MARKED_ROLLBACK.
Click Source Link
From source file:org.j2free.jpa.Controller.java
/** * //from www .j a va 2 s . c o m * @return * @throws SystemException */ public String getTransactionStatus() throws SystemException { if (tx == null) { return "Null transaction"; } switch (tx.getStatus()) { case Status.STATUS_ACTIVE: return "Active"; case Status.STATUS_COMMITTED: return "Committed"; case Status.STATUS_COMMITTING: return "Committing"; case Status.STATUS_MARKED_ROLLBACK: return "Marked for rollback"; case Status.STATUS_NO_TRANSACTION: return "No Transaction"; case Status.STATUS_PREPARED: return "Prepared"; case Status.STATUS_ROLLEDBACK: return "Rolledback"; case Status.STATUS_ROLLING_BACK: return "Rolling back"; case Status.STATUS_UNKNOWN: return "Declared Unknown"; default: return "Undeclared Unknown Status"; } }
From source file:org.mule.util.xa.AbstractResourceManager.java
public void setTransactionRollbackOnly(AbstractTransactionContext context) throws ResourceManagerException { context.status = Status.STATUS_MARKED_ROLLBACK; }
From source file:org.mule.util.xa.AbstractResourceManager.java
public void commitTransaction(AbstractTransactionContext context) throws ResourceManagerException { assureReady();//from w ww. j av a 2s . c o m if (context.status == Status.STATUS_MARKED_ROLLBACK) { throw new ResourceManagerException(CoreMessages.transactionMarkedForRollback()); } 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); } } }
From source file:org.mule.util.xa.DefaultXASession.java
public void commit(Xid xid, boolean onePhase) throws XAException { if (xid == null) { throw new XAException(XAException.XAER_PROTO); }/* ww w . ja va2 s. c o m*/ AbstractTransactionContext context = resourceManager.getActiveTransactionalResource(xid); if (context == null) { throw new XAException(XAException.XAER_NOTA); } if (logger.isDebugEnabled()) { logger.debug("Committing transaction branch " + xid); } if (context.status == Status.STATUS_MARKED_ROLLBACK) { throw new XAException(XAException.XA_RBROLLBACK); } try { if (context.status != Status.STATUS_PREPARED) { if (onePhase) { resourceManager.prepareTransaction(context); } else { throw new XAException(XAException.XAER_PROTO); } } resourceManager.commitTransaction(context); } catch (ResourceManagerException e) { throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e); } resourceManager.removeActiveTransactionalResource(xid); resourceManager.removeSuspendedTransactionalResource(xid); }
From source file:org.mule.util.xa.DefaultXASession.java
public int prepare(Xid xid) throws XAException { if (xid == null) { throw new XAException(XAException.XAER_PROTO); }/*ww w .ja v a2 s . c o m*/ AbstractTransactionContext context = resourceManager.getTransactionalResource(xid); if (context == null) { throw new XAException(XAException.XAER_NOTA); } if (logger.isDebugEnabled()) { logger.debug("Preparing transaction branch " + xid); } if (context.status == Status.STATUS_MARKED_ROLLBACK) { throw new XAException(XAException.XA_RBROLLBACK); } try { return resourceManager.prepareTransaction(context); } catch (ResourceManagerException e) { throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e); } }
From source file:org.nuxeo.ecm.core.storage.dbs.DBSRepositoryBase.java
@Override public Session getSession() { Transaction transaction;/* www .ja va2 s . c o m*/ try { transaction = TransactionHelper.lookupTransactionManager().getTransaction(); if (transaction == null) { throw new NuxeoException("Missing transaction"); } int status = transaction.getStatus(); if (status != Status.STATUS_ACTIVE && status != Status.STATUS_MARKED_ROLLBACK) { throw new NuxeoException("Transaction in invalid state: " + status); } } catch (SystemException | NamingException e) { throw new NuxeoException("Failed to get transaction", e); } TransactionContext context = transactionContexts.get(transaction); if (context == null) { context = new TransactionContext(transaction, newSession()); context.init(); } return context.newSession(); }
From source file:org.nuxeo.elasticsearch.listener.ElasticSearchInlineListener.java
@Override public void afterCompletion(int status) { if (getAllCommands().isEmpty()) { return;//from w w w. j a va2 s. c o m } try { if (Status.STATUS_MARKED_ROLLBACK == status || Status.STATUS_ROLLEDBACK == status) { return; } List<IndexingCommand> commandList = new ArrayList<>(); for (IndexingCommands cmds : getAllCommands().values()) { for (IndexingCommand cmd : cmds.getCommands()) { commandList.add(cmd); } } ElasticSearchIndexing esi = Framework.getLocalService(ElasticSearchIndexing.class); esi.runIndexingWorker(commandList); } finally { isEnlisted.set(false); getAllCommands().clear(); useSyncIndexing.set(null); } }
From source file:org.nuxeo.runtime.transaction.TransactionHelper.java
/** * Checks if the current User Transaction is marked rollback only. *//* ww w .j a va 2 s.co m*/ public static boolean isTransactionMarkedRollback() { int status = getTransactionStatus(); return status == Status.STATUS_MARKED_ROLLBACK; }
From source file:org.nuxeo.runtime.transaction.TransactionHelper.java
/** * Checks if the current User Transaction is active or marked rollback only. */// w w w . ja va2 s .c o m public static boolean isTransactionActiveOrMarkedRollback() { int status = getTransactionStatus(); return status == Status.STATUS_ACTIVE || status == Status.STATUS_MARKED_ROLLBACK; }
From source file:org.nuxeo.runtime.transaction.TransactionHelper.java
/** * Commits or rolls back the User Transaction depending on the transaction status. *//*from w w w. jav a2 s .c om*/ public static void commitOrRollbackTransaction() { UserTransaction ut = NuxeoContainer.getUserTransaction(); if (ut == null) { return; } try { int status = ut.getStatus(); if (status == Status.STATUS_ACTIVE) { if (log.isDebugEnabled()) { log.debug("Commiting transaction"); } ut.commit(); } else if (status == Status.STATUS_MARKED_ROLLBACK) { if (log.isDebugEnabled()) { log.debug("Cannot commit transaction because it is marked rollback only"); } ut.rollback(); } else { if (log.isDebugEnabled()) { log.debug("Cannot commit transaction with unknown status: " + status); } } } catch (SystemException | RollbackException | HeuristicMixedException | HeuristicRollbackException | IllegalStateException | SecurityException e) { String msg = "Unable to commit/rollback"; String message = e.getMessage(); if (e instanceof RollbackException) { switch (message) { case "Unable to commit: transaction marked for rollback": // don't log as error, this happens if there's a ConcurrentModificationException // at transaction end inside VCS case "Unable to commit: Transaction timeout": // don't log either log.debug(msg, e); break; default: log.error(msg, e); } } else { log.error(msg, e); } throw new TransactionRuntimeException(msg + ": " + message, e); } }