Package com.taobao.metamorphosis.network

Examples of com.taobao.metamorphosis.network.SyncCommand


        final int opaque = -1;
        final long offset = 1024L;
        final byte[] data = new byte[1024];
        final long msgId = 100000L;
        final int flag = MessageFlagUtils.getFlag(null);
        final SyncCommand request = new SyncCommand(this.topic, partition, data, flag, msgId, -1, opaque);

        final MessageStore store = this.mocksControl.createMock(MessageStore.class);
        EasyMock.expect(this.storeManager.getOrCreateMessageStore(this.topic, partition)).andReturn(store);
        final BooleanCommand expectResp =
                new BooleanCommand(HttpStatus.Success, msgId + " " + partition + " " + offset, opaque);
View Full Code Here


        final int partition = 1;
        final int opaque = -1;
        final byte[] data = new byte[1024];
        final int flag = MessageFlagUtils.getFlag(null);
        final long msgId = 100000L;
        final SyncCommand request = new SyncCommand(this.topic, partition, data, flag, msgId, -1, opaque);

        final MessageStore store = this.mocksControl.createMock(MessageStore.class);
        EasyMock.expect(this.storeManager.getOrCreateMessageStore(this.topic, partition)).andReturn(store);
        final AtomicBoolean invoked = new AtomicBoolean(false);
        final BooleanCommand expectResp =
                new BooleanCommand(
                    HttpStatus.InternalServerError,
                    "Put message to [broker 'meta://localhost:8123'] [partition 'GregorCommandProcessorUnitTest-1'] failed.",
                    request.getOpaque());
        final PutCallback cb = new PutCallback() {

            @Override
            public void putComplete(final ResponseCommand resp) {
                invoked.set(true);
View Full Code Here

        final int partition = 1;
        final int opaque = -1;
        final byte[] data = new byte[1024];
        final int flag = MessageFlagUtils.getFlag(null);
        final long msgId = 100000L;
        final SyncCommand request = new SyncCommand(this.topic, partition, data, flag, msgId, -1, opaque);

        final MessageStore store = this.mocksControl.createMock(MessageStore.class);
        EasyMock.expect(this.storeManager.getOrCreateMessageStore(this.topic, partition)).andReturn(store);
        final AtomicBoolean invoked = new AtomicBoolean(false);
        final BooleanCommand expectResp =
                new BooleanCommand(
                    HttpStatus.InternalServerError,
                    "Put message to [broker 'meta://localhost:8123'] [partition 'GregorCommandProcessorUnitTest-1'] failed.Detail:Mock exception",
                    request.getOpaque());
        final PutCallback cb = new PutCallback() {

            @Override
            public void putComplete(final ResponseCommand resp) {
                invoked.set(true);
View Full Code Here

                    .create(offset, 1024));
                return null;
            }

        });
        this.remotingClient.sendToGroup(this.slaveUrl, new SyncCommand(request.getTopic(), partition,
            request.getData(), request.getFlag(), msgId, CheckSum.crc32(data), OpaqueGenerator.getNextOpaque()), apdcb,
            this.commandProcessor.getSendToSlaveTimeoutInMills(), TimeUnit.MILLISECONDS);
        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {

            @Override
View Full Code Here

                    .create(offset, 1024));
                return null;
            }

        });
        this.remotingClient.sendToGroup(this.slaveUrl, new SyncCommand(request.getTopic(), partition,
            request.getData(), request.getFlag(), msgId, CheckSum.crc32(data), OpaqueGenerator.getNextOpaque()), apdcb,
            this.commandProcessor.getSendToSlaveTimeoutInMills(), TimeUnit.MILLISECONDS);
        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {

            @Override
View Full Code Here

                    .create(offset, 1024));
                return null;
            }

        });
        this.remotingClient.sendToGroup(this.slaveUrl, new SyncCommand(request.getTopic(), partition,
            request.getData(), request.getFlag(), msgId, CheckSum.crc32(data), OpaqueGenerator.getNextOpaque()), apdcb,
            this.commandProcessor.getSendToSlaveTimeoutInMills(), TimeUnit.MILLISECONDS);
        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {

            @Override
View Full Code Here

        // skip two messages.
        OpaqueGenerator.getNextOpaque();
        OpaqueGenerator.getNextOpaque();
        // check if slave is ok.
        final BooleanCommand expectResp = new BooleanCommand(HttpStatus.Success, msgId + " " + partition + " " + 0, -1);
        SyncCommand command =
                new SyncCommand(testTopic, partition, encodePayload, flag, msgId, CheckSum.crc32(encodePayload),
                    OpaqueGenerator.getNextOpaque());
        EasyMock.expect(
            this.remotingClient.invokeToGroup(this.slaveUrl, command,
                this.commandProcessor.getSendToSlaveTimeoutInMills(), TimeUnit.MILLISECONDS)).andReturn(expectResp);
        OpaqueGenerator.resetOpaque();
View Full Code Here

                        Message msg = new Message(testTopic, "test".getBytes());
                        // ����slave
                        byte[] encodePayload = MessageUtils.encodePayload(msg);
                        int flag = 0;
                        int partition = 0;
                        SyncCommand command =
                                new SyncCommand(testTopic, partition, encodePayload, flag,
                                    SamsaCommandProcessor.this.idWorker.nextId(), CheckSum.crc32(encodePayload),
                                    OpaqueGenerator.getNextOpaque());
                        ResponseCommand resp =
                                SamsaCommandProcessor.this.remotingClient.invokeToGroup(
                                    SamsaCommandProcessor.this.slaveUrl, command,
View Full Code Here

                // ����callback
                final SyncAppendCallback syncCB =
                        new SyncAppendCallback(partition, partitionString, request, messageId, cb);
                // ����slave
                this.remotingClient.sendToGroup(this.slaveUrl,
                    new SyncCommand(request.getTopic(), partition, request.getData(), request.getFlag(), messageId,
                        request.getCheckSum(), OpaqueGenerator.getNextOpaque()), syncCB,
                        this.sendToSlaveTimeoutInMills, TimeUnit.MILLISECONDS);
                // д��master
                store.append(messageId, request, syncCB);
            }
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.network.SyncCommand

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.