com.alibaba.rocketmq.common.protocol.body.TopicList Java Examples

The following examples show how to use com.alibaba.rocketmq.common.protocol.body.TopicList. 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: RouteInfoManager.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
public byte[] getAllTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            topicList.getTopicList().addAll(this.topicQueueTable.keySet());
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #2
Source File: RouteInfoManager.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public byte[] getHasUnitSubUnUnitTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Iterator<Entry<String, List<QueueData>>> topicTableIt =
                    this.topicQueueTable.entrySet().iterator();
            while (topicTableIt.hasNext()) {
                Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                String topic = topicEntry.getKey();
                List<QueueData> queueDatas = topicEntry.getValue();
                if (queueDatas != null && queueDatas.size() > 0
                        && !TopicSysFlag.hasUnitFlag(queueDatas.get(0).getTopicSynFlag())
                        && TopicSysFlag.hasUnitSubFlag(queueDatas.get(0).getTopicSynFlag())) {
                    topicList.getTopicList().add(topic);
                }
            }
        } finally {
            this.lock.readLock().unlock();
        }
    } catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #3
Source File: RouteInfoManager.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public byte[] getHasUnitSubTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Iterator<Entry<String, List<QueueData>>> topicTableIt =
                    this.topicQueueTable.entrySet().iterator();
            while (topicTableIt.hasNext()) {
                Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                String topic = topicEntry.getKey();
                List<QueueData> queueDatas = topicEntry.getValue();
                if (queueDatas != null && queueDatas.size() > 0
                        && TopicSysFlag.hasUnitSubFlag(queueDatas.get(0).getTopicSynFlag())) {
                    topicList.getTopicList().add(topic);
                }
            }
        } finally {
            this.lock.readLock().unlock();
        }
    } catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #4
Source File: TopicServiceImpl.java    From rocket-console with Apache License 2.0 6 votes vote down vote up
@Override
public TopicList fetchAllTopicList() {
    try {
        TopicList topicList = mqAdminExt.fetchAllTopicList();
        topicList.setTopicList(Sets.newHashSet(Iterables.filter(topicList.getTopicList(), new Predicate<String>() {
            @Override
            public boolean apply(String s) {
                return !(s.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX) || s.startsWith(MixAll.DLQ_GROUP_TOPIC_PREFIX)); // todo 暂时先过滤掉 以后再搞出来
            }
        })));
        return topicList;

    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
 
Example #5
Source File: RouteInfoManager.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public byte[] getUnitTopics() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Iterator<Entry<String, List<QueueData>>> topicTableIt =
                    this.topicQueueTable.entrySet().iterator();
            while (topicTableIt.hasNext()) {
                Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                String topic = topicEntry.getKey();
                List<QueueData> queueDatas = topicEntry.getValue();
                if (queueDatas != null && queueDatas.size() > 0
                        && TopicSysFlag.hasUnitFlag(queueDatas.get(0).getTopicSynFlag())) {
                    topicList.getTopicList().add(topic);
                }
            }
        } finally {
            this.lock.readLock().unlock();
        }
    } catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #6
Source File: RouteInfoManager.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
public byte[] getAllTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            topicList.getTopicList().addAll(this.topicQueueTable.keySet());
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #7
Source File: RouteInfoManager.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public byte[] getAllTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            topicList.getTopicList().addAll(this.topicQueueTable.keySet());
        } finally {
            this.lock.readLock().unlock();
        }
    } catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #8
Source File: RouteInfoManager.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
/**
 * 获取含有单元化订阅组的非单元化 Topic 列表
 *
 * @return
 */
public byte[] getHasUnitSubUnUnitTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Iterator<Entry<String, List<QueueData>>> topicTableIt =
                    this.topicQueueTable.entrySet().iterator();
            while (topicTableIt.hasNext()) {
                Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                String topic = topicEntry.getKey();
                List<QueueData> queueDatas = topicEntry.getValue();
                if (queueDatas != null && queueDatas.size() > 0
                        && !TopicSysFlag.hasUnitFlag(queueDatas.get(0).getTopicSynFlag())
                        && TopicSysFlag.hasUnitSubFlag(queueDatas.get(0).getTopicSynFlag())) {
                    topicList.getTopicList().add(topic);
                }
            }
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #9
Source File: RouteInfoManager.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
/**
 * 获取中心向单元同步的所有 topic 列表
 *
 * @return
 */
public byte[] getHasUnitSubTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Iterator<Entry<String, List<QueueData>>> topicTableIt =
                    this.topicQueueTable.entrySet().iterator();
            while (topicTableIt.hasNext()) {
                Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                String topic = topicEntry.getKey();
                List<QueueData> queueDatas = topicEntry.getValue();
                if (queueDatas != null && queueDatas.size() > 0
                        && TopicSysFlag.hasUnitSubFlag(queueDatas.get(0).getTopicSynFlag())) {
                    topicList.getTopicList().add(topic);
                }
            }
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #10
Source File: RouteInfoManager.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
/**
 * 获取单元逻辑下的所有 topic 列表
 *
 * @return
 */
