List of usage examples for javax.transaction.xa XAException XA_HEURRB
int XA_HEURRB
To view the source code for javax.transaction.xa XAException XA_HEURRB.
Click Source Link
From source file:com.clican.pluto.transaction.resources.memory.XAFileResourceMemoryImpl.java
public void commit(Xid xid, boolean onePhase) throws XAException { byte[] data = modifiedDataMapping.get(xid); OutputStream os = null;//w w w . j a va 2 s . c o m try { if (data == null) { file.deleteOnExit(); } else { os = new FileOutputStream(file); os.write(data); } } catch (Exception e) { rollback(xid); throw new XAException(XAException.XA_HEURRB); } finally { lockedXid = null; if (os != null) { try { os.close(); } catch (Exception e) { log.error("", e); } } } }
From source file:com.clican.pluto.transaction.resources.memory.XAFileSetResourceMemoryImpl.java
public void commit(Xid xid, boolean onePhase) throws XAException { for (File file : modifiedDataMapping.get(xid).keySet()) { OutputStream os = null;/*from w w w . j a v a2s .c om*/ try { byte[] data = modifiedDataMapping.get(xid).get(file); if (data == null) { file.deleteOnExit(); } else { os = new FileOutputStream(file); os.write(modifiedDataMapping.get(xid).get(file)); } } catch (Exception e) { rollback(xid); throw new XAException(XAException.XA_HEURRB); } finally { lockedXid = null; modifiedDataMapping.remove(xid); oldDataMapping.remove(xid); if (os != null) { try { os.close(); } catch (Exception e) { log.error("", e); } } } } }
From source file:org.apache.hadoop.hbase.client.transactional.JtaXAResource.java
public int prepare(final Xid xid) throws XAException { LOG.trace("prepare [" + xid.toString() + "] "); TransactionState state = xidToTransactionState.get(xid); int status;//from w ww .j av a2s.c om try { status = this.transactionManager.prepareCommit(state); } catch (CommitUnsuccessfulException e) { XAException xae = new XAException(XAException.XA_HEURRB); xae.initCause(e); throw xae; } catch (IOException e) { XAException xae = new XAException(XAException.XAER_RMERR); xae.initCause(e); throw xae; } switch (status) { case TransactionalReturn.COMMIT_OK: return XAResource.XA_OK; case TransactionalReturn.COMMIT_OK_READ_ONLY: return XAResource.XA_RDONLY; default: throw new XAException(XAException.XA_RBPROTO); } }
From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java
private synchronized void fireRemoteParticipantConfirm() throws HeuristicMixedException, HeuristicRollbackException, SystemException { boolean commitExists = false; boolean rollbackExists = false; boolean errorExists = false; for (int i = 0; i < this.resourceList.size(); i++) { XAResourceArchive current = this.resourceList.get(i); if (current.isCommitted()) { commitExists = true;//from w w w . j a va 2 s . c o m continue; } CompensableLogger transactionLogger = this.beanFactory.getCompensableLogger(); XidFactory xidFactory = this.beanFactory.getCompensableXidFactory(); TransactionXid branchXid = (TransactionXid) current.getXid(); TransactionXid globalXid = xidFactory.createGlobalXid(branchXid.getGlobalTransactionId()); try { current.commit(globalXid, true); commitExists = true; current.setCommitted(true); current.setCompleted(true); transactionLogger.updateCoordinator(current); logger.info("{}| confirm remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current.getDescriptor().getIdentifier()); } catch (XAException ex) { switch (ex.errorCode) { case XAException.XAER_NOTA: logger.warn("{}| error occurred while confirming remote branch: {}, transaction is not exists!", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current.getDescriptor().getIdentifier()); break; case XAException.XA_HEURCOM: commitExists = true; current.setCommitted(true); current.setHeuristic(false); current.setCompleted(true); transactionLogger.updateCoordinator(current); logger.info("{}| confirm remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current.getDescriptor().getIdentifier()); break; case XAException.XA_HEURRB: rollbackExists = true; current.setRolledback(true); current.setHeuristic(false); current.setCompleted(true); transactionLogger.updateCoordinator(current); logger.error("{}| error occurred while confirming remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), this.archive, ex); break; case XAException.XA_HEURMIX: // should never happen commitExists = true; rollbackExists = true; current.setHeuristic(true); // current.setCommitted(true); // current.setRolledback(true); // current.setCompleted(true); transactionLogger.updateCoordinator(current); logger.error("{}| error occurred while confirming remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), this.archive, ex); break; default: errorExists = false; logger.error("{}| error occurred while confirming remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), this.archive, ex); } } catch (RuntimeException rex) { errorExists = false; logger.error("{}| error occurred while confirming branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), this.archive, rex); } } if (commitExists && rollbackExists) { throw new HeuristicMixedException(); } else if (rollbackExists) { throw new HeuristicRollbackException(); } else if (errorExists) { throw new SystemException(); } }
From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java
private synchronized void fireRemoteParticipantRecoveryConfirm() throws HeuristicMixedException, HeuristicRollbackException, SystemException { boolean commitExists = false; boolean rollbackExists = false; boolean errorExists = false; for (int i = 0; i < this.resourceList.size(); i++) { XAResourceArchive current = this.resourceList.get(i); if (current.isCommitted()) { commitExists = true;/*from w w w . jav a 2 s . c o m*/ continue; } CompensableLogger transactionLogger = this.beanFactory.getCompensableLogger(); XidFactory xidFactory = this.beanFactory.getCompensableXidFactory(); TransactionXid branchXid = (TransactionXid) current.getXid(); TransactionXid globalXid = xidFactory.createGlobalXid(branchXid.getGlobalTransactionId()); try { current.recoveryCommit(globalXid); commitExists = true; current.setCommitted(true); current.setCompleted(true); transactionLogger.updateCoordinator(current); logger.info("{}| recovery-confirm remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current.getDescriptor().getIdentifier()); } catch (XAException ex) { switch (ex.errorCode) { case XAException.XAER_NOTA: logger.warn("{}| error occurred while confirming remote branch: {}, transaction is not exists!", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current.getDescriptor().getIdentifier()); break; case XAException.XA_HEURCOM: current.setCommitted(true); current.setHeuristic(false); current.setCompleted(true); transactionLogger.updateCoordinator(current); logger.info("{}| recovery-confirm remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current.getDescriptor().getIdentifier()); break; case XAException.XA_HEURRB: rollbackExists = true; current.setRolledback(true); current.setHeuristic(false); current.setCompleted(true); transactionLogger.updateCoordinator(current); logger.error("{}| error occurred while confirming remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current, ex); break; case XAException.XA_HEURMIX: commitExists = true; rollbackExists = true; current.setHeuristic(true); // current.setCommitted(true); // current.setRolledback(true); // current.setCompleted(true); transactionLogger.updateCoordinator(current); logger.error("{}| error occurred while confirming remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current, ex); break; default: errorExists = false; logger.error("{}| error occurred while confirming remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current, ex); } } catch (RuntimeException rex) { errorExists = false; logger.error("{}| error occurred while confirming remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current, rex); } } if (commitExists && rollbackExists) { throw new HeuristicMixedException(); } else if (rollbackExists) { throw new HeuristicRollbackException(); } else if (errorExists) { throw new SystemException(); } }