com.alibaba.rocketmq.common.protocol.body.TopicConfigSerializeWrapper Java Examples
The following examples show how to use
com.alibaba.rocketmq.common.protocol.body.TopicConfigSerializeWrapper.
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: SlaveSynchronize.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 6 votes |
private void syncTopicConfig() { String masterAddrBak = this.masterAddr; if (masterAddrBak != null) { try { TopicConfigSerializeWrapper topicWrapper = this.brokerController.getBrokerOuterAPI().getAllTopicConfig(masterAddrBak); if (!this.brokerController.getTopicConfigManager().getDataVersion() .equals(topicWrapper.getDataVersion())) { this.brokerController.getTopicConfigManager().getDataVersion() .assignNewOne(topicWrapper.getDataVersion()); this.brokerController.getTopicConfigManager().getTopicConfigTable().clear(); this.brokerController.getTopicConfigManager().getTopicConfigTable() .putAll(topicWrapper.getTopicConfigTable()); this.brokerController.getTopicConfigManager().persist(); log.info("update slave topic config from master, {}", masterAddrBak); } } catch (Exception e) { log.error("syncTopicConfig Exception, " + masterAddrBak, e); } } }
Example #2
Source File: SlaveSynchronize.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
/** * 同步topic配置信息 */ private void syncTopicConfig() { String masterAddrBak = this.masterAddr; if (masterAddrBak != null) { try { TopicConfigSerializeWrapper topicWrapper = this.brokerController.getBrokerOuterAPI().getAllTopicConfig(masterAddrBak); if (!this.brokerController.getTopicConfigManager().getDataVersion() .equals(topicWrapper.getDataVersion())) { this.brokerController.getTopicConfigManager().getDataVersion() .assignNewOne(topicWrapper.getDataVersion()); this.brokerController.getTopicConfigManager().getTopicConfigTable().clear(); this.brokerController.getTopicConfigManager().getTopicConfigTable() .putAll(topicWrapper.getTopicConfigTable()); this.brokerController.getTopicConfigManager().persist(); log.info("update slave topic config from master, {}", masterAddrBak); } } catch (Exception e) { log.error("syncTopicConfig Exception, " + masterAddrBak, e); } } }
Example #3
Source File: MQAdminExtImpl.java From rocket-console with Apache License 2.0 | 6 votes |
@Override public TopicConfig examineTopicConfig(String addr, String topic) { RemotingClient remotingClient = MQAdminInstance.threadLocalRemotingClient(); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null); RemotingCommand response = null; try { response = remotingClient.invokeSync(addr, request, 3000); } catch (Exception err) { throw Throwables.propagate(err); } switch (response.getCode()) { case ResponseCode.SUCCESS: { TopicConfigSerializeWrapper topicConfigSerializeWrapper = decode(response.getBody(), TopicConfigSerializeWrapper.class); return topicConfigSerializeWrapper.getTopicConfigTable().get(topic); } default: throw Throwables.propagate(new MQBrokerException(response.getCode(), response.getRemark())); } }
Example #4
Source File: SlaveSynchronize.java From rocketmq with Apache License 2.0 | 6 votes |
private void syncTopicConfig() { String masterAddrBak = this.masterAddr; if (masterAddrBak != null) { try { TopicConfigSerializeWrapper topicWrapper = this.brokerController.getBrokerOuterAPI().getAllTopicConfig(masterAddrBak); if (!this.brokerController.getTopicConfigManager().getDataVersion() .equals(topicWrapper.getDataVersion())) { this.brokerController.getTopicConfigManager().getDataVersion() .assignNewOne(topicWrapper.getDataVersion()); this.brokerController.getTopicConfigManager().getTopicConfigTable().clear(); this.brokerController.getTopicConfigManager().getTopicConfigTable() .putAll(topicWrapper.getTopicConfigTable()); this.brokerController.getTopicConfigManager().persist(); log.info("update slave topic config from master, {}", masterAddrBak); } } catch (Exception e) { log.error("syncTopicConfig Exception, " + masterAddrBak, e); } } }
Example #5
Source File: TopicConfigManager.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
private void printLoadDataWhenFirstBoot(final TopicConfigSerializeWrapper tcs) { Iterator<Entry<String, TopicConfig>> it = tcs.getTopicConfigTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, TopicConfig> next = it.next(); log.info("load exist local topic, {}", next.getValue().toString()); } }
Example #6
Source File: TopicConfigManager.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
@Override public void decode(String jsonString) { if (jsonString != null) { TopicConfigSerializeWrapper topicConfigSerializeWrapper = TopicConfigSerializeWrapper.fromJson(jsonString, TopicConfigSerializeWrapper.class); if (topicConfigSerializeWrapper != null) { this.topicConfigTable.putAll(topicConfigSerializeWrapper.getTopicConfigTable()); this.dataVersion.assignNewOne(topicConfigSerializeWrapper.getDataVersion()); this.printLoadDataWhenFirstBoot(topicConfigSerializeWrapper); } } }
Example #7
Source File: BrokerController.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
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>(topicConfigWrapper.getTopicConfigTable()); for (TopicConfig topicConfig : topicConfigTable.values()) { topicConfig.setPerm(this.getBrokerConfig().getBrokerPermission()); } 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); 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()); } } }
Example #8
Source File: TopicConfigManager.java From rocketmq with Apache License 2.0 | 5 votes |
private void printLoadDataWhenFirstBoot(final TopicConfigSerializeWrapper tcs) { Iterator<Entry<String, TopicConfig>> it = tcs.getTopicConfigTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, TopicConfig> next = it.next(); log.info("load exist local topic, {}", next.getValue().toString()); } }
Example #9
Source File: TopicConfigManager.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public void decode(String jsonString) { if (jsonString != null) { TopicConfigSerializeWrapper topicConfigSerializeWrapper = TopicConfigSerializeWrapper.fromJson(jsonString, TopicConfigSerializeWrapper.class); if (topicConfigSerializeWrapper != null) { this.topicConfigTable.putAll(topicConfigSerializeWrapper.getTopicConfigTable()); this.dataVersion.assignNewOne(topicConfigSerializeWrapper.getDataVersion()); this.printLoadDataWhenFirstBoot(topicConfigSerializeWrapper); } } }
Example #10
Source File: BrokerController.java From rocketmq with Apache License 2.0 | 5 votes |
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()); } } }
Example #11
Source File: TopicConfigManager.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
private void printLoadDataWhenFirstBoot(final TopicConfigSerializeWrapper tcs) { Iterator<Entry<String, TopicConfig>> it = tcs.getTopicConfigTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, TopicConfig> next = it.next(); log.info("load exist local topic, {}", next.getValue().toString()); } }
Example #12
Source File: TopicConfigManager.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
@Override //把/root/store/config/topics.json 中的字符串序列化存入topicConfigTable, public void decode(String jsonString) { //ConfigManager.configFilePath中执行 if (jsonString != null) { TopicConfigSerializeWrapper topicConfigSerializeWrapper = TopicConfigSerializeWrapper.fromJson(jsonString, TopicConfigSerializeWrapper.class); if (topicConfigSerializeWrapper != null) { this.topicConfigTable.putAll(topicConfigSerializeWrapper.getTopicConfigTable()); this.dataVersion.assignNewOne(topicConfigSerializeWrapper.getDataVersion()); this.printLoadDataWhenFirstBoot(topicConfigSerializeWrapper); } } }
Example #13
Source File: TopicConfigManager.java From rocketmq with Apache License 2.0 | 4 votes |
public TopicConfigSerializeWrapper buildTopicConfigSerializeWrapper() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); topicConfigSerializeWrapper.setTopicConfigTable(this.topicConfigTable); topicConfigSerializeWrapper.setDataVersion(this.dataVersion); return topicConfigSerializeWrapper; }
Example #14
Source File: MQAdminExtImpl.java From rocket-console with Apache License 2.0 | 4 votes |
@Override //todo use public TopicConfigSerializeWrapper getAllTopicGroup(String brokerAddr, long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException { return MQAdminInstance.threadLocalMQAdminExt().getAllTopicGroup(brokerAddr, timeoutMillis); }
Example #15
Source File: TopicConfigManager.java From rocketmq with Apache License 2.0 | 4 votes |
public String encode(final boolean prettyFormat) { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); topicConfigSerializeWrapper.setTopicConfigTable(this.topicConfigTable); topicConfigSerializeWrapper.setDataVersion(this.dataVersion); return topicConfigSerializeWrapper.toJson(prettyFormat); }
Example #16
Source File: TopicConfigManager.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 4 votes |
public String encode(final boolean prettyFormat) { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); topicConfigSerializeWrapper.setTopicConfigTable(this.topicConfigTable); topicConfigSerializeWrapper.setDataVersion(this.dataVersion); return topicConfigSerializeWrapper.toJson(prettyFormat); }
Example #17
Source File: TopicConfigManager.java From RocketMQ-Master-analyze with Apache License 2.0 | 4 votes |
public TopicConfigSerializeWrapper buildTopicConfigSerializeWrapper() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); topicConfigSerializeWrapper.setTopicConfigTable(this.topicConfigTable); topicConfigSerializeWrapper.setDataVersion(this.dataVersion); return topicConfigSerializeWrapper; }
Example #18
Source File: TopicConfigManager.java From RocketMQ-Master-analyze with Apache License 2.0 | 4 votes |
public String encode(final boolean prettyFormat) { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); topicConfigSerializeWrapper.setTopicConfigTable(this.topicConfigTable); topicConfigSerializeWrapper.setDataVersion(this.dataVersion); return topicConfigSerializeWrapper.toJson(prettyFormat); }
Example #19
Source File: TopicConfigManager.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 4 votes |
public TopicConfigSerializeWrapper buildTopicConfigSerializeWrapper() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); topicConfigSerializeWrapper.setTopicConfigTable(this.topicConfigTable); topicConfigSerializeWrapper.setDataVersion(this.dataVersion); return topicConfigSerializeWrapper; }
Example #20
Source File: BrokerController.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 4 votes |
public synchronized void registerBrokerAll(final boolean checkOrderConfig, boolean oneway) { TopicConfigSerializeWrapper topicConfigWrapper = this.getTopicConfigManager().buildTopicConfigSerializeWrapper(); /** * broker本身不可读或者不可写,则用 broker 本身的权限配置覆盖topic的读写权限。 * 或者简单说 ,broker的读写权限比topic的读写权限具有更高的优先级。 * */ if (!PermName.isWriteable(this.getBrokerConfig().getBrokerPermission()) || !PermName.isReadable(this.getBrokerConfig().getBrokerPermission())) { ConcurrentHashMap<String, TopicConfig> topicConfigTable = new ConcurrentHashMap<String, TopicConfig>(); //遍历该broker下面的所有topic信息 for (TopicConfig topicConfig : topicConfigWrapper.getTopicConfigTable().values()) { TopicConfig tmp = new TopicConfig(topicConfig.getTopicName(), topicConfig.getReadQueueNums(), topicConfig.getWriteQueueNums(), this.brokerConfig.getBrokerPermission()); //把所有的broker下面的topic信息的读写权限修改为何broker一致 topicConfigTable.put(topicConfig.getTopicName(), tmp); } topicConfigWrapper.setTopicConfigTable(topicConfigTable); //把修改权限后的topic信息topicConfigTable重新赋值给topicConfigWrapper } //把broker维护的topic配置推送给namserver, 同时把broker注册到Nameserver 或者BrokerController.start 每隔30s定时时间到,都会发送该报文,除了通知为,也是broker与nameserver的保活报文 RegisterBrokerResult registerBrokerResult = this.brokerOuterAPI.registerBrokerAll(// this.brokerConfig.getBrokerClusterName(), // this.getBrokerAddr(), // this.brokerConfig.getBrokerName(), // this.brokerConfig.getBrokerId(), // this.getHAServerAddr(), // topicConfigWrapper,// this.filterServerManager.buildNewFilterServerList(),// oneway); if (registerBrokerResult != null) { //registerBrokerResult.getHaServerAddr() != null 标识当前broker是slave,则需要把ha server的地址更新掉。 //所谓ha是 master broker用于主从数据同步的IP + 端口。 if (this.updateMasterHAServerAddrPeriodically && registerBrokerResult.getHaServerAddr() != null) { this.messageStore.updateHaMasterAddress(registerBrokerResult.getHaServerAddr()); } this.slaveSynchronize.setMasterAddr(registerBrokerResult.getMasterAddr()); if (checkOrderConfig) { this.getTopicConfigManager().updateOrderTopicConfig(registerBrokerResult.getKvTable()); } } }