Package com.taobao.metamorphosis.network

Examples of com.taobao.metamorphosis.network.BooleanCommand


        final TransactionInfo info = new TransactionInfo(transactionId, sessionId, TransactionType.PREPARE);
        final TransactionCommand tc = new TransactionCommand(info, 1);
        EasyMock.expect(
            this.commandProcessor.prepareTransaction(new SessionContextImpl(sessionId, this.conn), transactionId))
            .andReturn(XAResource.XA_OK);
        this.conn.response(new BooleanCommand(HttpStatus.Success, String.valueOf(XAResource.XA_OK), 1));
        this.mockSessionContext(sessionId, sessionId);
        this.replay();
        this.transactionProcessor.handleRequest(tc, this.conn);
    }
View Full Code Here


        this.mockSessionContext(SessionContextHolder.GLOBAL_SESSION_KEY, sessionId);
        EasyMock.expect(
            this.commandProcessor.getPreparedTransactions(new SessionContextImpl("test", this.conn), uniqueQualifier))
            .andReturn(ids);

        this.conn.response(new BooleanCommand(HttpStatus.Success, resultString, 1));
        EasyMock.expectLastCall();
        this.replay();
        this.transactionProcessor.handleRequest(tc, this.conn);

    }
View Full Code Here

        EasyMock.expect(
            this.commandProcessor.getPreparedTransactions(new SessionContextImpl("test", this.conn), uniqueQualifier))
            .andThrow(new RuntimeException("just for test"));

        this.conn.response(new BooleanCommand(HttpStatus.InternalServerError, "just for test", 1));
        EasyMock.expectLastCall();
        this.replay();
        this.transactionProcessor.handleRequest(tc, this.conn);
    }
View Full Code Here

        this.transactionProcessor.handleRequest(tc, this.conn);
    }


    private void mockResponseOK() throws NotifyRemotingException {
        this.conn.response(new BooleanCommand(HttpStatus.Success, null, 1));
    }
View Full Code Here

    public void testHandleRequestNullStore() throws Exception {
        final int partition = 1;
        final int opaque = 0;
        final long offset = 1024;
        EasyMock.expect(this.storeManager.getMessageStore(this.topic, partition)).andReturn(null);
        this.conn.response(new BooleanCommand(HttpStatus.NotFound, "The topic `" + this.topic
                + "` in partition `" + partition + "` is not exists", opaque));
        this.mocksControl.replay();
        this.offsetProcessor.handleRequest(new OffsetCommand(this.topic, this.group, partition, offset, opaque),
            this.conn);
        this.mocksControl.verify();
View Full Code Here

        final long offset = 1024;
        final long resultOffset = 1536;
        final MessageStore store = this.mocksControl.createMock(MessageStore.class);
        EasyMock.expect(this.storeManager.getMessageStore(this.topic, partition)).andReturn(store);
        EasyMock.expect(store.getNearestOffset(offset)).andReturn(resultOffset);
        this.conn.response(new BooleanCommand(HttpStatus.Success, String.valueOf(resultOffset), opaque));
        this.mocksControl.replay();
        this.offsetProcessor.handleRequest(new OffsetCommand(this.topic, this.group, partition, offset, opaque),
            this.conn);
        this.mocksControl.verify();
        assertEquals(1, this.statsManager.getCmdOffsets());
View Full Code Here

        final PutCommand request = new PutCommand(this.topic, partition, data, null, flag, opaque);
        final long msgId = 100000L;
        final MessageStore store = this.mocksControl.createMock(MessageStore.class);
        EasyMock.expect(this.idWorker.nextId()).andReturn(msgId);
        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 long msgId = 100000L;
        final MessageStore store = this.mocksControl.createMock(MessageStore.class);
        EasyMock.expect(this.idWorker.nextId()).andReturn(msgId);
        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 'PutProcessorUnitTest-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

        final byte[] data = new byte[1024];
        final int flag = MessageFlagUtils.getFlag(null);
        final PutCommand request = new PutCommand(this.topic, partition, data, null, flag, opaque);
        this.metaConfig.setTopics(Arrays.asList(this.topic));
        this.metaConfig.closePartitions(this.topic, partition, partition);
        final BooleanCommand expectedResp =
                new BooleanCommand(
                    HttpStatus.Forbidden,
                    "Put message to [broker 'meta://localhost:8123'] [partition 'PutProcessorUnitTest-1'] failed.Detail:partition[0-1] has been closed",
                    request.getOpaque());
        final AtomicBoolean invoked = new AtomicBoolean(false);
        final PutCallback cb = new PutCallback() {

            @Override
            public void putComplete(final ResponseCommand resp) {
                invoked.set(true);
                System.out.println(((BooleanCommand) resp).getErrorMsg());
                if (!expectedResp.equals(resp)) {
                    throw new RuntimeException();
                }
            }
        };
        EasyMock.expect(this.brokerZooKeeper.getBrokerString()).andReturn("meta://localhost:8123");
View Full Code Here

    @Test
    public void testHandleRequestNoStore() throws Exception {
        final int partition = 1;
        final int opaque = 0;
        EasyMock.expect(this.storeManager.getMessageStore(this.topic, partition)).andReturn(null);
        this.conn.response(new BooleanCommand(HttpStatus.NotFound, "The topic `" + this.topic
            + "` in partition `" + partition + "` is not exists", opaque));
        EasyMock.expectLastCall();
        this.mocksControl.replay();

        final GetCommand request = new GetCommand(this.topic, this.group, partition, opaque, 1024 * 1024, opaque);
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.