• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HeuristicCommitException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.transaction.HeuristicCommitException的典型用法代码示例。如果您正苦于以下问题:Java HeuristicCommitException类的具体用法?Java HeuristicCommitException怎么用?Java HeuristicCommitException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HeuristicCommitException类属于javax.transaction包,在下文中一共展示了HeuristicCommitException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: rollback

import javax.transaction.HeuristicCommitException; //导入依赖的package包/类
public void rollback(Xid xid)
		throws HeuristicMixedException, HeuristicCommitException, IllegalStateException, SystemException {
	try {
		this.terminator.rollback(xid);
	} catch (XAException xaex) {
		switch (xaex.errorCode) {
		case XAException.XA_HEURRB:
			break;
		case XAException.XA_HEURMIX:
			throw new HeuristicMixedException();
		case XAException.XA_HEURCOM:
			throw new HeuristicCommitException();
		default:
			logger.error("Unknown state in rollingback transaction phase.", xaex);
			throw new SystemException();
		}
	} catch (RuntimeException rex) {
		logger.error("Unknown state in rollingback transaction phase.", rex);
		throw new SystemException();
	}
}
 
开发者ID:liuyangming,项目名称:ByteJTA,代码行数:22,代码来源:SimpleTransactionStrategy.java


示例2: rollback

import javax.transaction.HeuristicCommitException; //导入依赖的package包/类
/**
 * Rollback the current XA transaction. Transaction will not timeout while changing status but rather by some
 * extra logic that will manually throw the exception after doing as much cleanup as possible.
 *
 * @param transaction the transaction to rollback.
 * @param interestedResources resources that should be rolled back.
 * @throws HeuristicCommitException when all resources committed instead.
 * @throws HeuristicMixedException when some resources committed and some rolled back.
 * @throws bitronix.tm.internal.BitronixSystemException when an internal error occured.
 */
public void rollback(BitronixTransaction transaction, List<XAResourceHolderState> interestedResources) throws HeuristicMixedException, HeuristicCommitException, BitronixSystemException {
    XAResourceManager resourceManager = transaction.getResourceManager();
    transaction.setStatus(Status.STATUS_ROLLING_BACK);
    this.interestedResources.clear();
    this.interestedResources.addAll(interestedResources);

    try {
        executePhase(resourceManager, true);
    } catch (PhaseException ex) {
        logFailedResources(ex);
        transaction.setStatus(Status.STATUS_UNKNOWN);
        throwException("transaction failed during rollback of " + transaction, ex, interestedResources.size());
    }

    if (log.isDebugEnabled()) { log.debug("rollback executed on resources " + Decoder.collectResourcesNames(rolledbackResources)); }

    // Some resources might have failed the 2nd phase of 2PC.
    // Only resources which successfully rolled back should be registered in the journal, the other
    // ones should be picked up by the recoverer.
    // Not interested resources have to be included as well since they returned XA_RDONLY and they
    // don't participate in phase 2: the TX succeded for them.
    Set<String> rolledbackAndNotInterestedUniqueNames = new HashSet<String>();
    rolledbackAndNotInterestedUniqueNames.addAll(collectResourcesUniqueNames(rolledbackResources));
    List<XAResourceHolderState> notInterestedResources = collectNotInterestedResources(resourceManager.getAllResources(), interestedResources);
    rolledbackAndNotInterestedUniqueNames.addAll(collectResourcesUniqueNames(notInterestedResources));

    if (log.isDebugEnabled()) {
        List<XAResourceHolderState> rolledbackAndNotInterestedResources = new ArrayList<XAResourceHolderState>();
        rolledbackAndNotInterestedResources.addAll(rolledbackResources);
        rolledbackAndNotInterestedResources.addAll(notInterestedResources);

        log.debug("rollback succeeded on resources " + Decoder.collectResourcesNames(rolledbackAndNotInterestedResources));
    }

    transaction.setStatus(Status.STATUS_ROLLEDBACK, rolledbackAndNotInterestedUniqueNames);
}
 
开发者ID:bitronix,项目名称:btm,代码行数:47,代码来源:Rollbacker.java


示例3: throwException

