Search in sources :

Example 21 with TopicConfigSerializeWrapper

use of org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper in project rocketmq by apache.

the class BrokerController method registerBrokerAll.

public synchronized void registerBrokerAll(final boolean checkOrderConfig, boolean oneway) {
    TopicConfigSerializeWrapper topicConfigWrapper = this.getTopicConfigManager().buildTopicConfigSerializeWrapper();
    if (!PermName.isWriteable(this.getBrokerConfig().getBrokerPermission()) || !PermName.isReadable(this.getBrokerConfig().getBrokerPermission())) {
        ConcurrentHashMap<String, TopicConfig> topicConfigTable = new ConcurrentHashMap<String, TopicConfig>();
        for (TopicConfig topicConfig : topicConfigWrapper.getTopicConfigTable().values()) {
            TopicConfig tmp = new TopicConfig(topicConfig.getTopicName(), topicConfig.getReadQueueNums(), topicConfig.getWriteQueueNums(), this.brokerConfig.getBrokerPermission());
            topicConfigTable.put(topicConfig.getTopicName(), tmp);
        }
        topicConfigWrapper.setTopicConfigTable(topicConfigTable);
    }
    RegisterBrokerResult registerBrokerResult = this.brokerOuterAPI.registerBrokerAll(this.brokerConfig.getBrokerClusterName(), this.getBrokerAddr(), this.brokerConfig.getBrokerName(), this.brokerConfig.getBrokerId(), this.getHAServerAddr(), topicConfigWrapper, this.filterServerManager.buildNewFilterServerList(), oneway, this.brokerConfig.getRegisterBrokerTimeoutMills());
    if (registerBrokerResult != null) {
        if (this.updateMasterHAServerAddrPeriodically && registerBrokerResult.getHaServerAddr() != null) {
            this.messageStore.updateHaMasterAddress(registerBrokerResult.getHaServerAddr());
        }
        this.slaveSynchronize.setMasterAddr(registerBrokerResult.getMasterAddr());
        if (checkOrderConfig) {
            this.getTopicConfigManager().updateOrderTopicConfig(registerBrokerResult.getKvTable());
        }
    }
}
Also used : RegisterBrokerResult(org.apache.rocketmq.common.namesrv.RegisterBrokerResult) TopicConfigSerializeWrapper(org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TopicConfig(org.apache.rocketmq.common.TopicConfig)

Aggregations

TopicConfigSerializeWrapper (org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper)21 RegisterBrokerResult (org.apache.rocketmq.common.namesrv.RegisterBrokerResult)8 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)7 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 TopicConfig (org.apache.rocketmq.common.TopicConfig)6 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)5 Channel (io.netty.channel.Channel)4 IOException (java.io.IOException)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 RegisterBrokerRequestHeader (org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader)2 RegisterBrokerResponseHeader (org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerResponseHeader)2 UnRegisterBrokerRequestHeader (org.apache.rocketmq.common.protocol.header.namesrv.UnRegisterBrokerRequestHeader)2 Test (org.junit.Test)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MQClientException (org.apache.rocketmq.client.exception.MQClientException)1 RemotingClient (org.apache.rocketmq.remoting.RemotingClient)1 RemotingCommandException (org.apache.rocketmq.remoting.exception.RemotingCommandException)1 RemotingConnectException (org.apache.rocketmq.remoting.exception.RemotingConnectException)1 RemotingException (org.apache.rocketmq.remoting.exception.RemotingException)1 RemotingSendRequestException (org.apache.rocketmq.remoting.exception.RemotingSendRequestException)1