Examples of PutCommand


Examples of com.taobao.metamorphosis.network.PutCommand

    }


    @Test
    public void testAppendAppendCloseRecover() throws Exception {
        PutCommand message = new PutCommand("test", 0, "hello".getBytes(), null, 0, 0);
        final ByteBuffer buf1 = MessageUtils.makeMessageBuffer(1, message);
        assertEquals(0, this.fileMessageSet.append(buf1));

        message = new PutCommand("test", 0, "world".getBytes(), null, 0, 0);
        final ByteBuffer buf2 = MessageUtils.makeMessageBuffer(2, message);
        assertEquals(buf1.capacity(), this.fileMessageSet.append(buf2));

        this.fileMessageSet.flush();
        this.fileMessageSet.close();
View Full Code Here

Examples of com.taobao.metamorphosis.network.PutCommand

    }


    @Test
    public void testAppendAppendCloseRecoverTruncate() throws Exception {
        PutCommand message = new PutCommand("test", 0, "hello".getBytes(), null, 0, 0);
        ByteBuffer buf = MessageUtils.makeMessageBuffer(1, message);
        this.fileMessageSet.append(buf);

        message = new PutCommand("test", 0, "world".getBytes(), null, 0, 0);
        buf = MessageUtils.makeMessageBuffer(2, message);
        this.fileMessageSet.append(buf);
        this.fileMessageSet.append(ByteBuffer.wrap("temp".getBytes()));

        this.fileMessageSet.flush();
View Full Code Here

Examples of com.taobao.metamorphosis.network.PutCommand

        final MessageStore store2 = this.messageStoreManager.getMessageStore(topic, partition);
        assertSame(store1, store2);
        assertEquals(2048, store2.getMinOffset());

        final IdWorker idWorker = new IdWorker(0);
        final PutCommand cmd1 = new PutCommand(topic, partition, "hello".getBytes(), null, 0, 0);
        final PutCommand cmd2 = new PutCommand(topic, partition, "world".getBytes(), null, 0, 0);
        store1.append(idWorker.nextId(), cmd1, new AppendCallback() {

            @Override
            public void appendComplete(final Location location) {
                assertEquals(2048, location.getOffset());
View Full Code Here

Examples of com.taobao.metamorphosis.network.PutCommand

        }
        final CountDownLatch latch = new CountDownLatch(1000);
        for (int i = 0; i < 10; i++) {
            final MessageStore store = this.messageStoreManager.getOrCreateMessageStore(topic, i);
            for (int j = 0; j < 100; j++) {
                final PutCommand cmd = new PutCommand(topic, i, new byte[1024], null, 0, 0);
                final long id = idWorker.nextId();
                store.append(id, cmd, new AppendCallback() {

                    @Override
                    public void appendComplete(Location location) {
View Full Code Here

Examples of com.taobao.metamorphosis.network.PutCommand

        assertNull(this.messageStoreManager.getMessageStore(topic, partition));
        final MessageStore store = this.messageStoreManager.getOrCreateMessageStore(topic, partition);

        final IdWorker idWorker = new IdWorker(0);
        final byte[] data = new byte[1024];
        final PutCommand cmd1 = new PutCommand(topic, partition, data, null, 0, 0);
        final PutCommand cmd2 = new PutCommand(topic, partition, data, null, 0, 0);
        store.append(idWorker.nextId(), cmd1, new AppendCallback() {

            @Override
            public void appendComplete(final Location location) {
                assertEquals(0, location.getOffset());
View Full Code Here

Examples of com.taobao.metamorphosis.network.PutCommand

        final Transaction tx = context.getTransactions().get(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());

        // commit one phase
View Full Code Here

Examples of com.taobao.metamorphosis.network.PutCommand

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

        this.processor.prepareTransaction(context, xid);
View Full Code Here

Examples of com.taobao.metamorphosis.network.PutCommand

    @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

Examples of com.taobao.metamorphosis.network.PutCommand

        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);
        this.processor.processPutCommand(new PutCommand("topic1", 2, "world".getBytes(), xid, 0, 1), context, null);
        MessageStore store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
        store.flush();
        assertEquals(0, store.getSizeInBytes());

        assertEquals(0, this.processor.getPreparedTransactions(context, XIDGenerator.UNIQUE_QUALIFIER).length);
View Full Code Here

Examples of com.taobao.metamorphosis.network.PutCommand

        final Transaction tx = context.getTransactions().get(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());

        // rollback
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.