Search in sources :

Example 1 with GetMinOffsetRequestHeader

use of org.apache.rocketmq.common.protocol.header.GetMinOffsetRequestHeader in project rocketmq-comments by HScarb.

the class MQClientAPIImpl method getMinOffset.

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

Example 2 with GetMinOffsetRequestHeader

use of org.apache.rocketmq.common.protocol.header.GetMinOffsetRequestHeader in project rocketmq-comments by HScarb.

the class AdminBrokerProcessor method getMinOffset.

private RemotingCommand getMinOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(GetMinOffsetResponseHeader.class);
    final GetMinOffsetResponseHeader responseHeader = (GetMinOffsetResponseHeader) response.readCustomHeader();
    final GetMinOffsetRequestHeader requestHeader = (GetMinOffsetRequestHeader) request.decodeCommandCustomHeader(GetMinOffsetRequestHeader.class);
    long offset = this.brokerController.getMessageStore().getMinOffsetInQueue(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) GetMinOffsetRequestHeader(org.apache.rocketmq.common.protocol.header.GetMinOffsetRequestHeader) GetMinOffsetResponseHeader(org.apache.rocketmq.common.protocol.header.GetMinOffsetResponseHeader)

Example 3 with GetMinOffsetRequestHeader

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

the class MQClientAPIImpl method getMinOffset.

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

Example 4 with GetMinOffsetRequestHeader

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

the class AdminBrokerProcessor method getMinOffset.

private RemotingCommand getMinOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(GetMinOffsetResponseHeader.class);
    final GetMinOffsetResponseHeader responseHeader = (GetMinOffsetResponseHeader) response.readCustomHeader();
    final GetMinOffsetRequestHeader requestHeader = (GetMinOffsetRequestHeader) request.decodeCommandCustomHeader(GetMinOffsetRequestHeader.class);
    long offset = this.brokerController.getMessageStore().getMinOffsetInQueue(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) GetMinOffsetRequestHeader(org.apache.rocketmq.common.protocol.header.GetMinOffsetRequestHeader) GetMinOffsetResponseHeader(org.apache.rocketmq.common.protocol.header.GetMinOffsetResponseHeader)

Example 5 with GetMinOffsetRequestHeader

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

the class MQClientAPIImpl method getMinOffset.

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

Aggregations

GetMinOffsetRequestHeader (org.apache.rocketmq.common.protocol.header.GetMinOffsetRequestHeader)8 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)8 GetMinOffsetResponseHeader (org.apache.rocketmq.common.protocol.header.GetMinOffsetResponseHeader)6 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)3 DefaultMessageStore (org.apache.rocketmq.store.DefaultMessageStore)2 MessageStore (org.apache.rocketmq.store.MessageStore)2 Test (org.junit.Test)2