public byte[] getUnitTopics() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Iterator<Entry<String, List<QueueData>>> topicTableIt =
                    this.topicQueueTable.entrySet().iterator();
            while (topicTableIt.hasNext()) {
                Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                String topic = topicEntry.getKey();
                List<QueueData> queueDatas = topicEntry.getValue();
                if (queueDatas != null && queueDatas.size() > 0
                        && TopicSysFlag.hasUnitFlag(queueDatas.get(0).getTopicSynFlag())) {
                    topicList.getTopicList().add(topic);
                }
            }
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #11
Source File: RouteInfoManager.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
/**
 * 获取指定集群下的所有 topic 列表
 *
 * @param cluster
 * @return
 */
public byte[] getTopicsByCluster(String cluster) {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Set<String> brokerNameSet = this.clusterAddrTable.get(cluster);
            for (String brokerName : brokerNameSet) {
                Iterator<Entry<String, List<QueueData>>> topicTableIt =
                        this.topicQueueTable.entrySet().iterator();
                while (topicTableIt.hasNext()) {
                    Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                    String topic = topicEntry.getKey();
                    List<QueueData> queueDatas = topicEntry.getValue();
                    for (QueueData queueData : queueDatas) {
                        if (brokerName.equals(queueData.getBrokerName())) {
                            topicList.getTopicList().add(topic);
                            break;
                        }
                    }
                }
            }
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #12
Source File: RouteInfoManager.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
/**
 * 获取指定集群下的所有 topic 列表
 *
 * @return
 */
public byte[] getSystemTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            for (String cluster : clusterAddrTable.keySet()) {
                topicList.getTopicList().add(cluster);
                topicList.getTopicList().addAll(this.clusterAddrTable.get(cluster));
            }

            // 随机取一台 broker
            if (brokerAddrTable != null && !brokerAddrTable.isEmpty()) {
                Iterator<String> it = brokerAddrTable.keySet().iterator();
                while (it.hasNext()) {
                    BrokerData bd = brokerAddrTable.get(it.next());
                    HashMap<Long, String> brokerAddrs = bd.getBrokerAddrs();
                    if (bd.getBrokerAddrs() != null && !bd.getBrokerAddrs().isEmpty()) {
                        Iterator<Long> it2 = brokerAddrs.keySet().iterator();
                        topicList.setBrokerAddr(brokerAddrs.get(it2.next()));
                        break;
                    }
                }
            }
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #13
Source File: RouteInfoManager.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public byte[] getTopicsByCluster(String cluster) {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Set<String> brokerNameSet = this.clusterAddrTable.get(cluster);
            for (String brokerName : brokerNameSet) {
                Iterator<Entry<String, List<QueueData>>> topicTableIt =
                        this.topicQueueTable.entrySet().iterator();
                while (topicTableIt.hasNext()) {
                    Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                    String topic = topicEntry.getKey();
                    List<QueueData> queueDatas = topicEntry.getValue();
                    for (QueueData queueData : queueDatas) {
                        if (brokerName.equals(queueData.getBrokerName())) {
                            topicList.getTopicList().add(topic);
                            break;
                        }
                    }
                }
            }
        } finally {
            this.lock.readLock().unlock();
        }
    } catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #14
Source File: RouteInfoManager.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public byte[] getSystemTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            for (Map.Entry<String, Set<String>> entry : clusterAddrTable.entrySet()) {
                topicList.getTopicList().add(entry.getKey());
                topicList.getTopicList().addAll(entry.getValue());
            }

            if (brokerAddrTable != null && !brokerAddrTable.isEmpty()) {
                Iterator<String> it = brokerAddrTable.keySet().iterator();
                while (it.hasNext()) {
                    BrokerData bd = brokerAddrTable.get(it.next());
                    HashMap<Long, String> brokerAddrs = bd.getBrokerAddrs();
                    if (bd.getBrokerAddrs() != null && !bd.getBrokerAddrs().isEmpty()) {
                        Iterator<Long> it2 = brokerAddrs.keySet().iterator();
                        topicList.setBrokerAddr(brokerAddrs.get(it2.next()));
                        break;
                    }
                }
            }
        } finally {
            this.lock.readLock().unlock();
        }
    } catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #15
Source File: TopicService.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@CmdTrace(cmdClazz = TopicListSubCommand.class)
public Table list() throws Throwable {
    Throwable t = null;
    DefaultMQAdminExt defaultMQAdminExt = getDefaultMQAdminExt();
    try {
        defaultMQAdminExt.start();
        TopicList topicList = defaultMQAdminExt.fetchAllTopicList();
        int row = topicList.getTopicList().size();
        if (row > 0) {
            Table table = new Table(new String[] { "topic" }, row);
            for (String topicName : topicList.getTopicList()) {
                Object[] tr = table.createTR();
                tr[0] = topicName;
                table.insertTR(tr);
            }
            return table;
        }
        else {
            throw new IllegalStateException("defaultMQAdminExt.fetchAllTopicList() is blank");
        }
    }
    catch (Throwable e) {
        logger.error(e.getMessage(), e);
        t = e;
    }
    finally {
        shutdownDefaultMQAdminExt(defaultMQAdminExt);
    }
    throw t;
}
 
