Java Code Examples for javax.transaction.xa.XAException#XAER_INVAL

The following examples show how to use javax.transaction.xa.XAException#XAER_INVAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CloudSpannerXAConnection.java    From spanner-jdbc with MIT License 6 votes vote down vote up
@Override
public void commit(Xid xid, boolean onePhase) throws XAException {
  if (logger.logDebug()) {
    debug("committing xid = " + xid + (onePhase ? " (one phase) " : " (two phase)"));
  }

  if (xid == null) {
    throw new CloudSpannerXAException(CloudSpannerXAException.XID_NOT_NULL, Code.INVALID_ARGUMENT,
        XAException.XAER_INVAL);
  }

  if (onePhase) {
    commitOnePhase(xid);
  } else {
    commitPrepared(xid);
  }
}
 
Example 2
Source File: MysqlXAConnection.java    From FoxTelem with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void end(Xid xid, int flags) throws XAException {
    StringBuilder commandBuf = new StringBuilder(MAX_COMMAND_LENGTH);
    commandBuf.append("XA END ");
    appendXid(commandBuf, xid);

    switch (flags) {
        case TMSUCCESS:
            break; // no-op
        case TMSUSPEND:
            commandBuf.append(" SUSPEND");
            break;
        case TMFAIL:
            break; // no-op
        default:
            throw new XAException(XAException.XAER_INVAL);
    }

    dispatchCommand(commandBuf.toString());
}
 
Example 3
Source File: ActiveMQSessionContext.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
public void xaEnd(Xid xid, int flags) throws XAException, ActiveMQException {
   Packet packet;
   if (flags == XAResource.TMSUSPEND) {
      packet = new PacketImpl(PacketImpl.SESS_XA_SUSPEND);
   } else if (flags == XAResource.TMSUCCESS) {
      packet = new SessionXAEndMessage(xid, false);
   } else if (flags == XAResource.TMFAIL) {
      packet = new SessionXAEndMessage(xid, true);
   } else {
      throw new XAException(XAException.XAER_INVAL);
   }

   SessionXAResponseMessage response = (SessionXAResponseMessage) sessionChannel.sendBlocking(packet, PacketImpl.SESS_XA_RESP);

   if (response.isError()) {
      throw new XAException(response.getResponseCode());
   }
}
 
