use of org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeRequestHeader 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(), addr);
}
use of org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeRequestHeader in project rocketmq by apache.
the class AdminBrokerProcessorTest method testGetEarliestMsgStoretime.
@Test
public void testGetEarliestMsgStoretime() throws Exception {
messageStore = mock(MessageStore.class);
when(brokerController.getMessageStore()).thenReturn(messageStore);
GetEarliestMsgStoretimeRequestHeader getEarliestMsgStoretimeRequestHeader = new GetEarliestMsgStoretimeRequestHeader();
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_EARLIEST_MSG_STORETIME, getEarliestMsgStoretimeRequestHeader);
request.addExtField("topic", "topic");
request.addExtField("queueId", "0");
RemotingCommand response = adminBrokerProcessor.processRequest(handlerContext, request);
assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS);
}
use of org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeRequestHeader in project rocketmq-comments by HScarb.
the class AdminBrokerProcessorTest method testGetEarliestMsgStoretime.
@Test
public void testGetEarliestMsgStoretime() throws Exception {
messageStore = mock(MessageStore.class);
when(brokerController.getMessageStore()).thenReturn(messageStore);
GetEarliestMsgStoretimeRequestHeader getEarliestMsgStoretimeRequestHeader = new GetEarliestMsgStoretimeRequestHeader();
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_EARLIEST_MSG_STORETIME, getEarliestMsgStoretimeRequestHeader);
request.addExtField("topic", "topic");
request.addExtField("queueId", "0");
RemotingCommand response = adminBrokerProcessor.processRequest(handlerContext, request);
assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS);
}
Aggregations