Java Code Examples for org.apache.rocketmq.tools.admin.DefaultMQAdminExt#examineTopicStats()

The following examples show how to use org.apache.rocketmq.tools.admin.DefaultMQAdminExt#examineTopicStats() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
Source File: RmqAdminServiceImpl.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
@Override
public TopicStatsTable queryTopicConsumeState(String nameServer, String topic) throws Exception {
    DefaultMQAdminExt defaultMQAdminExt = getMQAdminExt(nameServer);
    return defaultMQAdminExt.examineTopicStats(topic);
}
 
Example 10
Source File: TopicStatusSubCommand.java    From rocketmq 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();
    }
}
 
Example 11
Source File: TopicStatusSubCommand.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) {
    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) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example 12
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();
    }
}
 
Example 13
Source File: TopicStatusSubCommand.java    From DDMQ 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();
    }
}
 
Example 14
Source File: RmqAdminServiceImpl.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
@Override
public TopicStatsTable queryTopicConsumeState(String nameServer, String topic) throws Exception {
    DefaultMQAdminExt defaultMQAdminExt = getMQAdminExt(nameServer);
    return defaultMQAdminExt.examineTopicStats(topic);
}
 
Example 15
Source File: TopicStatusSubCommand.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) {
    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) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example 16
Source File: TopicStatusSubCommand.java    From rocketmq-read 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();
    }
}
 
Example 17
Source File: TopicStatusSubCommand.java    From rocketmq-4.3.0 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();
    }
}
 
Example 18
Source File: TopicStatusSubCommand.java    From DDMQ 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();
    }
}