Package com.taobao.metamorphosis.transaction

Examples of com.taobao.metamorphosis.transaction.TransactionId



    @Test
    public void testBeginPutPutCloseRecoverGetPreparedTransactionsCommit() throws Exception {
        final SessionContext context = new SessionContextImpl("test", this.conn);
        final TransactionId xid = XIDGenerator.createXID(100);
        assertNull(context.getTransactions().get(xid));
        this.processor.beginTransaction(context, xid, 0);
        this.replay();

        this.processor.processPutCommand(new PutCommand("topic1", 2, "hello".getBytes(), xid, 0, 1), context, null);
View Full Code Here



    @Test
    public void testBeginPutRollback() throws Exception {
        final SessionContext context = new SessionContextImpl("test", this.conn);
        final TransactionId xid = new LocalTransactionId("test", 100);
        assertNull(context.getTransactions().get(xid));
        this.processor.beginTransaction(context, xid, 0);
        final Transaction tx = context.getTransactions().get(xid);
        assertNotNull(tx);
        assertSame(xid, tx.getTransactionId());
View Full Code Here


    @Test
    public void testBeginPutPrepareRollbackCloseRecover() throws Exception {
        final SessionContext context = new SessionContextImpl("test", this.conn);
        final TransactionId xid = XIDGenerator.createXID(100);
        assertNull(context.getTransactions().get(xid));
        this.processor.beginTransaction(context, xid, 0);
        final Transaction tx = this.processor.getTransaction(context, xid);
        assertNotNull(tx);
        assertSame(xid, tx.getTransactionId());
View Full Code Here


    @Test
    public void testCommitTransactionHeuristicallyRecoverHeuristicTransactions() throws Exception {
        final SessionContext context = new SessionContextImpl("test", this.conn);
        final TransactionId xid = XIDGenerator.createXID(100);
        assertNull(context.getTransactions().get(xid));
        this.processor.beginTransaction(context, xid, 0);
        final Transaction tx = this.processor.getTransaction(context, xid);
        assertNotNull(tx);
        assertSame(xid, tx.getTransactionId());
        this.replay();

        this.processor.processPutCommand(new PutCommand("topic1", 2, "hello".getBytes(), xid, 0, 1), context, null);
        final MessageStore store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
        store.flush();
        assertEquals(0, store.getSizeInBytes());

        // prepare
        this.processor.prepareTransaction(context, xid);
        assertSame(tx, this.processor.getTransaction(context, xid));

        // �ֹ��ύ
        this.processor.commitTransactionHeuristically(xid.getTransactionKey(), false);
        Map<TransactionId, XATransaction> heuristicTxMap = this.processor.getXAHeuristicTransactions();
        assertFalse(heuristicTxMap.isEmpty());
        assertTrue(heuristicTxMap.containsKey(xid));
        assertSame(tx, heuristicTxMap.get(xid));
        assertEquals(Transaction.HEURISTIC_COMMIT_STATE, heuristicTxMap.get(xid).getState());
View Full Code Here

                // transaction key sessionId type [timeout] [unique qualifier]
                // opaque\r\n
                private Object decodeTransaction(final String[] sa) {
                    this.assertCommand(sa[0], "transaction");
                    final TransactionId transactionId = this.getTransactionId(sa[1]);
                    final TransactionType type = TransactionType.valueOf(sa[3]);
                    switch (sa.length) {
                    case 7:
                        // Both include timeout and unique qualifier.
                        int timeout = Integer.valueOf(sa[4]);
View Full Code Here


    private int replayTx(final long offset, final long cmdBufLen, final TxCommand txCmd, final DataFile dataFile)
            throws InvalidProtocolBufferException {
        final TransactionOperation command = TransactionOperation.parseFrom(txCmd.getCmdContent());
        final TransactionId xid = TransactionId.valueOf(command.getTransactionId());
        try {
            // �ط�������־
            switch (command.getType()) {
            case XA_PREPARE:
                this.transactionStore.replayPrepare(xid);
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.transaction.TransactionId

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.