Example 4
Source File: EhcacheXAResource.java    From ehcache3 with Apache License 2.0 6 votes vote down vote up
@Override
public Xid[] recover(int flags) throws XAException {
  if (flags != XAResource.TMNOFLAGS && flags != XAResource.TMSTARTRSCAN && flags != XAResource.TMENDRSCAN && flags != (XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN)) {
    throw new EhcacheXAException("Recover flags not supported : " + xaResourceFlagsToString(flags), XAException.XAER_INVAL);
  }

  if ((flags & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
    List<Xid> xids = new ArrayList<>();
    Set<TransactionId> transactionIds = journal.recover().keySet();
    for (TransactionId transactionId : transactionIds) {
      // filter-out in-flight tx
      if (!transactionContextFactory.contains(transactionId)) {
        xids.add(transactionId.getSerializableXid());
      }
    }
    return xids.toArray(new Xid[xids.size()]);
  }
  return new Xid[0];
}
 
Example 5
Source File: MysqlXAConnection.java    From Komondor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Starts work on behalf of a transaction branch specified in xid.
 * 
 * If TMJOIN is specified, the start applies to joining a transaction
 * previously seen by the resource manager.
 * 
 * If TMRESUME is specified, the start applies to resuming a suspended
 * transaction specified in the parameter xid.
 * 
 * If neither TMJOIN nor TMRESUME is specified and the transaction specified
 * by xid has previously been seen by the resource manager, the resource
 * manager throws the XAException exception with XAER_DUPID error code.
 * 
 * @parameter xid A global transaction identifier to be associated with the
 *            resource.
 * 
 * @parameter flags One of TMNOFLAGS, TMJOIN, or TMRESUME.
 * 
 * @throws XAException
 *             An error has occurred. Possible exceptions are XA_RB*,
 *             XAER_RMERR, XAER_RMFAIL, XAER_DUPID, XAER_OUTSIDE, XAER_NOTA,
 *             XAER_INVAL, or XAER_PROTO.
 */
public void start(Xid xid, int flags) throws XAException {
    StringBuilder commandBuf = new StringBuilder(MAX_COMMAND_LENGTH);
    commandBuf.append("XA START ");
    appendXid(commandBuf, xid);

    switch (flags) {
        case TMJOIN:
            commandBuf.append(" JOIN");
            break;
        case TMRESUME:
            commandBuf.append(" RESUME");
            break;
        case TMNOFLAGS:
            // no-op
            break;
        default:
            throw new XAException(XAException.XAER_INVAL);
    }

    dispatchCommand(commandBuf.toString());

    this.underlyingConnection.setInGlobalTx(true);
}
 
Example 6
Source File: MysqlXAConnection.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public void start(Xid xid, int flags) throws XAException {
    StringBuilder commandBuf = new StringBuilder(MAX_COMMAND_LENGTH);
    commandBuf.append("XA START ");
    appendXid(commandBuf, xid);

    switch (flags) {
        case TMJOIN:
            commandBuf.append(" JOIN");
            break;
        case TMRESUME:
            commandBuf.append(" RESUME");
            break;
        case TMNOFLAGS:
            // no-op
            break;
        default:
            throw new XAException(XAException.XAER_INVAL);
    }

    dispatchCommand(commandBuf.toString());

    this.underlyingConnection.setInGlobalTx(true);
}
 
Example 7
Source File: XATestUtil.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Return a string for the error code of the XAException.
*/
public static String errorCode(XAException e)
{
    String error;
    switch(e.errorCode)
    {
    case XAException.XA_HEURCOM : error = "XA_HEURCOM "; break;
    case XAException.XA_HEURHAZ : error = "XA_HEURHAZ"; break;
    case XAException.XA_HEURMIX : error = "XA_HEURMIX"; break;
    case XAException.XA_HEURRB : error = "XA_HEURRB "; break;
    case XAException.XA_NOMIGRATE : error = "XA_NOMIGRATE "; break;
    case XAException.XA_RBCOMMFAIL : error = "XA_RBCOMMFAIL "; break;
    case XAException.XA_RBDEADLOCK : error = "XA_RBDEADLOCK "; break;
    case XAException.XA_RBINTEGRITY : error = "XA_RBINTEGRITY "; break;
    case XAException.XA_RBOTHER : error = "XA_RBOTHER "; break;
    case XAException.XA_RBPROTO : error = "XA_RBPROTO "; break;
    case XAException.XA_RBROLLBACK : error = "XA_RBROLLBACK "; break;
    case XAException.XA_RBTIMEOUT : error = "XA_RBTIMEOUT "; break;
    case XAException.XA_RBTRANSIENT : error = "XA_RBTRANSIENT "; break;
    case XAException.XA_RDONLY : error = "XA_RDONLY "; break;
    case XAException.XA_RETRY : error = "XA_RETRY "; break;
    case XAException.XAER_ASYNC : error = "XAER_ASYNC "; break;
    case XAException.XAER_DUPID : error = "XAER_DUPID "; break;
    case XAException.XAER_INVAL : error = "XAER_INVAL "; break;
    case XAException.XAER_NOTA : error = "XAER_NOTA "; break;
    case XAException.XAER_OUTSIDE : error = "XAER_OUTSIDE "; break;
    case XAException.XAER_PROTO : error = "XAER_PROTO "; break;
    case XAException.XAER_RMERR : error = "XAER_RMERR "; break;
    case XAException.XAER_RMFAIL : error = "XAER_RMFAIL "; break;
    default: error = Integer.toString(e.errorCode); break;
    }        
    return error;
}
 
Example 8
Source File: TransactionCoordinator.java    From ByteTCC with GNU Lesser General Public License v3.0 5 votes vote down vote up
public int prepare(Xid xid) throws XAException {
	TransactionParticipant compensableCoordinator = this.beanFactory.getCompensableNativeParticipant();
	TransactionParticipant transactionCoordinator = this.beanFactory.getTransactionNativeParticipant();

	int formatId = xid.getFormatId();
	if (XidFactory.JTA_FORMAT_ID == formatId) {
		return transactionCoordinator.prepare(xid);
	} else if (XidFactory.TCC_FORMAT_ID == formatId) {
		return compensableCoordinator.prepare(xid);
	} else {
		throw new XAException(XAException.XAER_INVAL);
	}
}
 
Example 9
Source File: TransactionCoordinator.java    From ByteTCC with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void commit(Xid xid, boolean onePhase) throws XAException {
	TransactionParticipant compensableCoordinator = this.beanFactory.getCompensableNativeParticipant();
	TransactionParticipant transactionCoordinator = this.beanFactory.getTransactionNativeParticipant();

	int formatId = xid.getFormatId();
	if (XidFactory.JTA_FORMAT_ID == formatId) {
		transactionCoordinator.commit(xid, onePhase);
	} else if (XidFactory.TCC_FORMAT_ID == formatId) {
		compensableCoordinator.commit(xid, onePhase);
	} else {
		throw new XAException(XAException.XAER_INVAL);
	}
}
 
Example 10
Source File: MariaXaResource.java    From mariadb-connector-j with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Starts work on behalf of a transaction branch specified in xid. If TMJOIN is specified, the
 * start applies to joining a transaction previously seen by the resource manager. If TMRESUME is
 * specified, the start applies to resuming a suspended transaction specified in the parameter
 * xid. If neither TMJOIN nor TMRESUME is specified and the transaction specified by xid has
 * previously been seen by the resource manager, the resource manager throws the XAException
 * exception with XAER_DUPID error code.
 *
 * @param xid A global transaction identifier to be associated with the resource.
 * @param flags One of TMNOFLAGS, TMJOIN, or TMRESUME.
 * @throws XAException An error has occurred.
 */
public void start(Xid xid, int flags) throws XAException {
  if (flags != TMJOIN && flags != TMRESUME && flags != TMNOFLAGS) {
    throw new XAException(XAException.XAER_INVAL);
  }
  execute(
      "XA START "
          + xidToString(xid)
          + " "
          + flagsToString(
              flags == TMJOIN && connection.getPinGlobalTxToPhysicalConnection()
                  ? TMRESUME
                  : flags));
}
 
Example 11
Source File: XATerminatorImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void invokeOnePhaseCommit(XAResourceArchive archive) throws XAException {
	try {
		archive.commit(archive.getXid(), true);
	} catch (XAException xaex) {
		switch (xaex.errorCode) {
		case XAException.XA_HEURCOM:
		case XAException.XA_HEURHAZ:
		case XAException.XA_HEURMIX:
		case XAException.XA_HEURRB:
			logger.warn("An error occurred in one phase commit: {}, transaction has been completed!",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			throw xaex;
		case XAException.XAER_RMFAIL:
			logger.warn("An error occurred in one phase commit: {}",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			throw xaex;
		case XAException.XAER_NOTA:
		case XAException.XAER_INVAL:
		case XAException.XAER_PROTO:
			logger.warn("An error occurred in one phase commit: {}",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			throw new XAException(XAException.XAER_RMERR);
		case XAException.XAER_RMERR:
		case XAException.XA_RBCOMMFAIL:
		case XAException.XA_RBDEADLOCK:
		case XAException.XA_RBINTEGRITY:
		case XAException.XA_RBOTHER:
		case XAException.XA_RBPROTO:
		case XAException.XA_RBROLLBACK:
		case XAException.XA_RBTIMEOUT:
		case XAException.XA_RBTRANSIENT:
		default:
			logger.warn("An error occurred in one phase commit: {}, transaction has been rolled back!",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			throw new XAException(XAException.XA_HEURRB);
		}
	}
}
 
Example 12
Source File: CompensableCoordinator.java    From ByteTCC with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void forget(Xid xid) throws XAException {
	this.checkParticipantReadyIfNecessary();

	if (xid == null) {
		throw new XAException(XAException.XAER_INVAL);
	}
	TransactionRepository compensableRepository = this.beanFactory.getCompensableRepository();
	XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
	TransactionXid globalXid = xidFactory.createGlobalXid(xid.getGlobalTransactionId());
	CompensableTransaction transaction = null;
	try {
		transaction = (CompensableTransaction) compensableRepository.getTransaction(globalXid);
	} catch (TransactionException tex) {
		throw new XAException(XAException.XAER_RMERR);
	}

	if (transaction == null) {
		throw new XAException(XAException.XAER_NOTA);
	}

	try {
		transaction.forget();
	} catch (SystemException ex) {
		logger.error("Error occurred while forgetting transaction: {}." //
				, ByteUtils.byteArrayToString(xid.getGlobalTransactionId()), ex);

		throw new XAException(XAException.XAER_RMERR);
	} catch (RuntimeException rex) {
		logger.error("Error occurred while forgetting transaction: {}." //
				, ByteUtils.byteArrayToString(xid.getGlobalTransactionId()), rex);

		throw new XAException(XAException.XAER_RMERR);
	}
}
 
Example 13
Source File: TransactionImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 4 votes vote down vote up
public synchronized void cleanup() throws SystemException {
	boolean unFinishExists = false;

	for (int i = 0; i < this.participantList.size(); i++) {
		XAResourceArchive archive = this.participantList.get(i);
		Xid currentXid = archive.getXid();
		if (archive.isHeuristic()) {
			try {
				Xid branchXid = archive.getXid();
				archive.forget(branchXid);
			} catch (XAException xae) {
				// Possible exception values are XAER_RMERR, XAER_RMFAIL
				// , XAER_NOTA, XAER_INVAL, or XAER_PROTO.
				switch (xae.errorCode) {
				case XAException.XAER_RMERR:
					unFinishExists = true;
					logger.error("{}> forget: xares= {}, branch={}, error= {}",
							ByteUtils.byteArrayToString(currentXid.getGlobalTransactionId()), archive,
							ByteUtils.byteArrayToString(currentXid.getBranchQualifier()), xae.errorCode);
					break;
				case XAException.XAER_RMFAIL:
					unFinishExists = true;
					logger.error("{}> forget: xares= {}, branch={}, error= {}",
							ByteUtils.byteArrayToString(currentXid.getGlobalTransactionId()), archive,
							ByteUtils.byteArrayToString(currentXid.getBranchQualifier()), xae.errorCode);
					break;
				case XAException.XAER_NOTA:
				case XAException.XAER_INVAL:
				case XAException.XAER_PROTO:
					break;
				default:
					unFinishExists = true;
					logger.error("{}> forget: xares= {}, branch={}, error= {}",
							ByteUtils.byteArrayToString(currentXid.getGlobalTransactionId()), archive,
							ByteUtils.byteArrayToString(currentXid.getBranchQualifier()), xae.errorCode);
				}
			}
		} // end-if
	} // end-for

	if (unFinishExists) {
		throw new SystemException("Error occurred while cleaning branch transaction!");
	}

}
 
Example 14
Source File: NetXAResource.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Set the current transaction timeout value for this XAResource
 * instance. Once set, this timeout value is effective until
 * setTransactionTimeout is invoked again with a different value. To reset
 * the timeout value to the default value used by the resource manager,
 * set the value to zero. If the timeout operation is performed
 * successfully, the method returns true; otherwise false. If a resource
 * manager does not support transaction timeout value to be set
 * explicitly, this method returns false.
 *
 * @param seconds the transaction timeout value in seconds.
 *                Value of 0 means the reasource manager's default value.
 *                Value of Integer.MAX_VALUE means no timeout.
 * @return true if transaction timeout value is set successfully;
 * otherwise false.
 *
 * @exception XAException - An error has occurred. Possible exception
 * values are XAER_RMERR, XAER_RMFAIL, or XAER_INVAL.
 */
public boolean setTransactionTimeout(int seconds) throws XAException {
    if (conn_.agent_.loggingEnabled()) {
        conn_.agent_.logWriter_.traceEntry(this, "setTransactionTimeout");
    }
    if (seconds < 0) {
        // throw an exception if invalid value was specified
        throw new XAException(XAException.XAER_INVAL);
    }
    exceptionsOnXA = null;
    timeoutSeconds = seconds;
    if (conn_.agent_.loggingEnabled()) {
        conn_.agent_.logWriter_.traceExit(this, "setTransactionTimeout", true);
    }
    return true;
}
 
Example 15
Source File: MysqlXAConnection.java    From r-course with MIT License 4 votes vote down vote up
/**
 * Ends the work performed on behalf of a transaction branch.
 * 
 * The resource manager disassociates the XA resource from the transaction
 * branch specified and lets the transaction complete.
 * 
 * If TMSUSPEND is specified in the flags, the transaction branch is
 * temporarily suspended in an incomplete state. The transaction context is
 * in a suspended state and must be resumed via the start method with
 * TMRESUME specified.
 * 
 * If TMFAIL is specified, the portion of work has failed. The resource
 * manager may mark the transaction as rollback-only
 * 
 * If TMSUCCESS is specified, the portion of work has completed
 * successfully.
 * 
 * @parameter xid A global transaction identifier that is the same as the
 *            identifier used previously in the start method.
 * 
 * @parameter flags One of TMSUCCESS, TMFAIL, or TMSUSPEND.
 * 
 * @throws XAException
 *             -
 *             An error has occurred. Possible XAException values are
 *             XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, XAER_PROTO,
 *             or XA_RB*.
 */
public void end(Xid xid, int flags) throws XAException {
    StringBuilder commandBuf = new StringBuilder(MAX_COMMAND_LENGTH);
    commandBuf.append("XA END ");
    appendXid(commandBuf, xid);

    switch (flags) {
        case TMSUCCESS:
            break; // no-op
        case TMSUSPEND:
            commandBuf.append(" SUSPEND");
            break;
        case TMFAIL:
            break; // no-op
        default:
            throw new XAException(XAException.XAER_INVAL);
    }

    dispatchCommand(commandBuf.toString());
}
 
Example 16
Source File: XATerminatorOptd.java    From ByteJTA with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void fireOnePhaseCommit(Xid xid) throws XAException {
	if (archive.isCommitted() && archive.isRolledback()) {
		throw new XAException(XAException.XA_HEURMIX);
	} else if (archive.isCommitted()) {
		return;
	} else if (archive.isReadonly()) {
		throw new XAException(XAException.XA_RDONLY); // XAException.XAER_NOTA
	} else if (archive.isRolledback()) {
		throw new XAException(XAException.XA_HEURRB);
	}

	TransactionLogger transactionLogger = this.beanFactory.getTransactionLogger();

	boolean updateRequired = true;
	try {
		archive.commit(archive.getXid(), true);
		archive.setCommitted(true);
		archive.setCompleted(true);

		logger.info("{}> commit: xares= {}, branch= {}, opc= {}",
				ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()), archive,
				ByteUtils.byteArrayToString(archive.getXid().getBranchQualifier()), false);
	} catch (XAException xaex) {
		switch (xaex.errorCode) {
		case XAException.XA_HEURCOM:
			archive.setHeuristic(true);
			archive.setCommitted(true);
			archive.setCompleted(true);
			break;
		case XAException.XA_HEURMIX:
			archive.setHeuristic(true);
			archive.setCommitted(true);
			archive.setRolledback(true);
			archive.setCompleted(true);
			throw xaex;
		case XAException.XA_HEURRB:
			archive.setHeuristic(true);
			archive.setRolledback(true);
			archive.setCompleted(true);
			throw xaex;
		case XAException.XA_HEURHAZ:
			archive.setHeuristic(true);
			throw xaex;
		case XAException.XAER_RMFAIL:
			logger.warn("An error occurred in one phase commit: {}",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			updateRequired = false;
			throw new XAException(XAException.XA_HEURHAZ);
		case XAException.XAER_NOTA:
		case XAException.XAER_INVAL:
		case XAException.XAER_PROTO:
			logger.warn("An error occurred in one phase commit: {}",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			updateRequired = false;
			throw new XAException(XAException.XAER_RMERR);
		case XAException.XAER_RMERR:
		case XAException.XA_RBCOMMFAIL:
		case XAException.XA_RBDEADLOCK:
		case XAException.XA_RBINTEGRITY:
		case XAException.XA_RBOTHER:
		case XAException.XA_RBPROTO:
		case XAException.XA_RBROLLBACK:
		case XAException.XA_RBTIMEOUT:
		case XAException.XA_RBTRANSIENT:
		default:
			logger.warn("An error occurred in one phase commit: {}, transaction has been rolled back!",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			archive.setRolledback(true);
			archive.setCompleted(true);
			throw new XAException(XAException.XA_HEURRB);
		}
	} catch (RuntimeException rex) {
		logger.error("{}> Error occurred while committing xa-resource: xares= {}, branch= {}",
				ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()), archive,
				ByteUtils.byteArrayToString(archive.getXid().getBranchQualifier()), rex);
		updateRequired = false;
		throw new XAException(XAException.XA_HEURHAZ);
	} finally {
		if (updateRequired) {
			transactionLogger.updateParticipant(archive);
		}
	}
}
 
Example 17
Source File: NetXAResource.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Set the current transaction timeout value for this XAResource
 * instance. Once set, this timeout value is effective until
 * setTransactionTimeout is invoked again with a different value. To reset
 * the timeout value to the default value used by the resource manager,
 * set the value to zero. If the timeout operation is performed
 * successfully, the method returns true; otherwise false. If a resource
 * manager does not support transaction timeout value to be set
 * explicitly, this method returns false.
 *
 * @param seconds the transaction timeout value in seconds.
 *                Value of 0 means the reasource manager's default value.
 *                Value of Integer.MAX_VALUE means no timeout.
 * @return true if transaction timeout value is set successfully;
 * otherwise false.
 *
 * @exception XAException - An error has occurred. Possible exception
 * values are XAER_RMERR, XAER_RMFAIL, or XAER_INVAL.
 */
public boolean setTransactionTimeout(int seconds) throws XAException {
    if (conn_.agent_.loggingEnabled()) {
        conn_.agent_.logWriter_.traceEntry(this, "setTransactionTimeout");
    }
    if (seconds < 0) {
        // throw an exception if invalid value was specified
        throw new XAException(XAException.XAER_INVAL);
    }
    exceptionsOnXA = null;
    timeoutSeconds = seconds;
    if (conn_.agent_.loggingEnabled()) {
        conn_.agent_.logWriter_.traceExit(this, "setTransactionTimeout", true);
    }
    return true;
}
 
Example 18
Source File: xaHelper.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
private void handleException(Throwable t) throws SQLException
{
	if (t instanceof SQLException)
	{
		// let ij handle it
		throw (SQLException)t;
	}
	if (t instanceof XAException)
	{
		int errorCode = ((XAException)t).errorCode;
		String error = LocalizedResource.getMessage("IJ_IlleValu");

		// XA_RBBASE 100
		// XA_RBROLLBACK 100
		// XA_RBCOMMFAIL 101
		// XA_RBDEADLOCK 102
		// XA_RBINTEGRITY 103
		// XA_RBOTHER 104
		// XA_RBPROTO 105
		// XA_RBTIMEOUT 106
		// XA_RBTRANSIENT 107
		// XA_RBEND 107
		//
		// XA_RDONLY 3
		// XA_RETRY 4
		// XA_HEURMIX 5
		// XA_HEURRB 6
		// XA_HEURCOM 7
		// XA_HEURHAZ 8
		// XA_NOMIGRATE 9
		//
		// XAER_ASYNC -2
		// XAER_RMERR -3
		// XAER_NOTA -4
		// XAER_INVAL -5
		// XAER_PROTO -6
		// XAER_RMFAIL -7
		// XAER_DUPID -8
		// XAER_OUTSIDE -9

		switch(errorCode)
		{
		case XAException.XA_HEURCOM : error = "XA_HEURCOM "; break;
		case XAException.XA_HEURHAZ : error = "XA_HEURHAZ"; break;
		case XAException.XA_HEURMIX : error = "XA_HEURMIX"; break;
		case XAException.XA_HEURRB : error = "XA_HEURRB "; break;
		case XAException.XA_NOMIGRATE : error = "XA_NOMIGRATE "; break;
			// case XAException.XA_RBBASE : error = "XA_RBBASE "; break;
		case XAException.XA_RBCOMMFAIL : error = "XA_RBCOMMFAIL "; break;
		case XAException.XA_RBDEADLOCK : error = "XA_RBDEADLOCK "; break;
			// case XAException.XA_RBEND : error = "XA_RBEND "; break;
		case XAException.XA_RBINTEGRITY : error = "XA_RBINTEGRITY "; break;
		case XAException.XA_RBOTHER : error = "XA_RBOTHER "; break;
		case XAException.XA_RBPROTO : error = "XA_RBPROTO "; break;
		case XAException.XA_RBROLLBACK : error = "XA_RBROLLBACK "; break;
		case XAException.XA_RBTIMEOUT : error = "XA_RBTIMEOUT "; break;
		case XAException.XA_RBTRANSIENT : error = "XA_RBTRANSIENT "; break;
		case XAException.XA_RDONLY : error = "XA_RDONLY "; break;
		case XAException.XA_RETRY : error = "XA_RETRY "; break;
		case XAException.XAER_ASYNC : error = "XAER_ASYNC "; break;
		case XAException.XAER_DUPID : error = "XAER_DUPID "; break;
		case XAException.XAER_INVAL : error = "XAER_INVAL "; break;
		case XAException.XAER_NOTA : error = "XAER_NOTA "; break;
		case XAException.XAER_OUTSIDE : error = "XAER_OUTSIDE "; break;
		case XAException.XAER_PROTO : error = "XAER_PROTO "; break;
		case XAException.XAER_RMERR : error = "XAER_RMERR "; break;
		case XAException.XAER_RMFAIL : error = "XAER_RMFAIL "; break;
		}
		//t.printStackTrace(System.out);
		throw new ijException(error);

	}
	else // StandardException or run time exception, log it first
	{
		String info = LocalizedResource.getMessage("IJ_01SeeLog", t.toString(), t.getMessage());
		//		t.printStackTrace(System.out);
		throw new ijException(info);
	}
}
 
Example 19
Source File: TransactionImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 4 votes vote down vote up
private boolean delistResource(XAResourceArchive archive, int flag) throws SystemException {
	try {
		Xid branchXid = archive.getXid();

		logger.info("{}> delist: xares= {}, branch= {}, flags= {}",
				ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), archive,
				ByteUtils.byteArrayToString(branchXid.getBranchQualifier()), flag);

		switch (flag) {
		case XAResource.TMSUSPEND:
			archive.end(branchXid, flag);
			archive.setDelisted(true);
			archive.setSuspended(true);
			return true;
		case XAResource.TMFAIL:
			this.setRollbackOnlyQuietly();
		case XAResource.TMSUCCESS:
			archive.end(branchXid, flag);
			archive.setDelisted(true);
			return true;
		default:
			return false;
		}
	} catch (XAException xae) {
		logger.error("XATerminatorImpl.delistResource(XAResourceArchive, int)", xae);

		// Possible XAException values are XAER_RMERR, XAER_RMFAIL,
		// XAER_NOTA, XAER_INVAL, XAER_PROTO, or XA_RB*.
		switch (xae.errorCode) {
		case XAException.XAER_NOTA:
			// The specified XID is not known by the resource manager.
		case XAException.XAER_INVAL:
			// Invalid arguments were specified.
		case XAException.XAER_PROTO:
			// The routine was invoked in an improper context.
			return false;
		case XAException.XAER_RMFAIL:
			// An error occurred that makes the resource manager unavailable.
		case XAException.XAER_RMERR:
			// An error occurred in dissociating the transaction branch from the thread of control.
			return false; // throw new SystemException();
		default /* XA_RB* */ :
			return false; // throw new RollbackRequiredException();
		}
	} catch (RuntimeException ex) {
		logger.error("XATerminatorImpl.delistResource(XAResourceArchive, int)", ex);
		throw new SystemException();
	}
}
 
Example 20
Source File: EmbedXAResource.java    From spliceengine with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * Set the current transaction timeout value for this XAResource
 * instance. Once set, this timeout value is effective until
 * setTransactionTimeout is invoked again with a different value. To reset
 * the timeout value to the default value used by the resource manager,
 * set the value to zero. If the timeout operation is performed
 * successfully, the method returns true; otherwise false. If a resource
 * manager does not support transaction timeout value to be set
 * explicitly, this method returns false.
 *
 * @param seconds the transaction timeout value in seconds.
 *                Value of 0 means the reasource manager's default value.
 *                Value of Integer.MAX_VALUE means no timeout.
 * @return true if transaction timeout value is set successfully;
 * otherwise false.
 *
 * @exception XAException - An error has occurred. Possible exception
 * values are XAER_RMERR, XAER_RMFAIL, or XAER_INVAL.
 */
public synchronized boolean setTransactionTimeout(int seconds)
throws XAException {
    if (seconds < 0) {
        // throw an exception if invalid value was specified
        throw new XAException(XAException.XAER_INVAL);
    }
    timeoutSeconds = seconds;
    return true;
}