Java Code Examples for org.apache.rocketmq.common.protocol.route.QueueData#setBrokerName()
The following examples show how to use
org.apache.rocketmq.common.protocol.route.QueueData#setBrokerName() .
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: DefaultMQProducerTest.java From rocketmq with Apache License 2.0 | 6 votes |
public static TopicRouteData createTopicRoute() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<>(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<>(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); queueData.setReadQueueNums(3); queueData.setWriteQueueNums(4); queueData.setTopicSynFlag(0); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); return topicRouteData; }
Example 2
Source File: DefaultMQProducerTest.java From rocketmq with Apache License 2.0 | 6 votes |
public static TopicRouteData createTopicRoute() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<BrokerData>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<Long, String>(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<QueueData>(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); queueData.setReadQueueNums(3); queueData.setWriteQueueNums(4); queueData.setTopicSynFlag(0); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); return topicRouteData; }
Example 3
Source File: DefaultMQProducerTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
public static TopicRouteData createTopicRoute() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<BrokerData>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<Long, String>(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<QueueData>(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); queueData.setReadQueueNums(3); queueData.setWriteQueueNums(4); queueData.setTopicSynFlag(0); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); return topicRouteData; }
Example 4
Source File: DefaultMQProducerTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
public static TopicRouteData createTopicRoute() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<BrokerData>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<Long, String>(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<QueueData>(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); queueData.setReadQueueNums(3); queueData.setWriteQueueNums(4); queueData.setTopicSynFlag(0); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); return topicRouteData; }
Example 5
Source File: ClientFuseTest.java From DeFiBus with Apache License 2.0 | 6 votes |
public static TopicRouteData createTopicRoute() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<BrokerData>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<Long, String>(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<QueueData>(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); queueData.setReadQueueNums(3); queueData.setWriteQueueNums(4); queueData.setTopicSynFlag(0); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); return topicRouteData; }
Example 6
Source File: DefaultMQProducerTest.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
public static TopicRouteData createTopicRoute() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<BrokerData>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<Long, String>(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<QueueData>(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); queueData.setReadQueueNums(3); queueData.setWriteQueueNums(4); queueData.setTopicSynFlag(0); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); return topicRouteData; }
Example 7
Source File: DefaultMQConsumerWithTraceTest.java From rocketmq with Apache License 2.0 | 6 votes |
public static TopicRouteData createTopicRoute() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<BrokerData>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<Long, String>(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<QueueData>(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); queueData.setReadQueueNums(3); queueData.setWriteQueueNums(4); queueData.setTopicSynFlag(0); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); return topicRouteData; }
Example 8
Source File: MQClientInstanceTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testTopicRouteData2TopicPublishInfo() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<BrokerData>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<Long, String>(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<QueueData>(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); queueData.setReadQueueNums(3); queueData.setWriteQueueNums(4); queueData.setTopicSynFlag(0); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); TopicPublishInfo topicPublishInfo = MQClientInstance.topicRouteData2TopicPublishInfo(topic, topicRouteData); assertThat(topicPublishInfo.isHaveTopicRouterInfo()).isFalse(); assertThat(topicPublishInfo.getMessageQueueList().size()).isEqualTo(4); }
Example 9
Source File: MQClientInstanceTest.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
@Test public void testTopicRouteData2TopicPublishInfo() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<BrokerData>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<Long, String>(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<QueueData>(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); queueData.setReadQueueNums(3); queueData.setWriteQueueNums(4); queueData.setTopicSynFlag(0); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); TopicPublishInfo topicPublishInfo = MQClientInstance.topicRouteData2TopicPublishInfo(topic, topicRouteData); assertThat(topicPublishInfo.isHaveTopicRouterInfo()).isFalse(); assertThat(topicPublishInfo.getMessageQueueList().size()).isEqualTo(4); }
Example 10
Source File: TopicRouteDataTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testTopicRouteDataJsonSerialize() throws Exception { TopicRouteData topicRouteData = new TopicRouteData(); QueueData queueData = new QueueData(); queueData.setBrokerName("broker-a"); queueData.setPerm(6); queueData.setReadQueueNums(8); queueData.setWriteQueueNums(8); queueData.setTopicSynFlag(0); List<QueueData> queueDataList = new ArrayList<QueueData>(); queueDataList.add(queueData); HashMap<Long, String> brokerAddrs = new HashMap<Long, String>(); brokerAddrs.put(0L, "192.168.0.47:10911"); brokerAddrs.put(1L, "192.168.0.47:10921"); BrokerData brokerData = new BrokerData(); brokerData.setBrokerAddrs(brokerAddrs); brokerData.setBrokerName("broker-a"); brokerData.setCluster("TestCluster"); List<BrokerData> brokerDataList = new ArrayList<BrokerData>(); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); topicRouteData.setQueueDatas(queueDataList); String topicRouteDataJsonStr = RemotingSerializable.toJson(topicRouteData, true); TopicRouteData topicRouteDataFromJson = RemotingSerializable.fromJson(topicRouteDataJsonStr, TopicRouteData.class); assertThat(topicRouteDataJsonStr).isNotEqualTo(topicRouteDataFromJson); assertThat(topicRouteDataFromJson.getBrokerDatas()).isEqualTo(topicRouteData.getBrokerDatas()); assertThat(topicRouteDataFromJson.getFilterServerTable()).isEqualTo(topicRouteData.getFilterServerTable()); assertThat(topicRouteDataFromJson.getQueueDatas()).isEqualTo(topicRouteData.getQueueDatas()); }
Example 11
Source File: RouteInfoManager.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
private void createAndUpdateQueueData(final String brokerName, final TopicConfig topicConfig) { QueueData queueData = new QueueData(); queueData.setBrokerName(brokerName); queueData.setWriteQueueNums(topicConfig.getWriteQueueNums()); queueData.setReadQueueNums(topicConfig.getReadQueueNums()); queueData.setPerm(topicConfig.getPerm()); queueData.setTopicSynFlag(topicConfig.getTopicSysFlag()); List<QueueData> queueDataList = this.topicQueueTable.get(topicConfig.getTopicName()); if (null == queueDataList) { queueDataList = new LinkedList<QueueData>(); queueDataList.add(queueData); this.topicQueueTable.put(topicConfig.getTopicName(), queueDataList); log.info("new topic registerd, {} {}", topicConfig.getTopicName(), queueData); } else { boolean addNewOne = true; Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { if (qd.equals(queueData)) { addNewOne = false; } else { log.info("topic changed, {} OLD: {} NEW: {}", topicConfig.getTopicName(), qd, queueData); it.remove(); } } } if (addNewOne) { queueDataList.add(queueData); } } }
Example 12
Source File: MQClientInstanceTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testTopicRouteData2TopicPublishInfo() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<>(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<>(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); queueData.setReadQueueNums(3); queueData.setWriteQueueNums(4); queueData.setTopicSynFlag(0); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); TopicPublishInfo topicPublishInfo = MQClientInstance.topicRouteData2TopicPublishInfo(topic, topicRouteData); assertThat(topicPublishInfo.isHaveTopicRouterInfo()).isFalse(); assertThat(topicPublishInfo.getMessageQueueList().size()).isEqualTo(4); }
Example 13
Source File: RouteInfoManager.java From rocketmq with Apache License 2.0 | 5 votes |
/** * 创建topic的QueueData,将其加入到{@link #topicQueueTable}中 * 在注册Broker的Master || 更新Topic配置 时触发,这样Producer和Consumer就能获取到可用的QueueData * 更新 topic 队列信息 * * @param brokerName broker名 * @param topicConfig topic配置 */ private void createAndUpdateQueueData(final String brokerName, final TopicConfig topicConfig) { QueueData queueData = new QueueData(); queueData.setBrokerName(brokerName); queueData.setWriteQueueNums(topicConfig.getWriteQueueNums()); queueData.setReadQueueNums(topicConfig.getReadQueueNums()); queueData.setPerm(topicConfig.getPerm()); queueData.setTopicSynFlag(topicConfig.getTopicSysFlag()); List<QueueData> queueDataList = this.topicQueueTable.get(topicConfig.getTopicName()); if (null == queueDataList) { queueDataList = new LinkedList<QueueData>(); queueDataList.add(queueData); this.topicQueueTable.put(topicConfig.getTopicName(), queueDataList); log.info("new topic registerd, {} {}", topicConfig.getTopicName(), queueData); } else { boolean addNewOne = true; Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { if (qd.equals(queueData)) { //原始QueueData是否和新建的一样 addNewOne = false; } else { log.info("topic changed, {} OLD: {} NEW: {}", topicConfig.getTopicName(), qd, queueData); it.remove(); } } } if (addNewOne) { queueDataList.add(queueData); } } }
Example 14
Source File: RouteInfoManager.java From rocketmq with Apache License 2.0 | 5 votes |
private void createAndUpdateQueueData(final String brokerName, final TopicConfig topicConfig) { QueueData queueData = new QueueData(); queueData.setBrokerName(brokerName); queueData.setWriteQueueNums(topicConfig.getWriteQueueNums()); queueData.setReadQueueNums(topicConfig.getReadQueueNums()); queueData.setPerm(topicConfig.getPerm()); queueData.setTopicSynFlag(topicConfig.getTopicSysFlag()); List<QueueData> queueDataList = this.topicQueueTable.get(topicConfig.getTopicName()); if (null == queueDataList) { queueDataList = new LinkedList<QueueData>(); queueDataList.add(queueData); this.topicQueueTable.put(topicConfig.getTopicName(), queueDataList); log.info("new topic registered, {} {}", topicConfig.getTopicName(), queueData); } else { boolean addNewOne = true; Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { if (qd.equals(queueData)) { addNewOne = false; } else { log.info("topic changed, {} OLD: {} NEW: {}", topicConfig.getTopicName(), qd, queueData); it.remove(); } } } if (addNewOne) { queueDataList.add(queueData); } } }
Example 15
Source File: MQClientInstanceTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Test public void testTopicRouteData2TopicPublishInfo() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<BrokerData>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<Long, String>(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<QueueData>(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); queueData.setReadQueueNums(3); queueData.setWriteQueueNums(4); queueData.setTopicSynFlag(0); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); TopicPublishInfo topicPublishInfo = MQClientInstance.topicRouteData2TopicPublishInfo(topic, topicRouteData); assertThat(topicPublishInfo.isHaveTopicRouterInfo()).isFalse(); assertThat(topicPublishInfo.getMessageQueueList().size()).isEqualTo(4); }
Example 16
Source File: RouteInfoManager.java From DDMQ with Apache License 2.0 | 5 votes |
private void createAndUpdateQueueData(final String brokerName, final TopicConfig topicConfig) { QueueData queueData = new QueueData(); queueData.setBrokerName(brokerName); queueData.setWriteQueueNums(topicConfig.getWriteQueueNums()); queueData.setReadQueueNums(topicConfig.getReadQueueNums()); queueData.setPerm(topicConfig.getPerm()); queueData.setTopicSynFlag(topicConfig.getTopicSysFlag()); List<QueueData> queueDataList = this.topicQueueTable.get(topicConfig.getTopicName()); if (null == queueDataList) { queueDataList = new LinkedList<QueueData>(); queueDataList.add(queueData); this.topicQueueTable.put(topicConfig.getTopicName(), queueDataList); log.info("new topic registered, {} {}", topicConfig.getTopicName(), queueData); } else { boolean addNewOne = true; Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { if (qd.equals(queueData)) { addNewOne = false; } else { log.info("topic changed, {} OLD: {} NEW: {}", topicConfig.getTopicName(), qd, queueData); it.remove(); } } } if (addNewOne) { queueDataList.add(queueData); } } }
Example 17
Source File: RouteInfoManager.java From DDMQ with Apache License 2.0 | 5 votes |
private void createAndUpdateQueueData(final String brokerName, final TopicConfig topicConfig) { QueueData queueData = new QueueData(); queueData.setBrokerName(brokerName); queueData.setWriteQueueNums(topicConfig.getWriteQueueNums()); queueData.setReadQueueNums(topicConfig.getReadQueueNums()); queueData.setPerm(topicConfig.getPerm()); queueData.setTopicSynFlag(topicConfig.getTopicSysFlag()); List<QueueData> queueDataList = this.topicQueueTable.get(topicConfig.getTopicName()); if (null == queueDataList) { queueDataList = new LinkedList<QueueData>(); queueDataList.add(queueData); this.topicQueueTable.put(topicConfig.getTopicName(), queueDataList); log.info("new topic registered, {} {}", topicConfig.getTopicName(), queueData); } else { boolean addNewOne = true; Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { if (qd.equals(queueData)) { addNewOne = false; } else { log.info("topic changed, {} OLD: {} NEW: {}", topicConfig.getTopicName(), qd, queueData); it.remove(); } } } if (addNewOne) { queueDataList.add(queueData); } } }
Example 18
Source File: MQClientInstanceTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Test public void testTopicRouteData2TopicPublishInfo() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<BrokerData>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<Long, String>(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<QueueData>(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); queueData.setReadQueueNums(3); queueData.setWriteQueueNums(4); queueData.setTopicSynFlag(0); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); TopicPublishInfo topicPublishInfo = MQClientInstance.topicRouteData2TopicPublishInfo(topic, topicRouteData); assertThat(topicPublishInfo.isHaveTopicRouterInfo()).isFalse(); assertThat(topicPublishInfo.getMessageQueueList().size()).isEqualTo(4); }
Example 19
Source File: RouteInfoManager.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
private void createAndUpdateQueueData(final String brokerName, final TopicConfig topicConfig) { QueueData queueData = new QueueData(); queueData.setBrokerName(brokerName); queueData.setWriteQueueNums(topicConfig.getWriteQueueNums()); queueData.setReadQueueNums(topicConfig.getReadQueueNums()); queueData.setPerm(topicConfig.getPerm()); queueData.setTopicSynFlag(topicConfig.getTopicSysFlag()); List<QueueData> queueDataList = this.topicQueueTable.get(topicConfig.getTopicName()); if (null == queueDataList) { queueDataList = new LinkedList<QueueData>(); queueDataList.add(queueData); this.topicQueueTable.put(topicConfig.getTopicName(), queueDataList); log.info("new topic registerd, {} {}", topicConfig.getTopicName(), queueData); } else { boolean addNewOne = true; Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { if (qd.equals(queueData)) { addNewOne = false; } else { log.info("topic changed, {} OLD: {} NEW: {}", topicConfig.getTopicName(), qd, queueData); it.remove(); } } } if (addNewOne) { queueDataList.add(queueData); } } }
Example 20
Source File: RouteInfoManager.java From rocketmq-read with Apache License 2.0 | 4 votes |
/** * 创建或者更新Broker对应的队列的数据 * @param brokerName brokerName * @param topicConfig topicConfig */ private void createAndUpdateQueueData(final String brokerName, final TopicConfig topicConfig) { QueueData queueData = new QueueData(); queueData.setBrokerName(brokerName); queueData.setWriteQueueNums(topicConfig.getWriteQueueNums()); queueData.setReadQueueNums(topicConfig.getReadQueueNums()); queueData.setPerm(topicConfig.getPerm()); queueData.setTopicSynFlag(topicConfig.getTopicSysFlag()); /* * 一个topic对应着多个broker */ List<QueueData> queueDataList = this.topicQueueTable.get(topicConfig.getTopicName()); if (null == queueDataList) { queueDataList = new LinkedList<>(); queueDataList.add(queueData); this.topicQueueTable.put(topicConfig.getTopicName(), queueDataList); log.info("new topic registered, {} {}", topicConfig.getTopicName(), queueData); } else { boolean addNewOne = true; Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { if (qd.equals(queueData)) { addNewOne = false; } else { log.info("topic changed, {} OLD: {} NEW: {}", topicConfig.getTopicName(), qd, queueData); //addNewOnetrue,后面会加,这里就移除 it.remove(); } } } //如果addNewOne=true,判断不equals,就添加 if (addNewOne) { queueDataList.add(queueData); } } }