Search in sources :

Example 6 with GetEarliestMsgStoretimeRequestHeader

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);
}
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 7 with GetEarliestMsgStoretimeRequestHeader

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);
}
Also used : DefaultMessageStore(org.apache.rocketmq.store.DefaultMessageStore) MessageStore(org.apache.rocketmq.store.MessageStore) RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetEarliestMsgStoretimeRequestHeader(org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeRequestHeader) Test(org.junit.Test)

Example 8 with GetEarliestMsgStoretimeRequestHeader

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);
}
Also used : DefaultMessageStore(org.apache.rocketmq.store.DefaultMessageStore) MessageStore(org.apache.rocketmq.store.MessageStore) RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetEarliestMsgStoretimeRequestHeader(org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeRequestHeader) Test(org.junit.Test)

Aggregations

GetEarliestMsgStoretimeRequestHeader (org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeRequestHeader)8 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)8 GetEarliestMsgStoretimeResponseHeader (org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeResponseHeader)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