Search in sources :

Example 1 with GetMaxOffsetResponseHeader

use of org.apache.rocketmq.common.protocol.header.GetMaxOffsetResponseHeader in project rocketmq by apache.

the class MQClientAPIImpl method getMaxOffset.

public long getMaxOffset(final String addr, final String topic, final int queueId, final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
    GetMaxOffsetRequestHeader requestHeader = new GetMaxOffsetRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setQueueId(queueId);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_MAX_OFFSET, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader) response.decodeCommandCustomHeader(GetMaxOffsetResponseHeader.class);
                return responseHeader.getOffset();
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetMaxOffsetResponseHeader(org.apache.rocketmq.common.protocol.header.GetMaxOffsetResponseHeader) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) GetMaxOffsetRequestHeader(org.apache.rocketmq.common.protocol.header.GetMaxOffsetRequestHeader)

Example 2 with GetMaxOffsetResponseHeader

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

the class AdminBrokerProcessor method getMaxOffset.

private RemotingCommand getMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(GetMaxOffsetResponseHeader.class);
    final GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader) response.readCustomHeader();
    final GetMaxOffsetRequestHeader requestHeader = (GetMaxOffsetRequestHeader) request.decodeCommandCustomHeader(GetMaxOffsetRequestHeader.class);
    long offset = this.brokerController.getMessageStore().getMaxOffsetInQueue(requestHeader.getTopic(), requestHeader.getQueueId());
    responseHeader.setOffset(offset);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetMaxOffsetResponseHeader(org.apache.rocketmq.common.protocol.header.GetMaxOffsetResponseHeader) GetMaxOffsetRequestHeader(org.apache.rocketmq.common.protocol.header.GetMaxOffsetRequestHeader)

Example 3 with GetMaxOffsetResponseHeader

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

the class MQClientAPIImpl method getMaxOffset.

public long getMaxOffset(final String addr, final String topic, final int queueId, final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
    GetMaxOffsetRequestHeader requestHeader = new GetMaxOffsetRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setQueueId(queueId);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_MAX_OFFSET, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader) response.decodeCommandCustomHeader(GetMaxOffsetResponseHeader.class);
                return responseHeader.getOffset();
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetMaxOffsetResponseHeader(org.apache.rocketmq.common.protocol.header.GetMaxOffsetResponseHeader) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) GetMaxOffsetRequestHeader(org.apache.rocketmq.common.protocol.header.GetMaxOffsetRequestHeader)

Example 4 with GetMaxOffsetResponseHeader

use of org.apache.rocketmq.common.protocol.header.GetMaxOffsetResponseHeader in project rocketmq by apache.

the class AdminBrokerProcessor method getMaxOffset.

private RemotingCommand getMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(GetMaxOffsetResponseHeader.class);
    final GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader) response.readCustomHeader();
    final GetMaxOffsetRequestHeader requestHeader = (GetMaxOffsetRequestHeader) request.decodeCommandCustomHeader(GetMaxOffsetRequestHeader.class);
    long offset = this.brokerController.getMessageStore().getMaxOffsetInQueue(requestHeader.getTopic(), requestHeader.getQueueId());
    responseHeader.setOffset(offset);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetMaxOffsetResponseHeader(org.apache.rocketmq.common.protocol.header.GetMaxOffsetResponseHeader) GetMaxOffsetRequestHeader(org.apache.rocketmq.common.protocol.header.GetMaxOffsetRequestHeader)

Aggregations

GetMaxOffsetRequestHeader (org.apache.rocketmq.common.protocol.header.GetMaxOffsetRequestHeader)4 GetMaxOffsetResponseHeader (org.apache.rocketmq.common.protocol.header.GetMaxOffsetResponseHeader)4 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)4 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2