Package bitronix.tm.utils

Examples of bitronix.tm.utils.Uid


            if (log.isDebugEnabled()) { log.debug(danglingRecords.size() + " dangling transaction(s) found in journal"); }

            int commitCount = 0;
            int rollbackCount = 0;
            for (BitronixXid xid : xids) {
                Uid gtrid = xid.getGlobalTransactionIdUid();

                JournalRecord tlog = (JournalRecord) danglingRecords.get(gtrid);
                if (tlog != null) {
                    if (log.isDebugEnabled()) { log.debug("committing " + xid); }
                    success &= RecoveryHelper.commit(xaResourceHolderState, xid);
View Full Code Here


        }

        final byte[] gtridArray = new byte[gtridSize];
        page.get(gtridArray);
        currentPosition += gtridSize;
        Uid gtrid = new Uid(gtridArray);
        final int uniqueNamesCount = page.getInt();
        currentPosition += 4;
        Set<String> uniqueNames = new HashSet<String>();
        int currentReadCount = 4 + 8 + 4 + 4 + 1 + gtridSize + 4;
View Full Code Here

        if (log.isDebugEnabled()) { log.debug("found " + danglingRecords.size() + " dangling record(s) in journal"); }
        Iterator<Map.Entry<Uid, JournalRecord>> it = danglingRecords.entrySet().iterator();
        while (it.hasNext()) {
            Entry<Uid, JournalRecord> entry = it.next();
            Uid gtrid = (Uid) entry.getKey();
            JournalRecord tlog = (JournalRecord) entry.getValue();

            Set<String> uniqueNames = tlog.getUniqueNames();
            Set<DanglingTransaction> danglingTransactions = getDanglingTransactionsInRecoveredXids(uniqueNames, tlog.getGtrid());

            long txTimestamp = gtrid.extractTimestamp();
            if (log.isDebugEnabled()) { log.debug("recovered XID timestamp: " + txTimestamp + " - oldest in-flight TX timestamp: " + oldestTransactionTimestamp); }

            if (txTimestamp < oldestTransactionTimestamp) {
                if (log.isDebugEnabled()) { log.debug("committing dangling transaction with GTRID " + gtrid); }
                commit(danglingTransactions);
View Full Code Here

     * @throws IOException if an I/O error occurs.
     */
    protected void writeLog(TransactionLogRecord tlog) throws IOException {
        try {
            int status = tlog.getStatus();
            Uid gtrid = tlog.getGtrid();

          int recordSize = tlog.calculateTotalRecordSize();
            ByteBuffer buf = ByteBuffer.allocate(recordSize);
            buf.putInt(tlog.getStatus());
            buf.putInt(tlog.getRecordLength());
            buf.putInt(tlog.getHeaderLength());
            buf.putLong(tlog.getTime());
            buf.putInt(tlog.getSequenceNumber());
            buf.putInt(tlog.getCrc32());
            buf.put((byte) gtrid.getArray().length);
            buf.put(gtrid.getArray());
            Set<String> uniqueNames = tlog.getUniqueNames();
            buf.putInt(uniqueNames.size());
            for (String uniqueName : uniqueNames) {
                buf.putShort((short) uniqueName.length());
                buf.put(uniqueName.getBytes());
View Full Code Here

    }

    public void testSimpleCollectDanglingRecords() throws Exception {
        DiskJournal journal = new DiskJournal();
        journal.open();
        Uid gtrid = UidGenerator.generateUid();

        assertEquals(0, journal.collectDanglingRecords().size());

        journal.log(Status.STATUS_COMMITTING, gtrid, csvToSet("name1"));
        assertEquals(1, journal.collectDanglingRecords().size());
View Full Code Here

    }

    public void testComplexCollectDanglingRecords() throws Exception {
        DiskJournal journal = new DiskJournal();
        journal.open();
        Uid gtrid1 = UidGenerator.generateUid();
        Uid gtrid2 = UidGenerator.generateUid();

        assertEquals(0, journal.collectDanglingRecords().size());

        journal.log(Status.STATUS_COMMITTING, gtrid1, csvToSet("name1,name2,name3"));
        assertEquals(1, journal.collectDanglingRecords().size());
View Full Code Here

    }

    public void testCorruptedCollectDanglingRecords() throws Exception {
        DiskJournal journal = new DiskJournal();
        journal.open();
        Uid gtrid1 = UidGenerator.generateUid();
        Uid gtrid2 = UidGenerator.generateUid();

        assertEquals(0, journal.collectDanglingRecords().size());

        journal.log(Status.STATUS_COMMITTING, gtrid1, csvToSet("name1,name2,name3"));
        assertEquals(1, journal.collectDanglingRecords().size());
View Full Code Here

            String substr = uidString.substring(i*2, i*2+2);
            byte b = (byte)Integer.parseInt(substr, 16);

            uidArray[i] = b;
        }
        Uid uid = new Uid(uidArray);

        TransactionLogRecord tlr = new TransactionLogRecord(Status.STATUS_COMMITTED, 116, 28, 1220609394845L, 38266, -1380478121, uid, names, TransactionLogAppender.END_RECORD);
        boolean correct = tlr.isCrc32Correct();
        assertTrue("CRC32 values did not match", correct);

View Full Code Here

        DiskJournal journal = new DiskJournal();
        journal.open();

        List<Uid> uncommitted = new ArrayList<Uid>();
        for (int i = 1; i < 4000; i++) {
          Uid gtrid = UidGenerator.generateUid();
          journal.log(Status.STATUS_COMMITTING, gtrid, csvToSet("name1,name2,name3"));

          if (i < 3600)
          {
            journal.log(Status.STATUS_COMMITTED, gtrid, csvToSet("name1"));
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

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.