List of usage examples for javax.transaction Status STATUS_ROLLING_BACK
int STATUS_ROLLING_BACK
To view the source code for javax.transaction Status STATUS_ROLLING_BACK.
Click Source Link
From source file:org.apache.ofbiz.entity.transaction.TransactionUtil.java
public static String getTransactionStateString(int state) { /*//from w ww. j a v a2 s .com * javax.transaction.Status * STATUS_ACTIVE 0 * STATUS_MARKED_ROLLBACK 1 * STATUS_PREPARED 2 * STATUS_COMMITTED 3 * STATUS_ROLLEDBACK 4 * STATUS_UNKNOWN 5 * STATUS_NO_TRANSACTION 6 * STATUS_PREPARING 7 * STATUS_COMMITTING 8 * STATUS_ROLLING_BACK 9 */ switch (state) { case Status.STATUS_ACTIVE: return "Transaction Active (" + state + ")"; case Status.STATUS_COMMITTED: return "Transaction Committed (" + state + ")"; case Status.STATUS_COMMITTING: return "Transaction Committing (" + state + ")"; case Status.STATUS_MARKED_ROLLBACK: return "Transaction Marked Rollback (" + state + ")"; case Status.STATUS_NO_TRANSACTION: return "No Transaction (" + state + ")"; case Status.STATUS_PREPARED: return "Transaction Prepared (" + state + ")"; case Status.STATUS_PREPARING: return "Transaction Preparing (" + state + ")"; case Status.STATUS_ROLLEDBACK: return "Transaction Rolledback (" + state + ")"; case Status.STATUS_ROLLING_BACK: return "Transaction Rolling Back (" + state + ")"; case Status.STATUS_UNKNOWN: return "Transaction Status Unknown (" + state + ")"; default: return "Not a valid state code (" + state + ")"; } }
From source file:org.apache.ojb.odmg.JTATxManager.java
private static String getStatusString(int status) { switch (status) { case Status.STATUS_ACTIVE: return "STATUS_ACTIVE"; case Status.STATUS_COMMITTED: return "STATUS_COMMITTED"; case Status.STATUS_COMMITTING: return "STATUS_COMMITTING"; case Status.STATUS_MARKED_ROLLBACK: return "STATUS_MARKED_ROLLBACK"; case Status.STATUS_NO_TRANSACTION: return "STATUS_NO_TRANSACTION"; case Status.STATUS_PREPARED: return "STATUS_PREPARED"; case Status.STATUS_PREPARING: return "STATUS_PREPARING"; case Status.STATUS_ROLLEDBACK: return "STATUS_ROLLEDBACK"; case Status.STATUS_ROLLING_BACK: return "STATUS_ROLLING_BACK"; case Status.STATUS_UNKNOWN: return "STATUS_UNKNOWN"; default://from w w w . j av a2 s . co m return "NO STATUS FOUND"; } }
From source file:org.bytesoft.bytejta.TransactionRecoveryImpl.java
private void recoverCoordinator(Transaction transaction) throws CommitRequiredException, RollbackRequiredException, SystemException { switch (transaction.getTransactionStatus()) { case Status.STATUS_ACTIVE: case Status.STATUS_MARKED_ROLLBACK: case Status.STATUS_PREPARING: case Status.STATUS_ROLLING_BACK: case Status.STATUS_UNKNOWN: transaction.recoveryRollback();//from w ww . jav a2 s . co m transaction.forgetQuietly(); break; case Status.STATUS_PREPARED: case Status.STATUS_COMMITTING: transaction.recoveryCommit(); transaction.forgetQuietly(); break; case Status.STATUS_COMMITTED: case Status.STATUS_ROLLEDBACK: transaction.forgetQuietly(); break; default: logger.debug("Current transaction has already been completed."); } }
From source file:org.bytesoft.bytejta.TransactionRecoveryImpl.java
private void recoverParticipant(Transaction transaction) throws CommitRequiredException, RollbackRequiredException, SystemException { TransactionImpl transactionImpl = (TransactionImpl) transaction; switch (transaction.getTransactionStatus()) { case Status.STATUS_PREPARED: case Status.STATUS_COMMITTING: break;/*from www . j a va2 s . com*/ case Status.STATUS_COMMITTED: case Status.STATUS_ROLLEDBACK: break; case Status.STATUS_ACTIVE: case Status.STATUS_MARKED_ROLLBACK: case Status.STATUS_PREPARING: case Status.STATUS_UNKNOWN: case Status.STATUS_ROLLING_BACK: default: transactionImpl.recoveryRollback(); transactionImpl.forgetQuietly(); } }
From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java
public synchronized void rollback() throws IllegalStateException, SystemException { CompensableLogger compensableLogger = this.beanFactory.getCompensableLogger(); this.transactionStatus = Status.STATUS_ROLLING_BACK; this.transactionContext.setCompensating(true); compensableLogger.updateTransaction(this.getTransactionArchive()); boolean coordinator = this.transactionContext.isCoordinator(); boolean coordinatorTried = false; for (int i = 0; coordinator && i < this.archiveList.size(); i++) { CompensableArchive compensableArchive = this.archiveList.get(i); coordinatorTried = compensableArchive.isTried() ? true : coordinatorTried; }/*from w ww . java 2 s. c o m*/ SystemException systemEx = null; if (coordinator == false || coordinatorTried) { try { this.fireNativeParticipantCancel(); } catch (SystemException ex) { systemEx = ex; logger.info("{}| cancel native branchs failed!", ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex); } catch (RuntimeException ex) { systemEx = new SystemException(ex.getMessage()); logger.info("{}| cancel native branchs failed!", ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex); } } try { this.fireRemoteParticipantCancel(); } catch (SystemException ex) { logger.info("{}| cancel remote branchs failed!", ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex); throw ex; } catch (RuntimeException ex) { logger.info("{}| cancel remote branchs failed!", ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex); throw new SystemException(ex.getMessage()); } if (systemEx != null) { throw systemEx; } else { this.transactionStatus = Status.STATUS_ROLLEDBACK; compensableLogger.updateTransaction(this.getTransactionArchive()); logger.info("{}| compensable transaction rolled back!", ByteUtils.byteArrayToString(transactionContext.getXid().getGlobalTransactionId())); } }
From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java
public synchronized void recoveryRollback() throws RollbackRequiredException, SystemException { CompensableLogger compensableLogger = this.beanFactory.getCompensableLogger(); this.transactionStatus = Status.STATUS_ROLLING_BACK; this.transactionContext.setCompensating(true); compensableLogger.updateTransaction(this.getTransactionArchive()); SystemException systemEx = null; try {/*from w w w . jav a2 s .c o m*/ this.fireNativeParticipantRecoveryCancel(); } catch (SystemException ex) { systemEx = ex; logger.info("{}| recovery-cancel native branchs failed!", ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex); } catch (RuntimeException ex) { systemEx = new SystemException(ex.getMessage()); logger.info("{}| recovery-cancel native branchs failed!", ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex); } try { this.fireRemoteParticipantRecoveryCancel(); } catch (SystemException ex) { logger.info("{}| recovery-cancel remote branchs failed!", ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex); throw ex; } catch (RuntimeException ex) { logger.info("{}| recovery-cancel remote branchs failed!", ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex); throw new SystemException(ex.getMessage()); } if (systemEx != null) { throw systemEx; } else { this.transactionStatus = Status.STATUS_ROLLEDBACK; compensableLogger.updateTransaction(this.getTransactionArchive()); logger.info("{}| compensable transaction recovery rolled back!", ByteUtils.byteArrayToString(transactionContext.getXid().getGlobalTransactionId())); } }
From source file:org.bytesoft.bytetcc.TransactionRecoveryImpl.java
private void recoverStatusIfNecessary(Transaction transaction) { CompensableTransactionImpl compensable = (CompensableTransactionImpl) transaction; List<CompensableArchive> archiveList = compensable.getCompensableArchiveList(); XAResourceDeserializer resourceDeserializer = this.beanFactory.getResourceDeserializer(); CompensableLogger compensableLogger = this.beanFactory.getCompensableLogger(); Map<TransactionBranchKey, Boolean> triedMap = new HashMap<TransactionBranchKey, Boolean>(); for (int i = 0; i < archiveList.size(); i++) { CompensableArchive archive = archiveList.get(i); if (archive.isTried()) { switch (transaction.getTransactionStatus()) { case Status.STATUS_ACTIVE: case Status.STATUS_MARKED_ROLLBACK: case Status.STATUS_PREPARING: case Status.STATUS_ROLLING_BACK: case Status.STATUS_UNKNOWN: transaction.setTransactionStatus(Status.STATUS_PREPARED); transaction.getTransactionContext().setCompensating(true); compensableLogger.updateTransaction(compensable.getTransactionArchive()); break; case Status.STATUS_PREPARED: case Status.STATUS_COMMITTING: case Status.STATUS_COMMITTED: case Status.STATUS_ROLLEDBACK: default: // ignore }//from w w w. java 2 s . c o m } else { Xid transactionXid = archive.getTransactionXid(); String resourceKey = archive.getTransactionResourceKey(); TransactionBranchKey recordKey = new TransactionBranchKey(); recordKey.xid = transactionXid; recordKey.resource = resourceKey; if (StringUtils.isBlank(resourceKey)) { logger.warn( "There is no valid resource participated in the trying branch transaction, the status of the branch transaction is unknown!"); } else if (triedMap.containsKey(recordKey)) { Boolean tried = triedMap.get(recordKey); if (Boolean.TRUE.equals(tried)) { transaction.setTransactionStatus(Status.STATUS_COMMITTING); // TODO } else { transaction.setTransactionStatus(Status.STATUS_MARKED_ROLLBACK); } transaction.getTransactionContext().setCompensating(true); compensableLogger.updateTransaction(compensable.getTransactionArchive()); } else { XAResource xares = resourceDeserializer.deserialize(resourceKey); if (RecoveredResource.class.isInstance(xares)) { RecoveredResource resource = (RecoveredResource) xares; try { resource.recoverable(archive.getTransactionXid()); archive.setTried(true); triedMap.put(recordKey, Boolean.TRUE); transaction.setTransactionStatus(Status.STATUS_COMMITTING); // TODO transaction.getTransactionContext().setCompensating(true); compensableLogger.updateTransaction(compensable.getTransactionArchive()); } catch (XAException xaex) { switch (xaex.errorCode) { case XAException.XAER_NOTA: triedMap.put(recordKey, Boolean.FALSE); transaction.setTransactionStatus(Status.STATUS_MARKED_ROLLBACK); transaction.getTransactionContext().setCompensating(true); compensableLogger.updateTransaction(compensable.getTransactionArchive()); break; case XAException.XAER_RMERR: logger.warn( "The database table 'bytejta' cannot found, the status of the trying branch transaction is unknown!"); break; case XAException.XAER_RMFAIL: logger.error("Error occurred while recovering the branch transaction service: {}", ByteUtils.byteArrayToString(transactionXid.getGlobalTransactionId()), xaex); break; default: logger.error( "Illegal state, the status of the trying branch transaction is unknown!"); } } } else { logger.error("Illegal resources, the status of the trying branch transaction is unknown!"); } } } // end-else-if (archive.isTried()) } // end-for }
From source file:org.bytesoft.bytetcc.TransactionRecoveryImpl.java
public synchronized void recoverCoordinator(Transaction transaction) throws CommitRequiredException, RollbackRequiredException, SystemException { switch (transaction.getTransactionStatus()) { case Status.STATUS_ACTIVE: case Status.STATUS_MARKED_ROLLBACK: case Status.STATUS_PREPARING: case Status.STATUS_ROLLING_BACK: case Status.STATUS_UNKNOWN: transaction.recoveryRollback();/*w w w . jav a 2s . co m*/ transaction.recoveryForget(); break; case Status.STATUS_PREPARED: case Status.STATUS_COMMITTING: transaction.recoveryCommit(); transaction.recoveryForget(); break; case Status.STATUS_COMMITTED: case Status.STATUS_ROLLEDBACK: default: // ignore } }
From source file:org.commonjava.maven.galley.cache.infinispan.FastLocalCacheProvider.java
private boolean isTxActive(CacheInstance<String, String> cacheInstance) throws SystemException { final int[] ACTIVE_STATUS = new int[] { Status.STATUS_ACTIVE, Status.STATUS_COMMITTING, Status.STATUS_PREPARING, Status.STATUS_PREPARED, Status.STATUS_ROLLING_BACK }; boolean isActive = false; for (int status : ACTIVE_STATUS) { if (cacheInstance.getTransactionStatus() == status) { isActive = true;//from w w w.j a va2 s . co m break; } } return isActive; }
From source file:org.compass.core.transaction.AbstractJTATransaction.java
public boolean wasRolledBack() throws TransactionException { if (!isBegun()) return false; if (commitFailed) return true; final int status; try {//from w w w . j av a 2 s. com status = ut.getStatus(); } catch (SystemException se) { throw new TransactionException("Could not determine transaction status", se); } if (status == Status.STATUS_UNKNOWN) { throw new TransactionException("Could not determine transaction status"); } else { return status == Status.STATUS_MARKED_ROLLBACK || status == Status.STATUS_ROLLING_BACK || status == Status.STATUS_ROLLEDBACK; } }