Package com.taobao.metamorphosis.network

Examples of com.taobao.metamorphosis.network.BooleanCommand


        final int maxSize = -1;
        this.metaConfig.setMaxTransferSize(1024);
        EasyMock.expect(this.storeManager.getMessageStore(this.topic, partition)).andReturn(
            new MessageStore(this.topic, partition, this.metaConfig, null));
        this.conn
        .response(new BooleanCommand(HttpStatus.BadRequest, "Bad request,invalid max size:" + maxSize, opaque));
        EasyMock.expectLastCall();
        this.mocksControl.replay();

        final GetCommand request = new GetCommand(this.topic, this.group, partition, opaque, maxSize, opaque);
        this.getProcessor.handleRequest(request, this.conn);
View Full Code Here


        final int maxSize = 1024;
        final long offset = 10;
        final MessageStore store = this.mocksControl.createMock(MessageStore.class);
        EasyMock.expect(this.storeManager.getMessageStore(this.topic, partition)).andReturn(store);
        EasyMock.expect(store.slice(offset, maxSize)).andReturn(null);
        this.conn.response(new BooleanCommand(HttpStatus.NotFound, "Could not find message at position "
                + offset, opaque));
        EasyMock.expect(store.getMaxOffset()).andReturn(offset);
        EasyMock.expectLastCall();
        this.mocksControl.replay();
View Full Code Here

        final int maxSize = 1024;
        final long offset = 10;
        final MessageStore store = this.mocksControl.createMock(MessageStore.class);
        EasyMock.expect(this.storeManager.getMessageStore(this.topic, partition)).andReturn(store);
        EasyMock.expect(store.slice(offset, maxSize)).andReturn(null);
        this.conn.response(new BooleanCommand(HttpStatus.NotFound, "Could not find message at position "
                + offset, opaque));
        EasyMock.expect(store.getMaxOffset()).andReturn(offset - 1);
        EasyMock.expectLastCall();
        this.mocksControl.replay();
View Full Code Here

        final long offset = Long.MAX_VALUE;
        final long realMaxOffset = 100;
        final MessageStore store = this.mocksControl.createMock(MessageStore.class);
        EasyMock.expect(this.storeManager.getMessageStore(this.topic, partition)).andReturn(store);
        EasyMock.expect(store.slice(offset, maxSize)).andReturn(null);
        this.conn.response(new BooleanCommand(HttpStatus.Moved, String.valueOf(realMaxOffset), opaque));
        EasyMock.expect(store.getMaxOffset()).andReturn(realMaxOffset);
        EasyMock.expectLastCall();
        this.mocksControl.replay();

        final GetCommand request = new GetCommand(this.topic, this.group, partition, offset, maxSize, opaque);
View Full Code Here

        final long newOffset = 512;
        final MessageStore store = this.mocksControl.createMock(MessageStore.class);
        EasyMock.expect(this.storeManager.getMessageStore(this.topic, partition)).andReturn(store);
        EasyMock.expect(store.slice(offset, maxSize)).andThrow(new ArrayIndexOutOfBoundsException());
        EasyMock.expect(store.getNearestOffset(offset)).andReturn(newOffset);
        this.conn.response(new BooleanCommand(HttpStatus.Moved, String.valueOf(newOffset), opaque));
        EasyMock.expectLastCall();
        this.mocksControl.replay();

        final GetCommand request = new GetCommand(this.topic, this.group, partition, offset, maxSize, opaque);
        this.getProcessor.handleRequest(request, this.conn);
View Full Code Here

                public boolean accept(String group, Message message) {
                    return false;
                }
            });
        this.commandProcessor.setConsumerFilterManager(this.consumerFilterManager);
        this.conn.response(new BooleanCommand(HttpStatus.Moved, String.valueOf(offset + msgBuf.capacity()), opaque));
        EasyMock.expectLastCall();
        this.mocksControl.replay();

        this.getProcessor.handleRequest(request, this.conn);
        this.mocksControl.verify();
View Full Code Here

        final long offset = 10;

        this.metaConfig.setTopics(Arrays.asList(this.topic));
        this.metaConfig.closePartitions(this.topic, partition, partition);
        final GetCommand request = new GetCommand(this.topic, this.group, partition, offset, maxSize, opaque);
        this.conn.response(new BooleanCommand(HttpStatus.Forbidden, "Partition["
                + this.metaConfig.getBrokerId() + "-" + request.getPartition() + "] has been closed", request.getOpaque()));
        EasyMock.expectLastCall();

        this.mocksControl.replay();
View Full Code Here


    @Test
    public void testHandleRequest() throws Exception {
        final int opaque = 1;
        this.conn.response(new BooleanCommand(HttpStatus.Success, BuildProperties.VERSION, opaque));
        EasyMock.expectLastCall();
        this.mocksControl.replay();
        this.processor.handleRequest(new VersionCommand(opaque), this.conn);
        this.mocksControl.verify();
    }
View Full Code Here

        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);
        final AtomicBoolean invoked = new AtomicBoolean(false);
        final PutCallback cb = new PutCallback() {
            @Override
            public void putComplete(final ResponseCommand resp) {
                invoked.set(true);
                if (!expectResp.equals(resp)) {
                    throw new RuntimeException();
                }
            }
        };
        store.append(msgId, request,
View Full Code Here

        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);
                System.out.println(((BooleanCommand) resp).getErrorMsg());
                if (!expectResp.equals(resp)) {
                    throw new RuntimeException();
                }
            }
        };
        store.append(msgId, request,
View Full Code Here

TOP

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

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.