org.apache.rocketmq.common.admin.TopicStatsTable Java Examples

The following examples show how to use org.apache.rocketmq.common.admin.TopicStatsTable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MQClientAPIImpl.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic, final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
    requestHeader.setTopic(topic);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
            return topicStatsTable;
        }
        default:
            break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #2
Source File: MQClientAPIImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic, final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
    requestHeader.setTopic(topic);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
            return topicStatsTable;
        }
        default:
            break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #3
Source File: MQClientAPIImpl.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic,
    final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
    requestHeader.setTopic(topic);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);

    String acturallyAddr = getActurallyBrokerAddr(addr);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), acturallyAddr),
        request, timeoutMillis);
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
            return topicStatsTable;
        }
        default:
            break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #4
Source File: DefaultMQAdminExtImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Override
public TopicStatsTable examineTopicStats(String topic) throws RemotingException, MQClientException, InterruptedException,
    MQBrokerException {
    TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
    TopicStatsTable topicStatsTable = new TopicStatsTable();

    for (BrokerData bd : topicRouteData.getBrokerDatas()) {
        String addr = bd.selectBrokerAddr();
        if (addr != null) {
            TopicStatsTable tst = this.mqClientInstance.getMQClientAPIImpl().getTopicStatsInfo(addr, topic, timeoutMillis);
            topicStatsTable.getOffsetTable().putAll(tst.getOffsetTable());
        }
    }

    if (topicStatsTable.getOffsetTable().isEmpty()) {
        throw new MQClientException("Not found the topic stats info", null);
    }

    return topicStatsTable;
}
 
Example #5
Source File: MQClientAPIImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic,
    final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
    requestHeader.setTopic(topic);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
            return topicStatsTable;
        }
        default:
            break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #6
Source File: DefaultMQAdminExtImpl.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Override
public TopicStatsTable examineTopicStats(
    String topic) throws RemotingException, MQClientException, InterruptedException,
    MQBrokerException {
    TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
    TopicStatsTable topicStatsTable = new TopicStatsTable();

    for (BrokerData bd : topicRouteData.getBrokerDatas()) {
        String addr = bd.selectBrokerAddr();
        if (addr != null) {
            TopicStatsTable tst = this.mqClientInstance.getMQClientAPIImpl().getTopicStatsInfo(addr, topic, timeoutMillis);
            topicStatsTable.getOffsetTable().putAll(tst.getOffsetTable());
        }
    }

    if (topicStatsTable.getOffsetTable().isEmpty()) {
        throw new MQClientException("Not found the topic stats info", null);
    }

    return topicStatsTable;
}
 
Example #7
Source File: DefaultMQAdminExtImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Override
public TopicStatsTable examineTopicStats(
    String topic) throws RemotingException, MQClientException, InterruptedException,
    MQBrokerException {
    TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
    TopicStatsTable topicStatsTable = new TopicStatsTable();

    for (BrokerData bd : topicRouteData.getBrokerDatas()) {
        String addr = bd.selectBrokerAddr();
        if (addr != null) {
            TopicStatsTable tst = this.mqClientInstance.getMQClientAPIImpl().getTopicStatsInfo(addr, topic, timeoutMillis);
            topicStatsTable.getOffsetTable().putAll(tst.getOffsetTable());
        }
    }

    if (topicStatsTable.getOffsetTable().isEmpty()) {
        throw new MQClientException("Not found the topic stats info", null);
    }

    return topicStatsTable;
}
 
Example #8
Source File: DefaultMQAdminExtImpl.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Override
public TopicStatsTable examineTopicStats(
    String topic) throws RemotingException, MQClientException, InterruptedException,
    MQBrokerException {
    TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
    TopicStatsTable topicStatsTable = new TopicStatsTable();

    for (BrokerData bd : topicRouteData.getBrokerDatas()) {
        String addr = bd.selectBrokerAddr();
        if (addr != null) {
            TopicStatsTable tst = this.mqClientInstance.getMQClientAPIImpl().getTopicStatsInfo(addr, topic, timeoutMillis);
            topicStatsTable.getOffsetTable().putAll(tst.getOffsetTable());
        }
    }

    if (topicStatsTable.getOffsetTable().isEmpty()) {
        throw new MQClientException("Not found the topic stats info", null);
    }

    return topicStatsTable;
}
 
Example #9
Source File: MQClientAPIImpl.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic,
    final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
    requestHeader.setTopic(topic);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
            return topicStatsTable;
        }
        default:
            break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #10
