Search in sources :

Example 1 with ConsumerOffsetSerializeWrapper

use of org.apache.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper in project rocketmq by apache.

the class SlaveSynchronize method syncConsumerOffset.

private void syncConsumerOffset() {
    String masterAddrBak = this.masterAddr;
    if (masterAddrBak != null) {
        try {
            ConsumerOffsetSerializeWrapper offsetWrapper = this.brokerController.getBrokerOuterAPI().getAllConsumerOffset(masterAddrBak);
            this.brokerController.getConsumerOffsetManager().getOffsetTable().putAll(offsetWrapper.getOffsetTable());
            this.brokerController.getConsumerOffsetManager().persist();
            log.info("Update slave consumer offset from master, {}", masterAddrBak);
        } catch (Exception e) {
            log.error("SyncConsumerOffset Exception, {}", masterAddrBak, e);
        }
    }
}
Also used : ConsumerOffsetSerializeWrapper(org.apache.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper) IOException(java.io.IOException)

Example 2 with ConsumerOffsetSerializeWrapper

use of org.apache.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper in project rocketmq by apache.

the class BrokerOuterAPI method getAllConsumerOffset.

public ConsumerOffsetSerializeWrapper getAllConsumerOffset(final String addr) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_CONSUMER_OFFSET, null);
    RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                return ConsumerOffsetSerializeWrapper.decode(response.getBody(), ConsumerOffsetSerializeWrapper.class);
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) ConsumerOffsetSerializeWrapper(org.apache.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException)

Example 3 with ConsumerOffsetSerializeWrapper

use of org.apache.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class BrokerOuterAPI method getAllConsumerOffset.

public ConsumerOffsetSerializeWrapper getAllConsumerOffset(final String addr) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_CONSUMER_OFFSET, null);
    RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                return ConsumerOffsetSerializeWrapper.decode(response.getBody(), ConsumerOffsetSerializeWrapper.class);
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) ConsumerOffsetSerializeWrapper(org.apache.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException)

Example 4 with ConsumerOffsetSerializeWrapper

use of org.apache.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class SlaveSynchronize method syncConsumerOffset.

private void syncConsumerOffset() {
    String masterAddrBak = this.masterAddr;
    if (masterAddrBak != null) {
        try {
            ConsumerOffsetSerializeWrapper offsetWrapper = this.brokerController.getBrokerOuterAPI().getAllConsumerOffset(masterAddrBak);
            this.brokerController.getConsumerOffsetManager().getOffsetTable().putAll(offsetWrapper.getOffsetTable());
            this.brokerController.getConsumerOffsetManager().persist();
            log.info("Update slave consumer offset from master, {}", masterAddrBak);
        } catch (Exception e) {
            log.error("SyncConsumerOffset Exception, {}", masterAddrBak, e);
        }
    }
}
Also used : ConsumerOffsetSerializeWrapper(org.apache.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper) IOException(java.io.IOException)

Aggregations

ConsumerOffsetSerializeWrapper (org.apache.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper)4 IOException (java.io.IOException)2 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)2