Package com.taobao.metamorphosis.transaction

Examples of com.taobao.metamorphosis.transaction.LocalTransactionId


    }


    @Test
    public void testAddAddCommitCloseRecover() throws Exception {
        final LocalTransactionId xid = new LocalTransactionId("test", 1);
        MessageStore store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
        this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg1".getBytes(), xid, 0, 1), null);
        this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg2".getBytes(), xid, 0, 2), null);

        final Tx tx = this.transactionStore.getInflyTx(xid);
View Full Code Here


    }


    @Test
    public void testBeginCommitCloseRecover() throws Exception {
        final LocalTransactionId xid = new LocalTransactionId("test", 1);
        this.transactionStore.commit(xid, false);
        assertNull(this.transactionStore.getInflyTx(xid));
        this.tearDown();
        this.init(this.path);
        assertNull(this.transactionStore.getInflyTx(xid));
View Full Code Here


    @Test
    public void testCheckpoint() throws Exception {
        // ����1
        final LocalTransactionId xid1 = new LocalTransactionId("session1", 1);
        final MessageStore store1 = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
        this.transactionStore.addMessage(store1, 1, new PutCommand("topic1", 2, ("msg" + 2).getBytes(), xid1, 0, 1),
            null);

        // ����2
        final LocalTransactionId xid2 = new LocalTransactionId("session2", 1);
        final MessageStore store2 = this.messageStoreManager.getOrCreateMessageStore("topic1", 3);
        this.transactionStore.addMessage(store2, 1, new PutCommand("topic1", 3, ("msg" + 3).getBytes(), xid2, 0, 1),
            null);

        // ����3���Ѿ��ύ
        final LocalTransactionId xid3 = new LocalTransactionId("session3", 1);
        final MessageStore store3 = this.messageStoreManager.getOrCreateMessageStore("topic1", 0);
        this.transactionStore.addMessage(store3, 1, new PutCommand("topic1", 0, ("msg" + 0).getBytes(), xid3, 0, 1),
            null);
        this.transactionStore.commit(xid3, false);
View Full Code Here

        final ConcurrentTestCase testCase = new ConcurrentTestCase(100, 1000, new ConcurrentTestTask() {

            @Override
            public void run(final int index, final int times) throws Exception {
                final int id = gen.incrementAndGet();
                final LocalTransactionId xid = new LocalTransactionId("test", id);
                for (int j = 0; j < rand.nextInt(3) + 1; j++) {
                    final int partition = rand.nextInt(10);
                    final MessageStore store =
                            JournalTransactionStoreUnitTest.this.messageStoreManager.getOrCreateMessageStore("topic1",
                                partition % 10);
View Full Code Here

        final int oldSize = JournalStore.MAX_FILE_SIZE;
        JournalStore.MAX_FILE_SIZE = 512;
        try {
            this.init(this.path);
            for (int i = 0; i < 10000; i++) {
                final LocalTransactionId xid = new LocalTransactionId("test", i);
                // �漴��Ӽ�����Ϣ
                for (int j = 0; j < rand.nextInt(3) + 1; j++) {
                    final int partition = rand.nextInt(10);
                    final MessageStore store =
                            this.messageStoreManager.getOrCreateMessageStore("topic1", partition % 10);
View Full Code Here

    @Test
    public void testAddManyCheckpointRecover() throws Exception {
        final Random rand = new Random();
        for (int i = 0; i < 10000; i++) {
            final LocalTransactionId xid = new LocalTransactionId("test", i);

            // �漴��Ӽ�����Ϣ
            for (int j = 0; j < rand.nextInt(3) + 1; j++) {
                final int partition = rand.nextInt(10);
                final MessageStore store = this.messageStoreManager.getOrCreateMessageStore("topic1", partition % 10);
View Full Code Here

    }


    @Test
    public void testAddAddCommit_CloseReplayAppend_CloseRecover() throws Exception {
        final LocalTransactionId xid = new LocalTransactionId("test", 1);
        MessageStore store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
        this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg1".getBytes(), xid, 0, 1), null);
        this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg2".getBytes(), xid, 0, 2), null);
        assertNotNull(this.transactionStore.getInflyTx(xid));
View Full Code Here

public class SessionContextHolderUnitTest {

    @Test
    public void testGetOrCreateSessionContext_LocalTransactionId() {
        final Connection conn = EasyMock.createMock(Connection.class);
        final LocalTransactionId xid = new LocalTransactionId("test", 1);
        EasyMock.expect(conn.getAttribute("test")).andReturn(null);
        EasyMock.expect(conn.setAttributeIfAbsent("test", new SessionContextImpl("test", conn))).andReturn(null);
        EasyMock.replay(conn);

        final SessionContext ctx = SessionContextHolder.getOrCreateSessionContext(conn, xid);
View Full Code Here

    }


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

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

    }


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

        final TransactionCommand cmd = new TransactionCommand(info, 100);
        final IoBuffer buf = cmd.encode();
        assertEquals("transaction TX:sessionId:99 sessionId BEGIN unique-qualifier 100\r\n", new String(buf.array()));
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.