Source File: DefaultMQAdminExtImpl.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Override
public TopicStatsTable examineTopicStats(String topic) throws RemotingException, MQClientException, InterruptedException,
    MQBrokerException {
    TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
    TopicStatsTable topicStatsTable = new TopicStatsTable();

    for (BrokerData bd : topicRouteData.getBrokerDatas()) {
        String addr = bd.selectBrokerAddr();
        if (addr != null) {
            TopicStatsTable tst = this.mqClientInstance.getMQClientAPIImpl().getTopicStatsInfo(addr, topic, timeoutMillis);
            topicStatsTable.getOffsetTable().putAll(tst.getOffsetTable());
        }
    }

    if (topicStatsTable.getOffsetTable().isEmpty()) {
        throw new MQClientException("Not found the topic stats info", null);
    }

    return topicStatsTable;
}
 
Example #11
Source File: DefaultMQAdminExtImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Override
public TopicStatsTable examineTopicStats(
    String topic) throws RemotingException, MQClientException, InterruptedException,
    MQBrokerException {
    TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
    TopicStatsTable topicStatsTable = new TopicStatsTable();

    for (BrokerData bd : topicRouteData.getBrokerDatas()) {
        String addr = bd.selectBrokerAddr();
        if (addr != null) {
            TopicStatsTable tst = this.mqClientInstance.getMQClientAPIImpl().getTopicStatsInfo(addr, topic, timeoutMillis);
            topicStatsTable.getOffsetTable().putAll(tst.getOffsetTable());
        }
    }

    if (topicStatsTable.getOffsetTable().isEmpty()) {
        throw new MQClientException("Not found the topic stats info", null);
    }

    return topicStatsTable;
}
 
Example #12
Source File: MQClientAPIImpl.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic, final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
    requestHeader.setTopic(topic);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
            return topicStatsTable;
        }
        default:
            break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #13
Source File: MQClientAPIImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic,
    final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
    requestHeader.setTopic(topic);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
            return topicStatsTable;
        }
        default:
            break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #14
Source File: MQClientAPIImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic,
    final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
    requestHeader.setTopic(topic);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
            return topicStatsTable;
        }
        default:
            break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #15
Source File: DefaultMQAdminExtImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Override
public TopicStatsTable examineTopicStats(
    String topic) throws RemotingException, MQClientException, InterruptedException,
    MQBrokerException {
    TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
    TopicStatsTable topicStatsTable = new TopicStatsTable();

    for (BrokerData bd : topicRouteData.getBrokerDatas()) {
        String addr = bd.selectBrokerAddr();
        if (addr != null) {
            TopicStatsTable tst = this.mqClientInstance.getMQClientAPIImpl().getTopicStatsInfo(addr, topic, timeoutMillis);
            topicStatsTable.getOffsetTable().putAll(tst.getOffsetTable());
        }
    }

    if (topicStatsTable.getOffsetTable().isEmpty()) {
        throw new MQClientException("Not found the topic stats info", null);
    }

    return topicStatsTable;
}
 
Example #16
Source File: MQAdmin.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private static boolean checkTopicExist(DefaultMQAdminExt mqAdminExt, String topic) {
    boolean createResult = false;
    try {
        TopicStatsTable topicInfo = mqAdminExt.examineTopicStats(topic);
        createResult = !topicInfo.getOffsetTable().isEmpty();
    } catch (Exception e) {
    }

    return createResult;
}
 
Example #17
Source File: ConsumeGroupServiceImpl.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private Map<String/*min/max key*/, Map<String/*qid*/, Long>> getRmqTopicMinOffsetMap(Long topicId, Long clusterId) {
    List<TopicConf> confList = topicConfService.findByTopicClusterId(topicId, clusterId);
    MqServer rmqServer = null;
    TopicConf topicConf = null;
    for (TopicConf conf : confList) {
        MqServer mqServer = mqServerService.findById(conf.getMqServerId());
        if (mqServer.getType() == MqServerType.ROCKETMQ.getIndex()) {
            topicConf = conf;
            rmqServer = mqServer;
        }
    }
    Map<String/*min/max key*/, Map<String/*qid*/, Long>> ret = Maps.newHashMap();
    Map<String, Long> minOffsetMap = Maps.newHashMap();
    Map<String, Long> maxOffsetMap = Maps.newHashMap();
    ret.put("min", minOffsetMap);
    ret.put("max", maxOffsetMap);
    if (rmqServer == null) {
        return ret;
    }

    try {
        TopicStatsTable statsTable = rmqAdminService.queryTopicConsumeState(rmqServer.getAddr(), topicConf.getTopicName());
        statsTable.getOffsetTable().forEach(((messageQueue, topicOffset) -> {
            minOffsetMap.put(RmqAdminServiceImpl.getNewQid(messageQueue), topicOffset.getMinOffset());
            maxOffsetMap.put(RmqAdminServiceImpl.getNewQid(messageQueue), topicOffset.getMaxOffset());
        }));

        return ret;
    } catch (Exception e) {
        LOGGER.error("queryTopicConsumeState exception, topic:" + topicConf.getTopicName() + ", mqserver:" + topicConf.getMqServerName());
        return ret;
    }
}
 
