Java Code Examples for com.alibaba.rocketmq.common.protocol.route.QueueData#setPerm()

The following examples show how to use com.alibaba.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 reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
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: RouteInfoManager.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
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 3
Source File: RouteInfoManager.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
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: RouteInfoManager.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
/**
 *
 *
 * 注意topicQueueTable<String,Liat<QueueData>>这个比较难理解的数据结构 。
 * key是topic, value是topic下面的所有队列配置信息。
 *
 * 这个List<QueueData> 可以这么理解,  其中的每一个QueueData是topic在某一个brokername下面的队列配置元数据。
 * QueueData List 就是topic在所有brokername下面的配置信息。
 *
 *
 * @param brokerName
 * @param 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());

    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)) {    //如果是同一个brokername的broker上报的queuedata 。
                if (qd.equals(queueData)) { //如果队列信息完全一致,则不用新增。
                    addNewOne = false;
                }
                else { //如果队列信息不一致, 则把老的queuedata移除掉
                    log.info("topic changed, {} OLD: {} NEW: {}", topicConfig.getTopicName(), qd,
                        queueData);
                    it.remove();
                }
            }
        }

        if (addNewOne) { //326行把brokername中老的queuedata移除掉以后 ,把当前这个queuedata加上。 这个操作保证了topic在一个brokername下只会有一个queuedata.
            queueDataList.add(queueData);
        }
    }
}
 
Example 5
Source File: RouteInfoManager.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
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 6
Source File: RouteInfoManager.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
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);
        }
    }
}