Example #16
Source File: RouteInfoManager.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public byte[] getHasUnitSubUnUnitTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Iterator<Entry<String, List<QueueData>>> topicTableIt =
                    this.topicQueueTable.entrySet().iterator();
            while (topicTableIt.hasNext()) {
                Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                String topic = topicEntry.getKey();
                List<QueueData> queueDatas = topicEntry.getValue();
                if (queueDatas != null && queueDatas.size() > 0
                        && !TopicSysFlag.hasUnitFlag(queueDatas.get(0).getTopicSynFlag())
                        && TopicSysFlag.hasUnitSubFlag(queueDatas.get(0).getTopicSynFlag())) {
                    topicList.getTopicList().add(topic);
                }
            }
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #17
Source File: RouteInfoManager.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public byte[] getHasUnitSubTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Iterator<Entry<String, List<QueueData>>> topicTableIt =
                    this.topicQueueTable.entrySet().iterator();
            while (topicTableIt.hasNext()) {
                Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                String topic = topicEntry.getKey();
                List<QueueData> queueDatas = topicEntry.getValue();
                if (queueDatas != null && queueDatas.size() > 0
                        && TopicSysFlag.hasUnitSubFlag(queueDatas.get(0).getTopicSynFlag())) {
                    topicList.getTopicList().add(topic);
                }
            }
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #18
Source File: RouteInfoManager.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public byte[] getUnitTopics() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Iterator<Entry<String, List<QueueData>>> topicTableIt =
                    this.topicQueueTable.entrySet().iterator();
            while (topicTableIt.hasNext()) {
                Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                String topic = topicEntry.getKey();
                List<QueueData> queueDatas = topicEntry.getValue();
                if (queueDatas != null && queueDatas.size() > 0
                        && TopicSysFlag.hasUnitFlag(queueDatas.get(0).getTopicSynFlag())) {
                    topicList.getTopicList().add(topic);
                }
            }
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #19
Source File: RouteInfoManager.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public byte[] getTopicsByCluster(String cluster) {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Set<String> brokerNameSet = this.clusterAddrTable.get(cluster);
            for (String brokerName : brokerNameSet) {
                Iterator<Entry<String, List<QueueData>>> topicTableIt =
                        this.topicQueueTable.entrySet().iterator();
                while (topicTableIt.hasNext()) {
                    Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                    String topic = topicEntry.getKey();
                    List<QueueData> queueDatas = topicEntry.getValue();
                    for (QueueData queueData : queueDatas) {
                        if (brokerName.equals(queueData.getBrokerName())) {
                            topicList.getTopicList().add(topic);
                            break;
                        }
                    }
                }
            }
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #20
Source File: RouteInfoManager.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public byte[] getSystemTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            for (String cluster : clusterAddrTable.keySet()) {
                topicList.getTopicList().add(cluster);
                topicList.getTopicList().addAll(this.clusterAddrTable.get(cluster));
            }

            if (brokerAddrTable != null && !brokerAddrTable.isEmpty()) {
                Iterator<String> it = brokerAddrTable.keySet().iterator();
                while (it.hasNext()) {
                    BrokerData bd = brokerAddrTable.get(it.next());
                    HashMap<Long, String> brokerAddrs = bd.getBrokerAddrs();
                    if (bd.getBrokerAddrs() != null && !bd.getBrokerAddrs().isEmpty()) {
                        Iterator<Long> it2 = brokerAddrs.keySet().iterator();
                        topicList.setBrokerAddr(brokerAddrs.get(it2.next()));
                        break;
                    }
                }
            }
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example #21
Source File: MQAdminExtImpl.java    From rocket-console with Apache License 2.0 4 votes vote down vote up
@Override //可以根据集群细分topic了
public TopicList fetchTopicsByCLuster(String clusterName) throws RemotingException, MQClientException, InterruptedException {
    return  MQAdminInstance.threadLocalMQAdminExt().fetchTopicsByCLuster(clusterName);
}
 
Example #22
Source File: MQAdminExtImpl.java    From rocket-console with Apache License 2.0 4 votes vote down vote up
@Override
public TopicList fetchAllTopicList() throws RemotingException, MQClientException, InterruptedException {
    TopicList topicList = MQAdminInstance.threadLocalMQAdminExt().fetchAllTopicList();
    logger.info("op=look={}", JsonUtil.obj2String(topicList.getTopicList()));
    return topicList;
}
 
Example #23
Source File: TopicService.java    From rocket-console with Apache License 2.0 votes vote down vote up
TopicList fetchAllTopicList();