Java Code Examples for org.apache.rocketmq.common.protocol.route.QueueData#setPerm()
The following examples show how to use
org.apache.rocketmq.common.protocol.route.QueueData#setPerm() .
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 with Apache License 2.0 | 6 votes |
private int wipeWritePermOfBroker(final String brokerName) { int wipeTopicCnt = 0; Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator(); while (itTopic.hasNext()) { Entry<String, List<QueueData>> entry = itTopic.next(); List<QueueData> qdList = entry.getValue(); Iterator<QueueData> it = qdList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { int perm = qd.getPerm(); perm &= ~PermName.PERM_WRITE; qd.setPerm(perm); wipeTopicCnt++; } } } return wipeTopicCnt; }
Example 2
Source File: DefaultMQProducerTest.java From rocketmq_trans_message 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 3
Source File: RouteInfoManager.java From rocketmq with Apache License 2.0 | 6 votes |
private int wipeWritePermOfBroker(final String brokerName) { int wipeTopicCnt = 0; Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator(); while (itTopic.hasNext()) { Entry<String, List<QueueData>> entry = itTopic.next(); List<QueueData> qdList = entry.getValue(); Iterator<QueueData> it = qdList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { int perm = qd.getPerm(); perm &= ~PermName.PERM_WRITE; qd.setPerm(perm); wipeTopicCnt++; } } } return wipeTopicCnt; }
Example 4
Source File: DefaultMQConsumerWithTraceTest.java From rocketmq with Apache License 2.0 | 6 votes |
public static TopicRouteData createTraceTopicRoute() { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); List<BrokerData> brokerDataList = new ArrayList<BrokerData>(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("broker-trace"); brokerData.setCluster("DefaultCluster"); HashMap<Long, String> brokerAddrs = new HashMap<Long, String>(); brokerAddrs.put(0L, "127.0.0.1:10912"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); List<QueueData> queueDataList = new ArrayList<QueueData>(); QueueData queueData = new QueueData(); queueData.setBrokerName("broker-trace"); queueData.setPerm(6); queueData.setReadQueueNums(1); queueData.setWriteQueueNums(1); queueData.setTopicSynFlag(1); queueDataList.add(queueData); topicRouteData.setQueueDatas(queueDataList); return topicRouteData; }
Example 5
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 6
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 7
Source File: RouteInfoManager.java From rocketmq-read with Apache License 2.0 | 6 votes |
/** * //去除该broker上所有topic的写权限 * @param brokerName brokerName * @return ; */ private int wipeWritePermOfBroker(final String brokerName) { int wipeTopicCnt = 0; Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator(); while (itTopic.hasNext()) { Entry<String, List<QueueData>> entry = itTopic.next(); List<QueueData> qdList = entry.getValue(); Iterator<QueueData> it = qdList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { int perm = qd.getPerm(); perm &= ~PermName.PERM_WRITE; qd.setPerm(perm); wipeTopicCnt++; } } } return wipeTopicCnt; }
Example 8
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 9
Source File: DefaultMQProducerTest.java From DDMQ 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 10
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 11
Source File: RouteInfoManager.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
private int wipeWritePermOfBroker(final String brokerName) { int wipeTopicCnt = 0; Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator(); while (itTopic.hasNext()) { Entry<String, List<QueueData>> entry = itTopic.next(); List<QueueData> qdList = entry.getValue(); Iterator<QueueData> it = qdList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { int perm = qd.getPerm(); perm &= ~PermName.PERM_WRITE; qd.setPerm(perm); wipeTopicCnt++; } } } return wipeTopicCnt; }
Example 12
Source File: DefaultMQProducerWithTraceTest.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 13
Source File: RouteInfoManager.java From DDMQ with Apache License 2.0 | 6 votes |
private int wipeWritePermOfBroker(final String brokerName) { int wipeTopicCnt = 0; Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator(); while (itTopic.hasNext()) { Entry<String, List<QueueData>> entry = itTopic.next(); List<QueueData> qdList = entry.getValue(); Iterator<QueueData> it = qdList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { int perm = qd.getPerm(); perm &= ~PermName.PERM_WRITE; qd.setPerm(perm); wipeTopicCnt++; } } } return wipeTopicCnt; }
Example 14
Source File: RouteInfoManager.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
private int wipeWritePermOfBroker(final String brokerName) { int wipeTopicCnt = 0; Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator(); while (itTopic.hasNext()) { Entry<String, List<QueueData>> entry = itTopic.next(); List<QueueData> qdList = entry.getValue(); Iterator<QueueData> it = qdList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { int perm = qd.getPerm(); perm &= ~PermName.PERM_WRITE; qd.setPerm(perm); wipeTopicCnt++; } } } return wipeTopicCnt; }
Example 15
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 16
Source File: RouteInfoManager.java From rocketmq-4.3.0 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()); // 查询topic的队列 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)) { // topic存在的队列和要保存的队列一样,不需要添加 addNewOne = false; } else { log.info("topic changed, {} OLD: {} NEW: {}", topicConfig.getTopicName(), qd, queueData); // 如果topic存在的队列和要保存的队列不一致,就删除存在的队列 it.remove(); } } } // 需要添加 if (addNewOne) { queueDataList.add(queueData); } } }
Example 17
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 18
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 19
Source File: TopicRouteDataTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testTopicRouteDataClone() 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); assertThat(topicRouteData.cloneTopicRouteData()).isEqualTo(topicRouteData); }
Example 20
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); }