Package bitronix.tm.internal

Examples of bitronix.tm.internal.XAResourceHolderState


      ResourceBean rb = new ResourceBean() { };
      rb.setUniqueName(xaResource.getClass().getName() + System.identityHashCode(xaResource));
      rb.setApplyTransactionTimeout(true);

      XAResourceHolder resHolder = new SimpleXAResourceHolder(xaResource);
      resHolder.setXAResourceHolderState(new XAResourceHolderState(resHolder, rb));

      return resHolder;
    }
View Full Code Here


            if (xaResourceHolders.isEmpty()) {
                throw new RecoveryException("no XAResource registered, recovery cannot be done on " + this);
            }

            recoveryXAResourceHolder = new RecoveryXAResourceHolder((XAResourceHolder) xaResourceHolders.get(0));
            return new XAResourceHolderState(recoveryXAResourceHolder, this);
        }
    }
View Full Code Here

    public static void recover(XAResourceProducer xaResourceProducer) throws RecoveryException {
        String uniqueName = xaResourceProducer.getUniqueName();
        if (log.isDebugEnabled()) log.debug("start of incremental recovery on resource " + uniqueName);

        try {
            XAResourceHolderState xaResourceHolderState = xaResourceProducer.startRecovery();
            boolean success = true;
            Set xids = RecoveryHelper.recover(xaResourceHolderState);
            if (log.isDebugEnabled()) log.debug(xids.size() + " dangling transaction(s) found on resource");
            Map danglingRecords = TransactionManagerServices.getJournal().collectDanglingRecords();
            if (log.isDebugEnabled()) log.debug(danglingRecords.size() + " dangling transaction(s) found in journal");
View Full Code Here

            if (currentTransaction.timedOut())
                throw new BitronixSystemException("transaction timed out");

            // in case multiple unjoined branches of the current transaction have run on the resource,
            // only the last one counts as all the first ones are ended already
            XAResourceHolderState alreadyEnlistedXAResourceHolderState = TransactionContextHelper.getLatestAlreadyEnlistedXAResourceHolderState(xaResourceHolder, currentTransaction);
            if (alreadyEnlistedXAResourceHolderState == null || alreadyEnlistedXAResourceHolderState.isEnded()) {
                currentTransaction.enlistResource(xaResourceHolder.getXAResource());
            }
            else if (log.isDebugEnabled()) log.debug("avoiding re-enlistment of already enlisted but not ended resource " + alreadyEnlistedXAResourceHolderState);
        }
        else {
View Full Code Here

        // with resources fully supporting transaction interleaving.
        if (isInEnlistingGlobalTransactionContext(xaResourceHolder, currentTransaction) && !bean.getDeferConnectionRelease()) {
            Map statesForGtrid = xaResourceHolder.getXAResourceHolderStatesForGtrid(currentTransaction.getResourceManager().getGtrid());
            Iterator statesForGtridIt = statesForGtrid.values().iterator();
            while (statesForGtridIt.hasNext()) {
                XAResourceHolderState xaResourceHolderState = (XAResourceHolderState) statesForGtridIt.next();

                if (!xaResourceHolderState.isEnded()) {
                    if (log.isDebugEnabled()) log.debug("delisting resource " + xaResourceHolderState + " from " + currentTransaction);

                    // Watch out: the delistResource() call might throw a BitronixRollbackSystemException to indicate a unilateral rollback.
                    currentTransaction.delistResource(xaResourceHolderState.getXAResource(), XAResource.TMSUCCESS);
                }
                else if (log.isDebugEnabled()) log.debug("avoiding delistment of not enlisted resource " + xaResourceHolderState);
            }

        } // isInEnlistingGlobalTransactionContext
View Full Code Here

        Map statesForGtrid = xaResourceHolder.getXAResourceHolderStatesForGtrid(currentTransaction.getResourceManager().getGtrid());
        if (statesForGtrid == null)
            return null;
        Iterator statesForGtridIt = statesForGtrid.values().iterator();

        XAResourceHolderState result = null;

        // iteration order is guraranteed so just take the latest matching one in the iterator
        while (statesForGtridIt.hasNext()) {
            XAResourceHolderState xaResourceHolderState = (XAResourceHolderState) statesForGtridIt.next();

            if (xaResourceHolderState != null && xaResourceHolderState.getXid() != null) {
                BitronixXid bitronixXid = xaResourceHolderState.getXid();
                Uid resourceGtrid = bitronixXid.getGlobalTransactionIdUid();
                Uid currentTransactionGtrid = currentTransaction.getResourceManager().getGtrid();

                if (currentTransactionGtrid.equals(resourceGtrid)) {
                    result = xaResourceHolderState;
View Full Code Here

            while (statesForGtridIt.hasNext()) {
                Map statesForGtrid = (Map) statesForGtridIt.next();

                Iterator statesForBqualIt = statesForGtrid.values().iterator();
                while (statesForBqualIt.hasNext()) {
                    XAResourceHolderState otherXaResourceHolderState = (XAResourceHolderState) statesForBqualIt.next();

                    if (otherXaResourceHolderState.getXAResource() == xaResourceHolder.getXAResource()) {
                        if (log.isDebugEnabled()) log.debug("resource " + xaResourceHolder + " is enlisted in another transaction with " + otherXaResourceHolderState.getXid().toString());
                        return true;
                    }
                }
            }
View Full Code Here

            if (statesForGtrid == null)
                return false;

            Iterator statesForBqualIt = statesForGtrid.values().iterator();
            while (statesForBqualIt.hasNext()) {
                XAResourceHolderState xaResourceHolderState = (XAResourceHolderState) statesForBqualIt.next();

                if (xaResourceHolderState != null &&
                        xaResourceHolderState.isStarted() &&
                        !xaResourceHolderState.isSuspended() &&
                        !xaResourceHolderState.isEnded())
                    return true;
            }
            return false;
        }
    }
View Full Code Here

            throw new RecoveryException("recovery already in progress on " + this);

        try {
            recoveryConnectionHandle = (JdbcConnectionHandle) pool.getConnectionHandle(false);
            recoveryXAResourceHolder = recoveryConnectionHandle.getPooledConnection().createRecoveryXAResourceHolder();
            return new XAResourceHolderState(recoveryConnectionHandle.getPooledConnection(), this);
        } catch (Exception ex) {
            throw new RecoveryException("cannot start recovery on " + this, ex);
        }
    }
View Full Code Here

        try {
            recoveryConnectionHandle = (JmsConnectionHandle) pool.getConnectionHandle(false);
            recoveryPooledConnection = recoveryConnectionHandle.getPooledConnection();
            recoveryXAResourceHolder = recoveryPooledConnection.createRecoveryXAResourceHolder();
            return new XAResourceHolderState(recoveryXAResourceHolder, recoveryPooledConnection.getPoolingConnectionFactory());
        } catch (Exception ex) {
            throw new RecoveryException("error starting recovery", ex);
        }
    }
View Full Code Here

TOP

Related Classes of bitronix.tm.internal.XAResourceHolderState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.