namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
/**
     *
     * @param brokerName   broker name
     * @param topicConfig  topic config
     */
@param brokerName   broker name
@param topicConfig  topic config
@param brokerName broker name @param topicConfig topic config
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()); 这个是topic与队列的关心
        if (null == queueDataList) { 新的topic
            queueDataList = new LinkedList<QueueData>();
            queueDataList.add(queueData);
            this.topicQueueTable.put(topicConfig.getTopicName(), queueDataList);
            log.info("new topic registered, {} {}", topicConfig.getTopicName(), queueData);
        } else {
            不为null 判断QueueData 是否 相等 不相等移除重新添加进队列
            相等 重写equals 和 hashCode方法
            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);
            }
        }
    }
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 ) ; } } }
@param brokerName   broker name
 @param topicConfig  topic config
@param brokerName broker name @param topicConfig topic config
//队列元数据 //broker name //写队列 //读队列 //权限 // topic 系统标志 // //这个是topic与队列的关心 //新的topic //不为null 判断QueueData 是否 相等 不相等移除重新添加进队列 //相等 重写equals 和 hashCode方法 //重新入队列