Package com.taobao.metamorphosis.transaction

Examples of com.taobao.metamorphosis.transaction.TransactionId


    @Test
    public void testLocalBeginCommit() throws Exception {
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);
        final TransactionId id = new LocalTransactionId(this.sessionId, 1);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.BEGIN), null);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.COMMIT_ONE_PHASE),
            null);
        assertNull(this.context.getTransactionId());
        assertFalse(this.context.isInTransaction());
        OpaqueGenerator.resetOpaque();
        this.replay();
        this.context.begin();
        final TransactionId xid = this.context.getTransactionId();
        assertNotNull(xid);
        assertTrue(xid.isLocalTransaction());
        assertTrue(this.context.isInLocalTransaction());
        assertFalse(this.context.isInXATransaction());
        assertTrue(this.context.isInTransaction());

        this.context.commit();
View Full Code Here


    @Test
    public void testLocalBeginRollback() throws Exception {
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);
        final TransactionId id = new LocalTransactionId(this.sessionId, 1);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.BEGIN), null);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.ROLLBACK), null);
        assertNull(this.context.getTransactionId());
        assertFalse(this.context.isInTransaction());
        OpaqueGenerator.resetOpaque();
        this.replay();
        this.context.begin();
        final TransactionId xid = this.context.getTransactionId();
        assertNotNull(xid);
        assertTrue(xid.isLocalTransaction());
        assertTrue(this.context.isInLocalTransaction());
        assertFalse(this.context.isInXATransaction());
        assertTrue(this.context.isInTransaction());

        this.context.rollback();
View Full Code Here

        assertFalse(this.context.isInTransaction());
        OpaqueGenerator.resetOpaque();
        this.replay();
        this.context.start(id, XAResource.TMNOFLAGS);

        final TransactionId xid = this.context.getTransactionId();
        assertNotNull(xid);
        assertEquals(id, xid);
        assertFalse(xid.isLocalTransaction());
        assertFalse(this.context.isInLocalTransaction());
        assertTrue(this.context.isInXATransaction());
        assertTrue(this.context.isInTransaction());
    }
View Full Code Here

    }


    @Test
    public void testDecodeOldPutCommand_HasTransactionId() {
        final TransactionId xid = new LocalTransactionId("test", 100);
        final PutCommand putCommand = new PutCommand("test", 1, "hello".getBytes(), xid, 0, 0);

        final PutCommand decodedCmd =
                (PutCommand) this.decoder.decode(IoBuffer.wrap("put test 1 5 0 TX:test:100 0\r\nhello".getBytes()),
                    null);
View Full Code Here

    }


    @Test
    public void testDecodeNewPutCommand_HasTransactionId() {
        final TransactionId xid = new LocalTransactionId("test", 100);
        final PutCommand putCommand = new PutCommand("test", 1, "hello".getBytes(), 0, 9999, xid, 0);

        final PutCommand decodedCmd =
                (PutCommand) this.decoder.decode(
                    IoBuffer.wrap("put test 1 5 0 9999 TX:test:100 0\r\nhello".getBytes()), null);
View Full Code Here


    @Override
    public void handleRequest(final TransactionCommand request, final Connection conn) {

        final TransactionId xid = request.getTransactionInfo().getTransactionId();
        final SessionContext context = SessionContextHolder.getOrCreateSessionContext(conn, xid);

        if (log.isDebugEnabled()) {
            log.debug(request);
        }
View Full Code Here


    @Test
    public void testBeginPutCommitOnePhase() 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 testSetTransactionTimeout() throws Exception {
        final SessionContext context = new SessionContextImpl("test", this.conn);
        final TransactionId xid = XIDGenerator.createXID(100);
        assertNull(context.getTransactions().get(xid));
        // ��������ʱ
        // this.processor.setTransactionTimeout(context, xid, 3);
        this.replay();
        this.processor.beginTransaction(context, xid, 3);
View Full Code Here


    @Test
    public void testBeginPreparedCommitTwoPhase() 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(expected = XAException.class)
    public void testPutNotBeginTransaction() throws Exception {
        final SessionContext context = new SessionContextImpl("test", this.conn);
        final TransactionId xid = XIDGenerator.createXID(100);
        this.replay();
        this.processor.processPutCommand(new PutCommand("topic1", 2, "hello".getBytes(), xid, 0, 1), context, null);
    }
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.