import javax.transaction.HeuristicCommitException; //导入依赖的package包/类
private void throwException(String message, PhaseException phaseException, int totalResourceCount) throws HeuristicMixedException, HeuristicCommitException {
    List<Exception> exceptions = phaseException.getExceptions();
    List<XAResourceHolderState> resources = phaseException.getResourceStates();

    boolean hazard = false;
    List<XAResourceHolderState> heuristicResources = new ArrayList<XAResourceHolderState>();
    List<XAResourceHolderState> errorResources = new ArrayList<XAResourceHolderState>();

    for (int i = 0; i < exceptions.size(); i++) {
        Exception ex = exceptions.get(i);
        XAResourceHolderState resourceHolder = resources.get(i);
        if (ex instanceof XAException) {
            XAException xaEx = (XAException) ex;
            switch (xaEx.errorCode) {
                case XAException.XA_HEURHAZ:
                    hazard = true;
                case XAException.XA_HEURCOM:
                case XAException.XA_HEURRB:
                case XAException.XA_HEURMIX:
                    heuristicResources.add(resourceHolder);
                    break;

                default:
                    errorResources.add(resourceHolder);
            }
        }
        else
            errorResources.add(resourceHolder);
    }

    if (!hazard && heuristicResources.size() == totalResourceCount)
        throw new BitronixHeuristicCommitException(message + ":" +
                " all resource(s) " + Decoder.collectResourcesNames(heuristicResources) +
                " improperly unilaterally committed", phaseException);
    else
        throw new BitronixHeuristicMixedException(message + ":" +
                (errorResources.size() > 0 ? " resource(s) " + Decoder.collectResourcesNames(errorResources) + " threw unexpected exception" : "") +
                (errorResources.size() > 0 && heuristicResources.size() > 0 ? " and" : "") +
                (heuristicResources.size() > 0 ? " resource(s) " + Decoder.collectResourcesNames(heuristicResources) + " improperly unilaterally committed" + (hazard ? " (or hazard happened)" : "") : ""), phaseException);
}
 
开发者ID:bitronix,项目名称:btm,代码行数:41,代码来源:Rollbacker.java


示例4: commit

import javax.transaction.HeuristicCommitException; //导入依赖的package包/类
public void commit() throws HeuristicMixedException, HeuristicRollbackException, SystemException,
		RemoteException {
	TransactionImpl transaction = TransactionImpl.this;
	synchronized (transaction) {
		TransactionStatus transactionStatus = transaction.transactionStatus;
		if (transactionStatus.isActive()) {
			throw new IllegalStateException();
		} else if (transactionStatus.isMarkedRollbackOnly()) {
			throw new IllegalStateException();
		} else if (transactionStatus.isRolledBack()) {
			throw new HeuristicRollbackException();
		} else if (transactionStatus.isRollingBack()) {
			try {
				this.rollback();
				throw new HeuristicRollbackException();
			} catch (IllegalStateException ex) {
				SystemException exception = new SystemException();
				exception.initCause(ex);
				throw exception;
			} catch (HeuristicCommitException e) {
				return;
			}
		} else if (transactionStatus.isCommitted()) {
			return;
		}

		transaction.setTransactionCompleting(true);

		try {
			if (transactionStatus.isPrepared()) {
				transactionStatus.setStatusCommiting();
				transactionStatistic.fireCommittingTransaction(transaction);
				transactionLogger.updateTransaction(transaction);
			} else if (transactionStatus.isCommitting()) {
				// ignore
			} else {
				throw new IllegalStateException();
			}

			transaction.participantCommit();

			if (transactionStatus.isCommitting()) {
				transactionStatus.setStatusCommitted();
				transactionStatistic.fireCommittedTransaction(transaction);
				transactionLogger.completeTransaction(transaction);
			} else if (transactionStatus.isCommitted()) {
				// ignore
			} else {
				throw new IllegalStateException();
			}

		} finally {
			transaction.afterCompletion();
		}
	}
}
 
开发者ID:yangting,项目名称:openjtcc,代码行数:57,代码来源:TransactionImpl.java


示例5: rollback