Example #18
Source File: MQAdmin.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private static boolean checkTopicExist(DefaultMQAdminExt mqAdminExt, String topic) {
    boolean createResult = false;
    try {
        TopicStatsTable topicInfo = mqAdminExt.examineTopicStats(topic);
        createResult = !topicInfo.getOffsetTable().isEmpty();
    } catch (Exception e) {
    }

    return createResult;
}
 
Example #19
Source File: DefaultMQAdminExtImplTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
    public void testNewGroup() throws Exception {
        group = "cg_test_new_rmq_group";
        topic = "test-2";
        TopicStatsTable ts = mqAdmin.examineTopicStats(topic);
        for (Map.Entry<MessageQueue, TopicOffset> messageQueueTopicOffsetEntry : ts.getOffsetTable().entrySet()) {
            System.out.println(messageQueueTopicOffsetEntry);
        }


        TopicRouteData routeInfo = mqAdmin.examineTopicRouteInfo(topic);
        System.out.println();
        MQClientInstance instance = MQClientManager.getInstance().getAndCreateMQClientInstance(mqAdmin);


        for (BrokerData brokerData : routeInfo.getBrokerDatas()) {
            ConsumeStats r = instance.getMQClientAPIImpl().getConsumeStats(brokerData.selectBrokerAddr(), group, topic, 3000);
            System.out.println(brokerData + "consumeStats:" + r.getOffsetTable());
        }

//        List<RollbackStats> r = mqAdmin.resetOffsetByTimestampOld(group, topic, -1, true);
//        for (RollbackStats rollbackStats : r) {
//            System.out.println(rollbackStats);
//        }

//        ConsumeStats cs = mqAdmin.examineConsumeStats(group, topic);
//        for (Map.Entry<MessageQueue, OffsetWrapper> messageQueueOffsetWrapperEntry : cs.getOffsetTable().entrySet()) {
//            System.out.println(messageQueueOffsetWrapperEntry);
//        }
    }
 
Example #20
Source File: MQAdmin.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
private static boolean checkTopicExist(DefaultMQAdminExt mqAdminExt, String topic) {
    boolean createResult = false;
    try {
        TopicStatsTable topicInfo = mqAdminExt.examineTopicStats(topic);
        createResult = !topicInfo.getOffsetTable().isEmpty();
    } catch (Exception e) {
    }

    return createResult;
}
 
Example #21
Source File: MQAdmin.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
private static boolean checkTopicExist(DefaultMQAdminExt mqAdminExt, String topic) {
    boolean createResult = false;
    try {
        TopicStatsTable topicInfo = mqAdminExt.examineTopicStats(topic);
        createResult = !topicInfo.getOffsetTable().isEmpty();
    } catch (Exception e) {
    }

    return createResult;
}
 
Example #22
Source File: ConsumeGroupServiceImpl.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private Map<String/*min/max key*/, Map<String/*qid*/, Long>> getRmqTopicMinOffsetMap(Long topicId, Long clusterId) {
    List<TopicConf> confList = topicConfService.findByTopicClusterId(topicId, clusterId);
    MqServer rmqServer = null;
    TopicConf topicConf = null;
    for (TopicConf conf : confList) {
        MqServer mqServer = mqServerService.findById(conf.getMqServerId());
        if (mqServer.getType() == MqServerType.ROCKETMQ.getIndex()) {
            topicConf = conf;
            rmqServer = mqServer;
        }
    }
    Map<String/*min/max key*/, Map<String/*qid*/, Long>> ret = Maps.newHashMap();
    Map<String, Long> minOffsetMap = Maps.newHashMap();
    Map<String, Long> maxOffsetMap = Maps.newHashMap();
    ret.put("min", minOffsetMap);
    ret.put("max", maxOffsetMap);
    if (rmqServer == null) {
        return ret;
    }

    try {
        TopicStatsTable statsTable = rmqAdminService.queryTopicConsumeState(rmqServer.getAddr(), topicConf.getTopicName());
        statsTable.getOffsetTable().forEach(((messageQueue, topicOffset) -> {
            minOffsetMap.put(RmqAdminServiceImpl.getNewQid(messageQueue), topicOffset.getMinOffset());
            maxOffsetMap.put(RmqAdminServiceImpl.getNewQid(messageQueue), topicOffset.getMaxOffset());
        }));

        return ret;
    } catch (Exception e) {
        LOGGER.error("queryTopicConsumeState exception, topic:" + topicConf.getTopicName() + ", mqserver:" + topicConf.getMqServerName());
        return ret;
    }
}
 
