Package com.taobao.metamorphosis.network

Examples of com.taobao.metamorphosis.network.OffsetCommand


        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();
        assertEquals(1, this.statsManager.getCmdOffsets());
    }
View Full Code Here


        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 int partition = Integer.parseInt(jettyRequest.getParameter("partition"));
        final String group = jettyRequest.getParameter("group");
        final long offset = Long.parseLong(jettyRequest.getParameter("offset"));

        try {
            final OffsetCommand offsetCommand = this.convert2OffsetCommand(topic, partition, group, offset);
            final ResponseCommand responseCommand = this.commandProcessor.processOffsetCommand(offsetCommand, null);
            response.setStatus(((BooleanCommand) responseCommand).getCode());
            response.getWriter().write(((BooleanCommand) responseCommand).getErrorMsg());
        }
        catch (final Throwable e) {
View Full Code Here

    }


    private OffsetCommand convert2OffsetCommand(final String topic, final int partition, final String group,
            final long offset) {
        return new OffsetCommand(topic, group, partition, offset, 0);
    }
View Full Code Here

        EasyMock.expect(this.slaveZooKeeper.getMasterServerUrl()).andReturn(masterUrl);
        EasyMock.expect(this.remotingClient.isConnected(masterUrl)).andReturn(true);
        OpaqueGenerator.resetOpaque();
        EasyMock.expect(
            this.remotingClient.invokeToGroup(masterUrl,
                new OffsetCommand(topic, GROUP, partition, 0, OpaqueGenerator.getNextOpaque()))).andReturn(resp);
        OpaqueGenerator.resetOpaque();
        final MetaConfig config = new MetaConfig();
        config.setSlaveConfig(new SlaveConfig(0, GROUP, 500, true));
        EasyMock.expect(this.broker.getMetaConfig()).andReturn(config);
        this.mocksControl.replay();
View Full Code Here

        EasyMock.expect(this.slaveZooKeeper.getMasterServerUrl()).andReturn(masterUrl);
        EasyMock.expect(this.remotingClient.isConnected(masterUrl)).andReturn(true);
        OpaqueGenerator.resetOpaque();
        EasyMock.expect(
            this.remotingClient.invokeToGroup(masterUrl,
                new OffsetCommand(topic, GROUP, partition, 0, OpaqueGenerator.getNextOpaque()))).andReturn(resp);
        OpaqueGenerator.resetOpaque();
        final MetaConfig config = new MetaConfig();
        config.setSlaveConfig(new SlaveConfig(0, GROUP, 500, true));
        EasyMock.expect(this.broker.getMetaConfig()).andReturn(config);
        this.mocksControl.replay();
View Full Code Here

        // EasyMock.expect(this.broker.getCommandProcessor()).andReturn(this.brokerCommandProcessor).anyTimes();
        EasyMock.expect(this.broker.getStoreManager()).andReturn(this.storeManager);
        EasyMock.expect(this.storeManager.getMessageStore(topic, partition)).andReturn(null);
        EasyMock.expect(this.slaveZooKeeper.getMasterServerUrl()).andReturn(masterUrl);
        EasyMock.expect(this.remotingClient.isConnected(masterUrl)).andReturn(true);
        EasyMock.expect(this.remotingClient.invokeToGroup(masterUrl, new OffsetCommand(topic, GROUP, partition, 0, 0)))
        .andThrow(new Exception("unknown error when invoke"));
        this.mocksControl.replay();
        this.slaveOffsetStorage.load(topic, "ss", new Partition(0, partition));
        this.mocksControl.verify();
    }
View Full Code Here

        final Broker broker = new Broker(1, url);
        final long delay = 0;
        final TopicPartitionRegInfo topicPartitionRegInfo = new TopicPartitionRegInfo(topic, partition, offset);
        EasyMock.expect(
            this.remotingClient.invokeToGroup(url,
                new OffsetCommand(topic, this.consumerConfig.getGroup(), partition.getPartition(), offset,
                    Integer.MIN_VALUE), this.consumerConfig.getFetchTimeoutInMills(), TimeUnit.MILLISECONDS))
                    .andReturn(new BooleanCommand(HttpStatus.Success, String.valueOf(offset), Integer.MIN_VALUE));
        this.mocksControl.replay();
        OpaqueGenerator.resetOpaque();
        assertEquals(offset, this.consumer.offset(new FetchRequest(broker, delay, topicPartitionRegInfo, maxSize)));
View Full Code Here

            log.info("try connect to " + masterServerUrl);
            this.connectServer(masterServerUrl);
        }
        try {
            final BooleanCommand resp =
                    (BooleanCommand) this.remotingClient.invokeToGroup(masterServerUrl, new OffsetCommand(topic,
                        this.broker.getMetaConfig().getSlaveConfig().getSlaveGroup(), partition.getPartition(), 0,
                        OpaqueGenerator.getNextOpaque()));

            final String resultStr = resp.getErrorMsg();
View Full Code Here

    public long offset(final FetchRequest fetchRequest) throws MetaClientException {
        final long start = System.currentTimeMillis();
        boolean success = false;
        try {
            final long currentOffset = fetchRequest.getOffset();
            final OffsetCommand offsetCmd =
                    new OffsetCommand(fetchRequest.getTopic(), this.consumerConfig.getGroup(),
                        fetchRequest.getPartition(), currentOffset, OpaqueGenerator.getNextOpaque());
            final String serverUrl = fetchRequest.getBroker().getZKString();
            final BooleanCommand booleanCmd =
                    (BooleanCommand) this.remotingClient.invokeToGroup(serverUrl, offsetCmd,
                        this.consumerConfig.getFetchTimeoutInMills(), TimeUnit.MILLISECONDS);
View Full Code Here

TOP

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

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.