import javax.transaction.HeuristicCommitException; //导入依赖的package包/类
public void rollback() throws HeuristicMixedException, HeuristicCommitException, SystemException,
		RemoteException {

	TransactionImpl transaction = TransactionImpl.this;
	synchronized (transaction) {
		TransactionStatus transactionStatus = transaction.transactionStatus;
		if (transactionStatus.isActive()) {
			throw new IllegalStateException();
		} else if (transactionStatus.isMarkedRollbackOnly()) {
			throw new IllegalStateException();
		} else if (transactionStatus.isCommitted()) {
			throw new IllegalStateException();
		} else if (transactionStatus.isRolledBack()) {
			return;
		}

		try {
			if (transactionStatus.isActive() || transactionStatus.isMarkedRollbackOnly()) {
				transactionStatus.setStatusRollingback();
				transactionStatistic.fireRollingBackTransaction(transaction);
				transactionLogger.updateTransaction(transaction);
			} else if (transactionStatus.isPrepareFail() || transactionStatus.isPrepared()) {
				transactionStatus.setStatusRollingback();
				transactionStatistic.fireRollingBackTransaction(transaction);
				transactionLogger.updateTransaction(transaction);
			} else if (transactionStatus.isRollingBack()) {
				// ignore
			} else if (transactionStatus.isCommitting() || transactionStatus.isCommitFail()) {
				transactionStatus.setStatusRollingback();
				transactionStatistic.fireRollingBackTransaction(transaction);
				transactionLogger.updateTransaction(transaction);
			} else {
				throw new IllegalStateException();
			}

			transaction.setTransactionCompleting(true);

			transaction.participantRollback();

			if (transactionStatus.isRollingBack()) {
				transactionStatus.setStatusRolledback();
				transactionStatistic.fireRolledbackTransaction(transaction);
			} else if (transactionStatus.isRolledBack()) {
				// ignore
			} else {
				throw new IllegalStateException();
			}

			transactionLogger.completeTransaction(transaction);

		} finally {
			transaction.afterCompletion();
		}
	}
}
 
开发者ID:yangting,项目名称:openjtcc,代码行数:56,代码来源:TransactionImpl.java


示例6: rollback

import javax.transaction.HeuristicCommitException; //导入依赖的package包/类
public void rollback(Xid xid)
throws HeuristicMixedException, HeuristicCommitException, IllegalStateException, SystemException;
 
开发者ID:liuyangming,项目名称:ByteJTA,代码行数:3,代码来源:TransactionStrategy.java


示例7: rollback

import javax.transaction.HeuristicCommitException; //导入依赖的package包/类
public void rollback(Xid xid)
		throws HeuristicMixedException, HeuristicCommitException, IllegalStateException, SystemException {
}
 
开发者ID:liuyangming,项目名称:ByteJTA,代码行数:4,代码来源:VacantTransactionStrategy.java


示例8: doCommit

import javax.transaction.HeuristicCommitException; //导入依赖的package包/类
/**
* Drive the subordinate transaction to commit. It must have previously
* been prepared.
*
* @return true, if the transaction was fully committed, false if there was a transient error
*
* @throws IllegalStateException thrown if the transaction has not been prepared
* or is unknown.
* @throws HeuristicMixedException thrown if a heuristic mixed outcome occurs
* (where some participants committed whilst others rolled back).
* @throws HeuristicRollbackException thrown if the transaction rolled back.
* @throws SystemException thrown if some other error occurs.
*/
  public boolean doCommit() throws IllegalStateException,
	HeuristicMixedException, HeuristicRollbackException, HeuristicCommitException,
	SystemException;
 
开发者ID:jbosstm,项目名称:jboss-transaction-spi,代码行数:17,代码来源:ImportedTransaction.java


示例9: doRollback

import javax.transaction.HeuristicCommitException; //导入依赖的package包/类
/**
* Drive the subordinate transaction to roll back. It need not have been previously
* prepared.
*
* @throws IllegalStateException thrown if the transaction is not known by the
* system or has been previously terminated.
* @throws HeuristicMixedException thrown if a heuristic mixed outcome occurs
* (can only happen if the transaction was previously prepared and then only if
* some participants commit whilst others roll back).
* @throws HeuristicCommitException thrown if the transaction commits (can only
* happen if it was previously prepared).
* @throws SystemException thrown if any other error occurs.
*/
  public void doRollback() throws IllegalStateException,
          HeuristicMixedException, HeuristicCommitException, HeuristicRollbackException, SystemException;
 
开发者ID:jbosstm,项目名称:jboss-transaction-spi,代码行数:16,代码来源:ImportedTransaction.java


示例10: rollback

import javax.transaction.HeuristicCommitException; //导入依赖的package包/类
public void rollback() throws HeuristicMixedException, HeuristicCommitException, SystemException, RemoteException; 
开发者ID:yangting,项目名称:openjtcc,代码行数:2,代码来源:Rollbackable.java



注:本文中的javax.transaction.HeuristicCommitException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Sasl类代码示例发布时间:2022-05-22
下一篇:
Java MapValue类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap