Search in sources :

Example 1 with GetEarliestMsgStoretimeResponseHeader

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

the class MQClientAPIImpl method getEarliestMsgStoretime.

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

Example 2 with GetEarliestMsgStoretimeResponseHeader

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

the class AdminBrokerProcessor method getEarliestMsgStoretime.

private RemotingCommand getEarliestMsgStoretime(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(GetEarliestMsgStoretimeResponseHeader.class);
    final GetEarliestMsgStoretimeResponseHeader responseHeader = (GetEarliestMsgStoretimeResponseHeader) response.readCustomHeader();
    final GetEarliestMsgStoretimeRequestHeader requestHeader = (GetEarliestMsgStoretimeRequestHeader) request.decodeCommandCustomHeader(GetEarliestMsgStoretimeRequestHeader.class);
    long timestamp = this.brokerController.getMessageStore().getEarliestMessageTime(requestHeader.getTopic(), requestHeader.getQueueId());
    responseHeader.setTimestamp(timestamp);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetEarliestMsgStoretimeResponseHeader(org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeResponseHeader) GetEarliestMsgStoretimeRequestHeader(org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeRequestHeader)

Example 3 with GetEarliestMsgStoretimeResponseHeader

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

the class AdminBrokerProcessor method getEarliestMsgStoretime.

private RemotingCommand getEarliestMsgStoretime(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(GetEarliestMsgStoretimeResponseHeader.class);
    final GetEarliestMsgStoretimeResponseHeader responseHeader = (GetEarliestMsgStoretimeResponseHeader) response.readCustomHeader();
    final GetEarliestMsgStoretimeRequestHeader requestHeader = (GetEarliestMsgStoretimeRequestHeader) request.decodeCommandCustomHeader(GetEarliestMsgStoretimeRequestHeader.class);
    long timestamp = this.brokerController.getMessageStore().getEarliestMessageTime(requestHeader.getTopic(), requestHeader.getQueueId());
    responseHeader.setTimestamp(timestamp);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetEarliestMsgStoretimeResponseHeader(org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeResponseHeader) GetEarliestMsgStoretimeRequestHeader(org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeRequestHeader)

Example 4 with GetEarliestMsgStoretimeResponseHeader

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

the class MQClientAPIImpl method getEarliestMsgStoretime.

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

Aggregations

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