Example #23
Source File: DefaultMQAdminExtImplTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
    public void testNewGroup() throws Exception {
        group = "cg_test_new_rmq_group";
        topic = "test-2";
        TopicStatsTable ts = mqAdmin.examineTopicStats(topic);
        for (Map.Entry<MessageQueue, TopicOffset> messageQueueTopicOffsetEntry : ts.getOffsetTable().entrySet()) {
            System.out.println(messageQueueTopicOffsetEntry);
        }


        TopicRouteData routeInfo = mqAdmin.examineTopicRouteInfo(topic);
        System.out.println();
        MQClientInstance instance = MQClientManager.getInstance().getAndCreateMQClientInstance(mqAdmin);


        for (BrokerData brokerData : routeInfo.getBrokerDatas()) {
            ConsumeStats r = instance.getMQClientAPIImpl().getConsumeStats(brokerData.selectBrokerAddr(), group, topic, 3000);
            System.out.println(brokerData + "consumeStats:" + r.getOffsetTable());
        }

//        List<RollbackStats> r = mqAdmin.resetOffsetByTimestampOld(group, topic, -1, true);
//        for (RollbackStats rollbackStats : r) {
//            System.out.println(rollbackStats);
//        }

//        ConsumeStats cs = mqAdmin.examineConsumeStats(group, topic);
//        for (Map.Entry<MessageQueue, OffsetWrapper> messageQueueOffsetWrapperEntry : cs.getOffsetTable().entrySet()) {
//            System.out.println(messageQueueOffsetWrapperEntry);
//        }
    }
 
Example #24
Source File: MQAdmin.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private static boolean checkTopicExist(DefaultMQAdminExt mqAdminExt, String topic) {
    boolean createResult = false;
    try {
        TopicStatsTable topicInfo = mqAdminExt.examineTopicStats(topic);
        createResult = !topicInfo.getOffsetTable().isEmpty();
    } catch (Exception e) {
    }

    return createResult;
}
 
Example #25
Source File: MQAdmin.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
private static boolean checkTopicExist(DefaultMQAdminExt mqAdminExt, String topic) {
    boolean createResult = false;
    try {
        TopicStatsTable topicInfo = mqAdminExt.examineTopicStats(topic);
        createResult = !topicInfo.getOffsetTable().isEmpty();
    } catch (Exception e) {
    }

    return createResult;
}
 
Example #26
Source File: MQAdmin.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
private static boolean checkTopicExist(DefaultMQAdminExt mqAdminExt, String topic) {
    boolean createResult = false;
    try {
        TopicStatsTable topicInfo = mqAdminExt.examineTopicStats(topic);
        createResult = !topicInfo.getOffsetTable().isEmpty();
    } catch (Exception e) {
    }

    return createResult;
}
 
Example #27
Source File: MQAdmin.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private static boolean checkTopicExist(DefaultMQAdminExt mqAdminExt, String topic) {
    boolean createResult = false;
    try {
        TopicStatsTable topicInfo = mqAdminExt.examineTopicStats(topic);
        createResult = !topicInfo.getOffsetTable().isEmpty();
    } catch (Exception e) {
    }

    return createResult;
}
 
Example #28
Source File: MQAdminExt.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
TopicStatsTable examineTopicStats(
final String topic) throws RemotingException, MQClientException, InterruptedException,
MQBrokerException;
 
Example #29
Source File: MQAdminExt.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
TopicStatsTable examineTopicStats(final String topic) throws RemotingException, MQClientException, InterruptedException,
MQBrokerException;
 
Example #30
Source File: TopicStatusSubCommand.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);

    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));

    try {
        defaultMQAdminExt.start();
        String topic = commandLine.getOptionValue('t').trim();
        TopicStatsTable topicStatsTable = defaultMQAdminExt.examineTopicStats(topic);

        List<MessageQueue> mqList = new LinkedList<MessageQueue>();
        mqList.addAll(topicStatsTable.getOffsetTable().keySet());
        Collections.sort(mqList);

        System.out.printf("%-32s  %-4s  %-20s  %-20s    %s%n",
            "#Broker Name",
            "#QID",
            "#Min Offset",
            "#Max Offset",
            "#Last Updated"
        );

        for (MessageQueue mq : mqList) {
            TopicOffset topicOffset = topicStatsTable.getOffsetTable().get(mq);

            String humanTimestamp = "";
            if (topicOffset.getLastUpdateTimestamp() > 0) {
                humanTimestamp = UtilAll.timeMillisToHumanString2(topicOffset.getLastUpdateTimestamp());
            }

            System.out.printf("%-32s  %-4d  %-20d  %-20d    %s%n",
                UtilAll.frontStringAtLeast(mq.getBrokerName(), 32),
                mq.getQueueId(),
                topicOffset.getMinOffset(),
                topicOffset.getMaxOffset(),
                humanTimestamp
            );
        }
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}