Java Code Examples for org.apache.rocketmq.common.protocol.route.BrokerData#getBrokerName()
The following examples show how to use
org.apache.rocketmq.common.protocol.route.BrokerData#getBrokerName() .
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: RocketMQProduceOffsetFetcher.java From DDMQ with Apache License 2.0 | 6 votes |
public Map<MessageQueue, Long> getMaxOffset(Collection<BrokerData> brokers) { HashMap<MessageQueue, Long> offsetTable = Maps.newHashMap(); if (CollectionUtils.isNotEmpty(brokers)) { for (BrokerData broker : brokers) { try { AllMaxOffset allMaxOffset = defaultMQAdminExt.getAllMaxOffset(broker.selectBrokerAddr()); for (Map.Entry<String, ConcurrentHashMap<Integer, Long>> entry : allMaxOffset.getOffsetTable().entrySet()) { for (Map.Entry<Integer, Long> entry1 : entry.getValue().entrySet()) { MessageQueue mq = new MessageQueue(entry.getKey(), broker.getBrokerName(), entry1.getKey()); offsetTable.put(mq, entry1.getValue()); } } } catch (Exception e) { LOGGER.error("GetMaxOffset Exception", e); } } } return offsetTable; }
Example 2
Source File: TopicListSubCommand.java From DDMQ with Apache License 2.0 | 6 votes |
private String findTopicBelongToWhichCluster(final String topic, final ClusterInfo clusterInfo, final DefaultMQAdminExt defaultMQAdminExt) throws RemotingException, MQClientException, InterruptedException { TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { return next.getKey(); } } return null; }
Example 3
Source File: DefaultMQAdminExtImpl.java From DDMQ with Apache License 2.0 | 6 votes |
@Override public Set<String> getTopicClusterList( final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException { Set<String> clusterSet = new HashSet<String>(); ClusterInfo clusterInfo = examineBrokerClusterInfo(); TopicRouteData topicRouteData = examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Map.Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { clusterSet.add(next.getKey()); } } return clusterSet; }
Example 4
Source File: TopicListSubCommand.java From DDMQ with Apache License 2.0 | 6 votes |
private String findTopicBelongToWhichCluster(final String topic, final ClusterInfo clusterInfo, final DefaultMQAdminExt defaultMQAdminExt) throws RemotingException, MQClientException, InterruptedException { TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { return next.getKey(); } } return null; }
Example 5
Source File: RocketMQProduceOffsetFetcher.java From DDMQ with Apache License 2.0 | 6 votes |
public Map<MessageQueue, Long> getMaxOffset(Collection<BrokerData> brokers) { HashMap<MessageQueue, Long> offsetTable = Maps.newHashMap(); if (CollectionUtils.isNotEmpty(brokers)) { for (BrokerData broker : brokers) { try { AllMaxOffset allMaxOffset = defaultMQAdminExt.getAllMaxOffset(broker.selectBrokerAddr()); for (Map.Entry<String, ConcurrentHashMap<Integer, Long>> entry : allMaxOffset.getOffsetTable().entrySet()) { for (Map.Entry<Integer, Long> entry1 : entry.getValue().entrySet()) { MessageQueue mq = new MessageQueue(entry.getKey(), broker.getBrokerName(), entry1.getKey()); offsetTable.put(mq, entry1.getValue()); } } } catch (Exception e) { LOGGER.error("GetMaxOffset Exception", e); } } } return offsetTable; }
Example 6
Source File: DefaultMQAdminExtImpl.java From DDMQ with Apache License 2.0 | 6 votes |
@Override public Set<String> getTopicClusterList( final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException { Set<String> clusterSet = new HashSet<String>(); ClusterInfo clusterInfo = examineBrokerClusterInfo(); TopicRouteData topicRouteData = examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Map.Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { clusterSet.add(next.getKey()); } } return clusterSet; }
Example 7
Source File: DefaultMQAdminExtImpl.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Override public Set<String> getTopicClusterList( final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException { Set<String> clusterSet = new HashSet<String>(); ClusterInfo clusterInfo = examineBrokerClusterInfo(); TopicRouteData topicRouteData = examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Map.Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { clusterSet.add(next.getKey()); } } return clusterSet; }
Example 8
Source File: TopicListSubCommand.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
private String findTopicBelongToWhichCluster(final String topic, final ClusterInfo clusterInfo, final DefaultMQAdminExt defaultMQAdminExt) throws RemotingException, MQClientException, InterruptedException { TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { return next.getKey(); } } return null; }
Example 9
Source File: TopicListSubCommand.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
private String findTopicBelongToWhichCluster(final String topic, final ClusterInfo clusterInfo, final DefaultMQAdminExt defaultMQAdminExt) throws RemotingException, MQClientException, InterruptedException { TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { return next.getKey(); } } return null; }
Example 10
Source File: DefaultMQAdminExtImpl.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Override public Set<String> getTopicClusterList( final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException { Set<String> clusterSet = new HashSet<String>(); ClusterInfo clusterInfo = examineBrokerClusterInfo(); TopicRouteData topicRouteData = examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Map.Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { clusterSet.add(next.getKey()); } } return clusterSet; }
Example 11
Source File: DefaultMQAdminExtImpl.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
@Override public Set<String> getTopicClusterList(final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException { Set<String> clusterSet = new HashSet<String>(); ClusterInfo clusterInfo = examineBrokerClusterInfo(); TopicRouteData topicRouteData = examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Map.Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { clusterSet.add(next.getKey()); } } return clusterSet; }
Example 12
Source File: DefaultMQAdminExtImpl.java From rocketmq with Apache License 2.0 | 6 votes |
@Override public Set<String> getTopicClusterList(final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException { Set<String> clusterSet = new HashSet<String>(); ClusterInfo clusterInfo = examineBrokerClusterInfo(); TopicRouteData topicRouteData = examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Map.Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { clusterSet.add(next.getKey()); } } return clusterSet; }
Example 13
Source File: TopicListSubCommand.java From rocketmq with Apache License 2.0 | 6 votes |
private String findTopicBelongToWhichCluster(final String topic, final ClusterInfo clusterInfo, final DefaultMQAdminExt defaultMQAdminExt) throws RemotingException, MQClientException, InterruptedException { TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { return next.getKey(); } } return null; }
Example 14
Source File: DefaultMQAdminExtImpl.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
@Override public Set<String> getTopicClusterList(final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException { Set<String> clusterSet = new HashSet<String>(); ClusterInfo clusterInfo = examineBrokerClusterInfo(); TopicRouteData topicRouteData = examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Map.Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { clusterSet.add(next.getKey()); } } return clusterSet; }
Example 15
Source File: Utils.java From DDMQ with Apache License 2.0 | 5 votes |
public static boolean isBrokerTopicWritable(String cluster, String nameSvr, String address/* broker Address */) { try { DefaultMQAdminExt adminExt = getMQAdminExt(nameSvr, cluster); String brokerPermission = adminExt.getBrokerConfig(address).getProperty("brokerPermission"); if (!PermName.isWriteable(Integer.parseInt(brokerPermission))) { logger.info("skip send because of broker brokerPermission={}. cluster={}, namesvr={}, address={}", brokerPermission, cluster, nameSvr, address); return false; } TopicRouteData topicRouteInfo = adminExt.examineTopicRouteInfo("SELF_TEST_TOPIC"); String brokerName = null; for (BrokerData brokerData : topicRouteInfo.getBrokerDatas()) { if (StringUtils.equals(brokerData.getBrokerAddrs().get(0L), address)) { brokerName = brokerData.getBrokerName(); break; } } if (brokerName != null) { for (QueueData queueData : topicRouteInfo.getQueueDatas()) { if (StringUtils.equals(queueData.getBrokerName(), brokerName)) { if (queueData.getWriteQueueNums() == 0 || !PermName.isWriteable(queueData.getPerm())) { logger.info("skip send because of queue.Permission={},queue.writeQNuum={}. cluster={}, namesvr={}, address={}", queueData.getPerm(), queueData.getWriteQueueNums(), cluster, nameSvr, address); return false; } break; } } } } catch (Exception e) { logger.error("exception in isBrokerTopicWritable, cluster={}, namesvr={}, address={}", cluster, nameSvr, address, e); } return true; }
Example 16
Source File: RouteInfoManager.java From rocketmq-read with Apache License 2.0 | 4 votes |
/** * 获取某个topic的路由信息,BrokerData 和QueueData * @param topic tpic * @return TopicRouteData */ public TopicRouteData pickupTopicRouteData(final String topic) { TopicRouteData topicRouteData = new TopicRouteData(); //找到队列数据 boolean foundQueueData = false; //找到Broker数据的标记 boolean foundBrokerData = false; Set<String> brokerNameSet = new HashSet<>(); List<BrokerData> brokerDataList = new LinkedList<>(); topicRouteData.setBrokerDatas(brokerDataList); HashMap<String, List<String>> filterServerMap = new HashMap<>(); topicRouteData.setFilterServerTable(filterServerMap); try { try { this.lock.readLock().lockInterruptibly(); List<QueueData> queueDataList = this.topicQueueTable.get(topic); if (queueDataList != null) { topicRouteData.setQueueDatas(queueDataList); foundQueueData = true; //构造BrokerNameSet Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); brokerNameSet.add(qd.getBrokerName()); } //获取BrokerDataList for (String brokerName : brokerNameSet) { BrokerData brokerData = this.brokerAddrTable.get(brokerName); if (null != brokerData) { BrokerData brokerDataClone = new BrokerData(brokerData.getCluster(), brokerData.getBrokerName(), (HashMap<Long, String>) brokerData .getBrokerAddrs().clone(),(HashMap<Long, String>) brokerData.getBackUpBrokerAddrs().clone()); brokerDataList.add(brokerDataClone); foundBrokerData = true; for (final String brokerAddr : brokerDataClone.getBrokerAddrs().values()) { List<String> filterServerList = this.filterServerTable.get(brokerAddr); filterServerMap.put(brokerAddr, filterServerList); } } } } } finally { this.lock.readLock().unlock(); } } catch (Exception e) { log.error("pickupTopicRouteData Exception", e); } log.debug("pickupTopicRouteData {} {}", topic, topicRouteData); //如果队列和Notify都找到了,就返回 if (foundBrokerData && foundQueueData) { return topicRouteData; } return null; }
Example 17
Source File: RouteInfoManager.java From DDMQ with Apache License 2.0 | 4 votes |
public TopicRouteData pickupTopicRouteData(final String topic) { TopicRouteData topicRouteData = new TopicRouteData(); boolean foundQueueData = false; boolean foundBrokerData = false; Set<String> brokerNameSet = new HashSet<String>(); List<BrokerData> brokerDataList = new LinkedList<BrokerData>(); topicRouteData.setBrokerDatas(brokerDataList); HashMap<String, List<String>> filterServerMap = new HashMap<String, List<String>>(); topicRouteData.setFilterServerTable(filterServerMap); try { try { this.lock.readLock().lockInterruptibly(); List<QueueData> queueDataList = this.topicQueueTable.get(topic); if (queueDataList != null) { topicRouteData.setQueueDatas(queueDataList); foundQueueData = true; Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); brokerNameSet.add(qd.getBrokerName()); } long minTerm = Long.MAX_VALUE; for (String brokerName : brokerNameSet) { BrokerData brokerData = this.brokerAddrTable.get(brokerName); if (null != brokerData) { BrokerData brokerDataClone = new BrokerData(brokerData.getCluster(), brokerData.getBrokerName(), (HashMap<Long, String>) brokerData .getBrokerAddrs().clone()); brokerDataList.add(brokerDataClone); foundBrokerData = true; for (final String brokerAddr : brokerDataClone.getBrokerAddrs().values()) { List<String> filterServerList = this.filterServerTable.get(brokerAddr); filterServerMap.put(brokerAddr, filterServerList); BrokerLiveInfo brokerLiveInfo = brokerLiveTable.get(brokerAddr); if (brokerLiveInfo != null && brokerLiveInfo.getTerm() != null) { if (minTerm > brokerLiveInfo.getTerm()) { minTerm = brokerLiveInfo.getTerm(); } } } } } if (minTerm < Long.MAX_VALUE) { topicRouteData.setTerm(minTerm); } } } finally { this.lock.readLock().unlock(); } } catch (Exception e) { log.error("pickupTopicRouteData Exception", e); } if (log.isDebugEnabled()) { log.debug("pickupTopicRouteData {} {}", topic, topicRouteData); } if (foundBrokerData && foundQueueData) { return topicRouteData; } return null; }
Example 18
Source File: RouteInfoManager.java From rocketmq-4.3.0 with Apache License 2.0 | 4 votes |
public TopicRouteData pickupTopicRouteData(final String topic) { TopicRouteData topicRouteData = new TopicRouteData(); boolean foundQueueData = false; boolean foundBrokerData = false; Set<String> brokerNameSet = new HashSet<String>(); List<BrokerData> brokerDataList = new LinkedList<BrokerData>(); topicRouteData.setBrokerDatas(brokerDataList); HashMap<String, List<String>> filterServerMap = new HashMap<String, List<String>>(); topicRouteData.setFilterServerTable(filterServerMap); try { try { this.lock.readLock().lockInterruptibly(); // 获取topic的消息队列 List<QueueData> queueDataList = this.topicQueueTable.get(topic); if (queueDataList != null) { topicRouteData.setQueueDatas(queueDataList); foundQueueData = true; Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); // 从消息队列中获取broker brokerNameSet.add(qd.getBrokerName()); } for (String brokerName : brokerNameSet) { // 获取broker数据 BrokerData brokerData = this.brokerAddrTable.get(brokerName); if (null != brokerData) { BrokerData brokerDataClone = new BrokerData(brokerData.getCluster(), brokerData.getBrokerName(), (HashMap<Long, String>) brokerData .getBrokerAddrs().clone()); brokerDataList.add(brokerDataClone); foundBrokerData = true; for (final String brokerAddr : brokerDataClone.getBrokerAddrs().values()) { // 获取过滤的broker地址 List<String> filterServerList = this.filterServerTable.get(brokerAddr); filterServerMap.put(brokerAddr, filterServerList); } } } } } finally { this.lock.readLock().unlock(); } } catch (Exception e) { log.error("pickupTopicRouteData Exception", e); } log.debug("pickupTopicRouteData {} {}", topic, topicRouteData); if (foundBrokerData && foundQueueData) { return topicRouteData; } return null; }
Example 19
Source File: RouteInfoManager.java From DDMQ with Apache License 2.0 | 4 votes |
public TopicRouteData pickupTopicRouteData(final String topic) { TopicRouteData topicRouteData = new TopicRouteData(); boolean foundQueueData = false; boolean foundBrokerData = false; Set<String> brokerNameSet = new HashSet<String>(); List<BrokerData> brokerDataList = new LinkedList<BrokerData>(); topicRouteData.setBrokerDatas(brokerDataList); HashMap<String, List<String>> filterServerMap = new HashMap<String, List<String>>(); topicRouteData.setFilterServerTable(filterServerMap); try { try { this.lock.readLock().lockInterruptibly(); List<QueueData> queueDataList = this.topicQueueTable.get(topic); if (queueDataList != null) { topicRouteData.setQueueDatas(queueDataList); foundQueueData = true; Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); brokerNameSet.add(qd.getBrokerName()); } long minTerm = Long.MAX_VALUE; for (String brokerName : brokerNameSet) { BrokerData brokerData = this.brokerAddrTable.get(brokerName); if (null != brokerData) { BrokerData brokerDataClone = new BrokerData(brokerData.getCluster(), brokerData.getBrokerName(), (HashMap<Long, String>) brokerData .getBrokerAddrs().clone()); brokerDataList.add(brokerDataClone); foundBrokerData = true; for (final String brokerAddr : brokerDataClone.getBrokerAddrs().values()) { List<String> filterServerList = this.filterServerTable.get(brokerAddr); filterServerMap.put(brokerAddr, filterServerList); BrokerLiveInfo brokerLiveInfo = brokerLiveTable.get(brokerAddr); if (brokerLiveInfo != null && brokerLiveInfo.getTerm() != null) { if (minTerm > brokerLiveInfo.getTerm()) { minTerm = brokerLiveInfo.getTerm(); } } } } } if (minTerm < Long.MAX_VALUE) { topicRouteData.setTerm(minTerm); } } } finally { this.lock.readLock().unlock(); } } catch (Exception e) { log.error("pickupTopicRouteData Exception", e); } if (log.isDebugEnabled()) { log.debug("pickupTopicRouteData {} {}", topic, topicRouteData); } if (foundBrokerData && foundQueueData) { return topicRouteData; } return null; }
Example 20
Source File: RouteInfoManager.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 4 votes |
public TopicRouteData pickupTopicRouteData(final String topic) { TopicRouteData topicRouteData = new TopicRouteData(); boolean foundQueueData = false; boolean foundBrokerData = false; Set<String> brokerNameSet = new HashSet<String>(); List<BrokerData> brokerDataList = new LinkedList<BrokerData>(); topicRouteData.setBrokerDatas(brokerDataList); HashMap<String, List<String>> filterServerMap = new HashMap<String, List<String>>(); topicRouteData.setFilterServerTable(filterServerMap); try { try { this.lock.readLock().lockInterruptibly(); //根据topic获取QueueData信息 List<QueueData> queueDataList = this.topicQueueTable.get(topic); if (queueDataList != null) { topicRouteData.setQueueDatas(queueDataList); foundQueueData = true; Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); brokerNameSet.add(qd.getBrokerName()); } for (String brokerName : brokerNameSet) { BrokerData brokerData = this.brokerAddrTable.get(brokerName); if (null != brokerData) { //根据broker名称获取其地址信息 BrokerData brokerDataClone = new BrokerData(brokerData.getCluster(), brokerData.getBrokerName(), (HashMap<Long, String>) brokerData .getBrokerAddrs().clone()); brokerDataList.add(brokerDataClone); foundBrokerData = true; for (final String brokerAddr : brokerDataClone.getBrokerAddrs().values()) { List<String> filterServerList = this.filterServerTable.get(brokerAddr); filterServerMap.put(brokerAddr, filterServerList); } } } } } finally { this.lock.readLock().unlock(); } } catch (Exception e) { log.error("pickupTopicRouteData Exception", e); } if (log.isDebugEnabled()) { log.debug("pickupTopicRouteData {} {}", topic, topicRouteData); } if (foundBrokerData && foundQueueData) { return topicRouteData; } return null; }