Package com.taobao.metamorphosis.transaction

Examples of com.taobao.metamorphosis.transaction.LocalTransactionId


    }


    @Test
    public void testEncodeWithUniqueQualifierAndTimeout() {
        final TransactionId id = new LocalTransactionId("sessionId", 99);
        final TransactionInfo info = new TransactionInfo(id, "sessionId", TransactionType.BEGIN, "unique-qualifier", 3);

        final TransactionCommand cmd = new TransactionCommand(info, 100);
        final IoBuffer buf = cmd.encode();
        assertEquals("transaction TX:sessionId:99 sessionId BEGIN 3 unique-qualifier 100\r\n", new String(buf.array()));
View Full Code Here


    @Test
    public void testBeginTransactionCommit() throws Exception {
        this.producer.beginTransaction();
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(new LocalTransactionId(this.sessionId, 1),
            this.sessionId, TransactionType.BEGIN), null);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(new LocalTransactionId(this.sessionId, 1),
            this.sessionId, TransactionType.COMMIT_ONE_PHASE), null);
        this.mocksControl.replay();
        OpaqueGenerator.resetOpaque();
        this.producer.beforeSendMessageFirstTime(serverUrl);
        assertTrue(this.producer.isInTransaction());
View Full Code Here

    @Test
    public void testBeginTransactionRollback() throws Exception {
        this.producer.beginTransaction();
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(new LocalTransactionId(this.sessionId, 1),
            this.sessionId, TransactionType.BEGIN), null);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(new LocalTransactionId(this.sessionId, 1),
            this.sessionId, TransactionType.ROLLBACK), null);
        this.mocksControl.replay();
        OpaqueGenerator.resetOpaque();
        this.producer.beforeSendMessageFirstTime(serverUrl);
        assertTrue(this.producer.isInTransaction());
View Full Code Here

public class PutCommandUnitTest {

    @Test
    public void testEncode_HasTransactionId() {
        final TransactionId id = new LocalTransactionId("test", 1);
        final PutCommand putCommand = new PutCommand("test", 1, "hello".getBytes(), id, 0, 0);
        final IoBuffer buf = putCommand.encode();
        assertEquals(0, buf.position());
        assertEquals("put test 1 5 0 -1 TX:test:1 0\r\nhello", new String(buf.array()));
    }
View Full Code Here

    @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());
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();
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

        assertEquals(0, cmd.getTransactionInfo().getTimeout());
        final TransactionInfo info = cmd.getTransactionInfo();
        assertNotNull(info);
        assertNotNull(info.getTransactionId());
        assertTrue(info.getTransactionId().isLocalTransaction());
        final LocalTransactionId id = (LocalTransactionId) info.getTransactionId();
        assertEquals("sessionId", id.getSessionId());
        assertEquals(99, id.getValue());
    }
View Full Code Here

        assertEquals(3, cmd.getTransactionInfo().getTimeout());
        final TransactionInfo info = cmd.getTransactionInfo();
        assertNotNull(info);
        assertNotNull(info.getTransactionId());
        assertTrue(info.getTransactionId().isLocalTransaction());
        final LocalTransactionId id = (LocalTransactionId) info.getTransactionId();
        assertEquals("sessionId", id.getSessionId());
        assertEquals(99, id.getValue());
    }
View Full Code Here

TOP

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

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.