Package bitronix.tm.internal

Examples of bitronix.tm.internal.XAResourceHolderState


     * @throws RecoveryException if an error preventing recovery happened.
     */
    private boolean commit(String uniqueName, Xid xid) throws RecoveryException {
        XAResourceProducer producer = registeredResources.get(uniqueName);
        try {
            XAResourceHolderState xaResourceHolderState = producer.startRecovery();
            return RecoveryHelper.commit(xaResourceHolderState, xid);
        } finally {
            producer.endRecovery();
        }
    }
View Full Code Here


            if (log.isDebugEnabled()) { log.debug("resource " + uniqueName + " has not recovered, skipping rollback"); }
            return false;
        }

        try {
            XAResourceHolderState xaResourceHolderState = producer.startRecovery();
            return RecoveryHelper.rollback(xaResourceHolderState, xid);
        } finally {
            producer.endRecovery();
        }
    }
View Full Code Here

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

public class SchedulerTest extends TestCase {

    public void testNaturalOrdering() throws Exception {
        Scheduler<XAResourceHolderState> resourceScheduler = new Scheduler<XAResourceHolderState>();

        XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(1));
        XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1));
        XAResourceHolderState xarhs2 = new XAResourceHolderState(null, new MockResourceBean(1));
        XAResourceHolderState xarhs3 = new XAResourceHolderState(null, new MockResourceBean(0));
        XAResourceHolderState xarhs4 = new XAResourceHolderState(null, new MockResourceBean(10));

        resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs2, xarhs2.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs3, xarhs3.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs4, xarhs4.getTwoPcOrderingPosition());

        assertEquals("a Scheduler with 5 object(s) in 3 position(s)", resourceScheduler.toString());

        /* testing natural order priorities */
        assertEquals(5, resourceScheduler.size());
View Full Code Here

    }

    public void testReverseOrdering() throws Exception {
        Scheduler<XAResourceHolderState> resourceScheduler = new Scheduler<XAResourceHolderState>();

        XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(1));
        XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1));
        XAResourceHolderState xarhs2 = new XAResourceHolderState(null, new MockResourceBean(1));
        XAResourceHolderState xarhs3 = new XAResourceHolderState(null, new MockResourceBean(0));
        XAResourceHolderState xarhs4 = new XAResourceHolderState(null, new MockResourceBean(10));

        resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs2, xarhs2.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs3, xarhs3.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs4, xarhs4.getTwoPcOrderingPosition());

        assertEquals("a Scheduler with 5 object(s) in 3 position(s)", resourceScheduler.toString());

        Set<Integer> reverseOrderPriorities = resourceScheduler.getReverseOrderPositions();
        assertEquals(3, reverseOrderPriorities.size());
View Full Code Here

    }

    public void testIterator() {
        Scheduler<XAResourceHolderState> resourceScheduler = new Scheduler<XAResourceHolderState>();

        XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(1));
        XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1));
        XAResourceHolderState xarhs2 = new XAResourceHolderState(null, new MockResourceBean(1));
        XAResourceHolderState xarhs3 = new XAResourceHolderState(null, new MockResourceBean(0));
        XAResourceHolderState xarhs4 = new XAResourceHolderState(null, new MockResourceBean(10));

        resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs2, xarhs2.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs3, xarhs3.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs4, xarhs4.getTwoPcOrderingPosition());

        assertEquals("a Scheduler with 5 object(s) in 3 position(s)", resourceScheduler.toString());

        Iterator<XAResourceHolderState> it = resourceScheduler.iterator();
        assertTrue(it.hasNext());
View Full Code Here

    }

    public void testReverseIterator() {
        Scheduler<XAResourceHolderState> resourceScheduler = new Scheduler<XAResourceHolderState>();

        XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(1));
        XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1));
        XAResourceHolderState xarhs2 = new XAResourceHolderState(null, new MockResourceBean(1));
        XAResourceHolderState xarhs3 = new XAResourceHolderState(null, new MockResourceBean(0));
        XAResourceHolderState xarhs4 = new XAResourceHolderState(null, new MockResourceBean(10));

        resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs2, xarhs2.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs3, xarhs3.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs4, xarhs4.getTwoPcOrderingPosition());

        assertEquals("a Scheduler with 5 object(s) in 3 position(s)", resourceScheduler.toString());

        Iterator it = resourceScheduler.reverseIterator();
        assertTrue(it.hasNext());
View Full Code Here

    }

    public void testRemove() {
        Scheduler<XAResourceHolderState> resourceScheduler = new Scheduler<XAResourceHolderState>();

        XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(0));
        XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1));

        resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition());

        resourceScheduler.remove(xarhs0);
        resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition());

        Iterator<XAResourceHolderState> it = resourceScheduler.iterator();
View Full Code Here

    }

    public void testReverseRemove() {
        Scheduler<XAResourceHolderState> resourceScheduler = new Scheduler<XAResourceHolderState>();

        XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(0));
        XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1));

        resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition());

        resourceScheduler.remove(xarhs0);
        resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition());

        Iterator<XAResourceHolderState> it = resourceScheduler.reverseIterator();
View Full Code Here

    }

    public void testHasNext() {
        Scheduler<XAResourceHolderState> resourceScheduler = new Scheduler<XAResourceHolderState>();

        XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(0));
        XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(10));

        resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition());
        resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition());


        Iterator<XAResourceHolderState> it = resourceScheduler.iterator();

        for (int i=0; i<10 ;i++) {
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.