Package bitronix.tm.utils

Examples of bitronix.tm.utils.Uid


          @Override
          public void run() {
            try {
              SortedSet<String> set = csvToSet(String.format("%d.name1,%d.name2,%d.name3", ndx, ndx, ndx));
              for (int i = 1; i < 40000; i++) {
                Uid gtrid = UidGenerator.generateUid();
                journal.log(Status.STATUS_COMMITTING, gtrid, set);
                        journal.force();
               
                journal.log(Status.STATUS_COMMITTED, gtrid, csvToSet(ndx + ".name1"));
                journal.log(Status.STATUS_COMMITTED, gtrid, csvToSet(ndx + ".name2"));
View Full Code Here


            @Override
            public void run() {
                try {
                    SortedSet<String> set = csvToSet(String.format("%d.name1,%d.name2,%d.name3", ndx, ndx, ndx));
                    for (int i = 1; i < count; i++) {
                        Uid gtrid = UidGenerator.generateUid();
                        journal.log(Status.STATUS_COMMITTING, gtrid, set);
                       
                        journal.log(Status.STATUS_COMMITTED, gtrid, csvToSet(ndx + ".name1"));
                        journal.log(Status.STATUS_COMMITTED, gtrid, csvToSet(ndx + ".name2"));
                        journal.log(Status.STATUS_COMMITTED, gtrid, csvToSet(ndx + ".name3"));
View Full Code Here

          @Override
          public void run() {
            try {
              SortedSet<String> set = csvToSet(String.format("%d.name1,%d.name2,%d.name3", ndx, ndx, ndx));
              for (int i = 1; i < 40000; i++) {
                Uid gtrid = UidGenerator.generateUid();
                journal.log(Status.STATUS_COMMITTING, gtrid, set);
                        journal.force();
               
                journal.log(Status.STATUS_COMMITTED, gtrid, csvToSet(ndx + ".name1"));
                journal.log(Status.STATUS_COMMITTED, gtrid, csvToSet(ndx + ".name2"));
View Full Code Here

            public Date getLastReleaseDate() {
                return null;
            }
        };

        Uid gtrid = UidGenerator.generateUid();

        XAResourceHolderState state1 = new XAResourceHolderState(xaResourceHolder, resourceBean);
        XAResourceHolderState state2 = new XAResourceHolderState(xaResourceHolder, resourceBean);
        XAResourceHolderState state3 = new XAResourceHolderState(xaResourceHolder, resourceBean);
View Full Code Here

        Xid xid2 = new MockXid(2, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID);
        xaResource.addInDoubtXid(xid2);

        Set names = new HashSet();
        names.add(pds.getUniqueName());
        journal.log(Status.STATUS_COMMITTING, new Uid(xid0.getGlobalTransactionId()), names);
        journal.log(Status.STATUS_COMMITTING, new Uid(xid1.getGlobalTransactionId()), names);
        journal.log(Status.STATUS_COMMITTING, new Uid(xid2.getGlobalTransactionId()), names);
        TransactionManagerServices.getRecoverer().run();

        assertEquals(3, TransactionManagerServices.getRecoverer().getCommittedCount());
        assertEquals(0, TransactionManagerServices.getRecoverer().getRolledbackCount());
        assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length);
View Full Code Here

        Xid xid2 = new MockXid(2, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID);
        xaResource.addInDoubtXid(xid2);

        Set names = new HashSet();
        names.add(pds.getUniqueName());
        journal.log(Status.STATUS_COMMITTING, new Uid(xid0.getGlobalTransactionId()), names);
        journal.log(Status.STATUS_COMMITTING, new Uid(xid1.getGlobalTransactionId()), names);
        journal.log(Status.STATUS_COMMITTING, new Uid(xid2.getGlobalTransactionId()), names);

        IncrementalRecoverer.recover(pds);

        assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length);
    }
View Full Code Here

    }

    public void testSkipInFlightRollback() throws Exception {
        BitronixTransactionManager btm = TransactionManagerServices.getTransactionManager();

        Uid uid0 = UidGenerator.generateUid();
        Xid xid0 = new MockXid(0, uid0.getArray(), BitronixXid.FORMAT_ID);
        xaResource.addInDoubtXid(xid0);

        assertNull(btm.getCurrentTransaction());
        Thread.sleep(30); // let the clock run a bit so that in-flight TX is a bit older than the journaled one
        btm.begin();
View Full Code Here

    }

    public void testSkipInFlightCommit() throws Exception {
        BitronixTransactionManager btm = TransactionManagerServices.getTransactionManager();

        Uid uid0 = UidGenerator.generateUid();
        Xid xid0 = new MockXid(0, uid0.getArray(), BitronixXid.FORMAT_ID);
        xaResource.addInDoubtXid(xid0);
        Set names = new HashSet();
        names.add(pds.getUniqueName());
        journal.log(Status.STATUS_COMMITTING, new Uid(xid0.getGlobalTransactionId()), names);

        assertNull(btm.getCurrentTransaction());
        Thread.sleep(30); // let the clock run a bit so that in-flight TX is a bit older than the journaled one
        btm.begin();

        Xid xid1 = new MockXid(1, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID);
        xaResource.addInDoubtXid(xid1);

        names = new HashSet();
        names.add(pds.getUniqueName());
        journal.log(Status.STATUS_COMMITTING, new Uid(xid1.getGlobalTransactionId()), names);

        TransactionManagerServices.getRecoverer().run();

        btm.rollback();
View Full Code Here

        final Xid xid0 = new MockXid(0, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID);
        xaResource.addInDoubtXid(xid0);

        Set names = new HashSet();
        names.add("no-such-registered-resource");
        journal.log(Status.STATUS_COMMITTING, new Uid(xid0.getGlobalTransactionId()), names);
        assertEquals(1, TransactionManagerServices.getJournal().collectDanglingRecords().size());

        // the TM must run the recoverer in this scenario
        TransactionManagerServices.getTransactionManager();

        assertEquals(1, TransactionManagerServices.getJournal().collectDanglingRecords().size());
        assertNull(TransactionManagerServices.getRecoverer().getCompletionException());
        assertEquals(0, TransactionManagerServices.getRecoverer().getCommittedCount());
        assertEquals(1, TransactionManagerServices.getRecoverer().getRolledbackCount());
        assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length);


        // the TM is running, adding this resource will kick incremental recovery on it
        PoolingDataSource pds = new PoolingDataSource() {
            public XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean) throws Exception {
                JdbcPooledConnection pc = (JdbcPooledConnection) super.createPooledConnection(xaFactory, bean);
                MockXAResource xaResource = (MockXAResource) pc.getXAResource();
                xaResource.addInDoubtXid(UidGenerator.generateXid(new Uid(xid0.getGlobalTransactionId())));
                return pc;
            }
        };
        pds.setClassName(MockitoXADataSource.class.getName());
        pds.setUniqueName("no-such-registered-resource");
View Full Code Here

        HashMap redundantGtrids = new HashMap();

        for (int i = 0; i < transactionTableModel.getRowCount(); i++) {
            JournalRecord tlog = transactionTableModel.getRow(i);
            if (tlog.getStatus() == Status.STATUS_COMMITTING) {
                Uid gtrid = tlog.getGtrid();
                if (gtrids.containsKey(gtrid)) {
                    java.util.List tlogs = (java.util.List) gtrids.get(gtrid);
                    tlogs.add(tlog);
                    redundantGtrids.put(gtrid, tlogs);
                }
View Full Code Here

TOP

Related Classes of bitronix.tm.utils.Uid

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.