org.apache.rocketmq.common.protocol.route.QueueData Java Examples
The following examples show how to use
org.apache.rocketmq.common.protocol.route.QueueData.
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-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 #2
Source File: DefaultMQAdminExtImplTest.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testResetOffset() throws Exception { TopicRouteData routeInfo = mqAdmin.examineTopicRouteInfo(topic); System.out.println(); for (BrokerData brokerData : routeInfo.getBrokerDatas()) { System.out.println(brokerData); } System.out.println(); for (QueueData data : routeInfo.getQueueDatas()) { MessageQueue mq = new MessageQueue(topic, data.getBrokerName(), 0); long offset = mqAdmin.searchOffset(mq, System.currentTimeMillis()); System.out.println(data + ", offset:" + offset); } System.out.println(); List<RollbackStats> r = mqAdmin.resetOffsetByTimestampOld(group, topic, System.currentTimeMillis(), true); for (RollbackStats rollbackStats : r) { System.out.println(rollbackStats); } }
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: RouteInfoManager.java From rocketmq with Apache License 2.0 | 6 votes |
private void removeTopicByBrokerName(final String brokerName) { Iterator<Entry<String, List<QueueData>>> itMap = this.topicQueueTable.entrySet().iterator(); while (itMap.hasNext()) { Entry<String, List<QueueData>> entry = itMap.next(); String topic = entry.getKey(); List<QueueData> queueDataList = entry.getValue(); Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { log.info("removeTopicByBrokerName, remove one broker's topic {} {}", topic, qd); it.remove(); } } if (queueDataList.isEmpty()) { log.info("removeTopicByBrokerName, remove the topic all queue {}", topic); itMap.remove(); } } }
Example #5
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 #6
Source File: RouteInfoManager.java From DDMQ with Apache License 2.0 | 6 votes |
private void removeTopicByBrokerName(final String brokerName) { Iterator<Entry<String, List<QueueData>>> itMap = this.topicQueueTable.entrySet().iterator(); while (itMap.hasNext()) { Entry<String, List<QueueData>> entry = itMap.next(); String topic = entry.getKey(); List<QueueData> queueDataList = entry.getValue(); Iterator<QueueData> it = queueDataList.iterator(); while (it.hasNext()) { QueueData qd = it.next(); if (qd.getBrokerName().equals(brokerName)) { log.info("removeTopicByBrokerName, remove one broker's topic {} {}", topic, qd); it.remove(); } } if (queueDataList.isEmpty()) { log.info("removeTopicByBrokerName, remove the topic all queue {}", topic); itMap.remove(); } } }
Example #7
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 #8
Source File: RouteInfoManager.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
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: 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 #10
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 #11
Source File: RouteInfoManager.java From DDMQ with Apache License 2.0 | 6 votes |
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 #12
Source File: RouteInfoManager.java From rocketmq with Apache License 2.0 | 6 votes |
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 #13
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 #14
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 #15
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 #16
Source File: RmqAdminServiceImpl.java From DDMQ with Apache License 2.0 | 6 votes |
@Override public Message queryLatestMessage(String nameServer, String topic) throws Exception { DefaultMQAdminExt defaultMQAdminExt = getMQAdminExt(nameServer); TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic); if (topicRouteData == null) { throw new MqException("[RMQ] topic<" + topic + "> route info is null"); } List<QueueData> queueDatas = topicRouteData.getQueueDatas(); Collections.shuffle(queueDatas); for (QueueData queueData : queueDatas) { for (int i = 0; i < queueData.getReadQueueNums(); i++) { long maxOffsets = defaultMQAdminExt.maxOffset(new MessageQueue(topic, queueData.getBrokerName(), i)); if (maxOffsets <= 0) { continue; } Message msg = queryMessageByOffset(nameServer, topic, queueData.getBrokerName(), i, maxOffsets - 1); if (msg != null) { return msg; } } } throw new MqException("[RMQ] fetch rmq latestmsg error, not exist"); }
Example #17
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 #18
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 #19
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 #20
Source File: RouteInfoManager.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
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 #21
Source File: DefaultMQProducerWithTraceTest.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 #22
Source File: RouteInfoManager.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
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 #23
Source File: DefaultMQAdminExtImplTest.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testResetOffset() throws Exception { TopicRouteData routeInfo = mqAdmin.examineTopicRouteInfo(topic); System.out.println(); for (BrokerData brokerData : routeInfo.getBrokerDatas()) { System.out.println(brokerData); } System.out.println(); for (QueueData data : routeInfo.getQueueDatas()) { MessageQueue mq = new MessageQueue(topic, data.getBrokerName(), 0); long offset = mqAdmin.searchOffset(mq, System.currentTimeMillis()); System.out.println(data + ", offset:" + offset); } System.out.println(); List<RollbackStats> r = mqAdmin.resetOffsetByTimestampOld(group, topic, System.currentTimeMillis(), true); for (RollbackStats rollbackStats : r) { System.out.println(rollbackStats); } }
Example #24
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 #25
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 #26
Source File: RouteInfoManager.java From DDMQ with Apache License 2.0 | 6 votes |
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 #27
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 #28
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 #29
Source File: RouteInfoManager.java From DDMQ with Apache License 2.0 | 6 votes |
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 #30
Source File: RouteInfoManager.java From rocketmq-read with Apache License 2.0 | 6 votes |
/** * 获取 getHasUnitSubTopicList * @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(); }