org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper Java Examples
The following examples show how to use
org.apache.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: MQClientAPIImpl.java From rocketmq-read with Apache License 2.0 | 6 votes |
public TopicConfigSerializeWrapper getAllTopicConfig(final String addr, long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null); String acturallyAddr = getActurallyBrokerAddr(addr); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), acturallyAddr), request, timeoutMillis); assert response != null; switch (response.getCode()) { case ResponseCode.SUCCESS: { return TopicConfigSerializeWrapper.decode(response.getBody(), TopicConfigSerializeWrapper.class); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #2
Source File: RegisterBrokerBodyTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void test_encode_decode() throws IOException { RegisterBrokerBody registerBrokerBody = new RegisterBrokerBody(); TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); registerBrokerBody.setTopicConfigSerializeWrapper(topicConfigSerializeWrapper); ConcurrentMap<String, TopicConfig> topicConfigTable = new ConcurrentHashMap<String, TopicConfig>(); for (int i = 0; i < 10000; i++) { topicConfigTable.put(String.valueOf(i), new TopicConfig(String.valueOf(i))); } topicConfigSerializeWrapper.setTopicConfigTable(topicConfigTable); byte[] compareEncode = registerBrokerBody.encode(true); byte[] encode2 = registerBrokerBody.encode(false); System.out.println(compareEncode.length); System.out.println(encode2.length); RegisterBrokerBody decodeRegisterBrokerBody = RegisterBrokerBody.decode(compareEncode, true); assertEquals(registerBrokerBody.getTopicConfigSerializeWrapper().getTopicConfigTable().size(), decodeRegisterBrokerBody.getTopicConfigSerializeWrapper().getTopicConfigTable().size()); }
Example #3
Source File: RouteInfoManagerTest.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testRegisterBroker() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>(); TopicConfig topicConfig = new TopicConfig(); topicConfig.setWriteQueueNums(8); topicConfig.setTopicName("unit-test"); topicConfig.setPerm(6); topicConfig.setReadQueueNums(8); topicConfig.setOrder(false); topicConfigConcurrentHashMap.put("unit-test", topicConfig); topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap); Channel channel = mock(Channel.class); RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", "127.0.0.1:10911", "default-broker", 1234, "127.0.0.1:1001", 1000L, 1000L, topicConfigSerializeWrapper, new ArrayList<String>(), channel); assertThat(registerBrokerResult).isNotNull(); }
Example #4
Source File: RouteInfoManagerTest.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testRegisterBroker() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>(); TopicConfig topicConfig = new TopicConfig(); topicConfig.setWriteQueueNums(8); topicConfig.setTopicName("unit-test"); topicConfig.setPerm(6); topicConfig.setReadQueueNums(8); topicConfig.setOrder(false); topicConfigConcurrentHashMap.put("unit-test", topicConfig); topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap); Channel channel = mock(Channel.class); RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", "127.0.0.1:10911", "default-broker", 1234, "127.0.0.1:1001", topicConfigSerializeWrapper, new ArrayList<String>(), channel); assertThat(registerBrokerResult).isNotNull(); }
Example #5
Source File: SlaveSynchronize.java From rocketmq with Apache License 2.0 | 6 votes |
private void syncTopicConfig() { String masterAddrBak = this.masterAddr; if (masterAddrBak != null && !masterAddrBak.equals(brokerController.getBrokerAddr())) { 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 #6
Source File: MQAdminExtImpl.java From rocketmq-exporter with Apache License 2.0 | 6 votes |
@Override public TopicConfig examineTopicConfig(String addr, String topic) { 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 #7
Source File: DefaultRequestProcessorTest.java From DDMQ with Apache License 2.0 | 6 votes |
private void registerRouteInfoManager(String brokerAddr, String brokerName, long brokerId, String topicName) { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>(); TopicConfig topicConfig = new TopicConfig(); topicConfig.setWriteQueueNums(8); topicConfig.setTopicName(topicName); topicConfig.setPerm(6); topicConfig.setReadQueueNums(8); topicConfig.setOrder(false); topicConfigConcurrentHashMap.put(topicName, topicConfig); topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap); Channel channel = mock(Channel.class); RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", brokerAddr, brokerName, brokerId, "127.0.0.1:1001", 0l,0l,topicConfigSerializeWrapper, new ArrayList<String>(), channel); }
Example #8
Source File: BrokerOuterAPI.java From rocketmq with Apache License 2.0 | 6 votes |
public TopicConfigSerializeWrapper getAllTopicConfig( final String addr) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(true, addr), request, 3000); assert response != null; switch (response.getCode()) { case ResponseCode.SUCCESS: { return TopicConfigSerializeWrapper.decode(response.getBody(), TopicConfigSerializeWrapper.class); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #9
Source File: DefaultRequestProcessorTest.java From DDMQ with Apache License 2.0 | 6 votes |
private void registerRouteInfoManager(String brokerAddr, String brokerName, long brokerId, String topicName) { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>(); TopicConfig topicConfig = new TopicConfig(); topicConfig.setWriteQueueNums(8); topicConfig.setTopicName(topicName); topicConfig.setPerm(6); topicConfig.setReadQueueNums(8); topicConfig.setOrder(false); topicConfigConcurrentHashMap.put(topicName, topicConfig); topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap); Channel channel = mock(Channel.class); RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", brokerAddr, brokerName, brokerId, "127.0.0.1:1001", 0l,0l,topicConfigSerializeWrapper, new ArrayList<String>(), channel); }
Example #10
Source File: SlaveSynchronize.java From DDMQ with Apache License 2.0 | 6 votes |
private void syncTopicConfig() { String masterAddrBak = this.masterAddr; if (masterAddrBak != null) { try { long start = System.currentTimeMillis(); TopicConfigSerializeWrapper topicWrapper = this.brokerController.getBrokerOuterAPI().getAllTopicConfig(masterAddrBak); if (!this.brokerController.getTopicConfigManager().getDataVersion() .equals(topicWrapper.getDataVersion())) { long startUpdate = System.currentTimeMillis(); 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, , master={}, getData={}ms,total={}ms", masterAddrBak, startUpdate - start, System.currentTimeMillis() - start); } } catch (Exception e) { log.error("SyncTopicConfig Exception, {}", masterAddrBak, e); } } }
Example #11
Source File: DefaultRequestProcessorTest.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
private void registerRouteInfoManager() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>(); TopicConfig topicConfig = new TopicConfig(); topicConfig.setWriteQueueNums(8); topicConfig.setTopicName("unit-test"); topicConfig.setPerm(6); topicConfig.setReadQueueNums(8); topicConfig.setOrder(false); topicConfigConcurrentHashMap.put("unit-test", topicConfig); topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap); Channel channel = mock(Channel.class); RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", "127.0.0.1:10911", "default-broker", 1234, "127.0.0.1:1001", topicConfigSerializeWrapper, new ArrayList<String>(), channel); }
Example #12
Source File: RouteInfoManagerTest.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testRegisterBroker() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>(); TopicConfig topicConfig = new TopicConfig(); topicConfig.setWriteQueueNums(8); topicConfig.setTopicName("unit-test"); topicConfig.setPerm(6); topicConfig.setReadQueueNums(8); topicConfig.setOrder(false); topicConfigConcurrentHashMap.put("unit-test", topicConfig); topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap); Channel channel = mock(Channel.class); RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", "127.0.0.1:10911", "default-broker", 1234, "127.0.0.1:1001", topicConfigSerializeWrapper, new ArrayList<String>(), channel); assertThat(registerBrokerResult).isNotNull(); }
Example #13
Source File: BrokerOuterAPI.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
public TopicConfigSerializeWrapper getAllTopicConfig(final String addr) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(true, addr), request, 3000); assert response != null; switch (response.getCode()) { case ResponseCode.SUCCESS: { return TopicConfigSerializeWrapper.decode(response.getBody(), TopicConfigSerializeWrapper.class); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #14
Source File: DefaultRequestProcessorTest.java From rocketmq with Apache License 2.0 | 6 votes |
private void registerRouteInfoManager() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>(); TopicConfig topicConfig = new TopicConfig(); topicConfig.setWriteQueueNums(8); topicConfig.setTopicName("unit-test"); topicConfig.setPerm(6); topicConfig.setReadQueueNums(8); topicConfig.setOrder(false); topicConfigConcurrentHashMap.put("unit-test", topicConfig); topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap); Channel channel = mock(Channel.class); RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", "127.0.0.1:10911", "default-broker", 1234, "127.0.0.1:1001", topicConfigSerializeWrapper, new ArrayList<String>(), channel); }
Example #15
Source File: MQClientAPIImpl.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
public TopicConfigSerializeWrapper getAllTopicConfig(final String addr, long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); assert response != null; switch (response.getCode()) { case ResponseCode.SUCCESS: { return TopicConfigSerializeWrapper.decode(response.getBody(), TopicConfigSerializeWrapper.class); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #16
Source File: MQClientAPIImpl.java From DDMQ with Apache License 2.0 | 6 votes |
public TopicConfigSerializeWrapper getAllTopicConfig(final String addr, long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); assert response != null; switch (response.getCode()) { case ResponseCode.SUCCESS: { return TopicConfigSerializeWrapper.decode(response.getBody(), TopicConfigSerializeWrapper.class); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #17
Source File: BrokerOuterAPI.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
public TopicConfigSerializeWrapper getAllTopicConfig( final String addr) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null); // 同步请求=》 RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(true, addr), request, 3000); assert response != null; switch (response.getCode()) { case ResponseCode.SUCCESS: { // 消息json解码 return TopicConfigSerializeWrapper.decode(response.getBody(), TopicConfigSerializeWrapper.class); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
Example #18
Source File: SlaveSynchronize.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
private void syncTopicConfig() { String masterAddrBak = this.masterAddr; if (masterAddrBak != null) { try { // 从master获取所有的topic配置=》 TopicConfigSerializeWrapper topicWrapper = this.brokerController.getBrokerOuterAPI().getAllTopicConfig(masterAddrBak); if (!this.brokerController.getTopicConfigManager().getDataVersion() .equals(topicWrapper.getDataVersion())) { this.brokerController.getTopicConfigManager().getDataVersion() .assignNewOne(topicWrapper.getDataVersion()); // 更新topic配置 this.brokerController.getTopicConfigManager().getTopicConfigTable().clear(); this.brokerController.getTopicConfigManager().getTopicConfigTable() .putAll(topicWrapper.getTopicConfigTable()); // topic配置持久化=》 this.brokerController.getTopicConfigManager().persist(); log.info("Update slave topic config from master, {}", masterAddrBak); } } catch (Exception e) { log.error("SyncTopicConfig Exception, {}", masterAddrBak, e); } } }
Example #19
Source File: RegisterBrokerBodyTest.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void test_encode_decode() throws IOException { RegisterBrokerBody registerBrokerBody = new RegisterBrokerBody(); TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); registerBrokerBody.setTopicConfigSerializeWrapper(topicConfigSerializeWrapper); ConcurrentMap<String, TopicConfig> topicConfigTable = new ConcurrentHashMap<String, TopicConfig>(); for (int i = 0; i < 10000; i++) { topicConfigTable.put(String.valueOf(i), new TopicConfig(String.valueOf(i))); } topicConfigSerializeWrapper.setTopicConfigTable(topicConfigTable); byte[] compareEncode = registerBrokerBody.encode(true); byte[] encode2 = registerBrokerBody.encode(false); System.out.println(compareEncode.length); System.out.println(encode2.length); RegisterBrokerBody decodeRegisterBrokerBody = RegisterBrokerBody.decode(compareEncode, true); assertEquals(registerBrokerBody.getTopicConfigSerializeWrapper().getTopicConfigTable().size(), decodeRegisterBrokerBody.getTopicConfigSerializeWrapper().getTopicConfigTable().size()); }
Example #20
Source File: SlaveSynchronize.java From DDMQ with Apache License 2.0 | 6 votes |
private void syncTopicConfig() { String masterAddrBak = this.masterAddr; if (masterAddrBak != null) { try { long start = System.currentTimeMillis(); TopicConfigSerializeWrapper topicWrapper = this.brokerController.getBrokerOuterAPI().getAllTopicConfig(masterAddrBak); if (!this.brokerController.getTopicConfigManager().getDataVersion() .equals(topicWrapper.getDataVersion())) { long startUpdate = System.currentTimeMillis(); 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, , master={}, getData={}ms,total={}ms", masterAddrBak, startUpdate - start, System.currentTimeMillis() - start); } } catch (Exception e) { log.error("SyncTopicConfig Exception, {}", masterAddrBak, e); } } }
Example #21
Source File: DefaultRequestProcessorTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
private void registerRouteInfoManager() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>(); TopicConfig topicConfig = new TopicConfig(); topicConfig.setWriteQueueNums(8); topicConfig.setTopicName("unit-test"); topicConfig.setPerm(6); topicConfig.setReadQueueNums(8); topicConfig.setOrder(false); topicConfigConcurrentHashMap.put("unit-test", topicConfig); topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap); Channel channel = mock(Channel.class); RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", "127.0.0.1:10911", "127.0.0.1:10911","default-broker", 1234, "127.0.0.1:1001", topicConfigSerializeWrapper, new ArrayList<String>(), channel); }
Example #22
Source File: RouteInfoManagerTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
@Test public void testRegisterBroker() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>(); TopicConfig topicConfig = new TopicConfig(); topicConfig.setWriteQueueNums(8); topicConfig.setTopicName("unit-test"); topicConfig.setPerm(6); topicConfig.setReadQueueNums(8); topicConfig.setOrder(false); topicConfigConcurrentHashMap.put("unit-test", topicConfig); topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap); Channel channel = mock(Channel.class); RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", "127.0.0.1:10911", "default-broker", 1234, "127.0.0.1:1001", topicConfigSerializeWrapper, new ArrayList<String>(), channel); assertThat(registerBrokerResult).isNotNull(); }
Example #23
Source File: RouteInfoManagerTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void testRegisterBroker() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>(); TopicConfig topicConfig = new TopicConfig(); topicConfig.setWriteQueueNums(8); topicConfig.setTopicName("unit-test"); topicConfig.setPerm(6); topicConfig.setReadQueueNums(8); topicConfig.setOrder(false); topicConfigConcurrentHashMap.put("unit-test", topicConfig); topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap); Channel channel = mock(Channel.class); RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", "127.0.0.1:10911", "127.0.0.1:10911","default-broker", 1234, "127.0.0.1:1001", topicConfigSerializeWrapper, new ArrayList<String>(), channel); assertThat(registerBrokerResult).isNotNull(); }
Example #24
Source File: BrokerOuterAPITest.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void test_register_normal() throws Exception { init(); brokerOuterAPI.start(); final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class); final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader) response.readCustomHeader(); response.setCode(ResponseCode.SUCCESS); response.setRemark(null); TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); when(nettyRemotingClient.getNameServerAddressList()).thenReturn(Lists.asList(nameserver1, nameserver2, new String[] {nameserver3})); when(nettyRemotingClient.invokeSync(anyString(), any(RemotingCommand.class), anyLong())).thenReturn(response); List<RegisterBrokerResult> registerBrokerResultList = brokerOuterAPI.registerBrokerAll(clusterName, brokerAddr,brokerAddr, brokerName, brokerId, "hasServerAddr", topicConfigSerializeWrapper, Lists.<String>newArrayList(), false, timeOut, true); assertTrue(registerBrokerResultList.size() > 0); }
Example #25
Source File: RouteInfoManagerTest.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Test public void testRegisterBroker() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>(); TopicConfig topicConfig = new TopicConfig(); topicConfig.setWriteQueueNums(8); topicConfig.setTopicName("unit-test"); topicConfig.setPerm(6); topicConfig.setReadQueueNums(8); topicConfig.setOrder(false); topicConfigConcurrentHashMap.put("unit-test", topicConfig); topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap); Channel channel = mock(Channel.class); RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", "127.0.0.1:10911", "default-broker", 1234, "127.0.0.1:1001", topicConfigSerializeWrapper, new ArrayList<String>(), channel); assertThat(registerBrokerResult).isNotNull(); }
Example #26
Source File: DefaultRequestProcessorTest.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
private void registerRouteInfoManager() { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>(); TopicConfig topicConfig = new TopicConfig(); topicConfig.setWriteQueueNums(8); topicConfig.setTopicName("unit-test"); topicConfig.setPerm(6); topicConfig.setReadQueueNums(8); topicConfig.setOrder(false); topicConfigConcurrentHashMap.put("unit-test", topicConfig); topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap); Channel channel = mock(Channel.class); RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", "127.0.0.1:10911", "default-broker", 1234, "127.0.0.1:1001", topicConfigSerializeWrapper, new ArrayList<String>(), channel); }
Example #27
Source File: RegisterBrokerBodyTest.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Test public void test_encode_decode() throws IOException { RegisterBrokerBody registerBrokerBody = new RegisterBrokerBody(); TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); registerBrokerBody.setTopicConfigSerializeWrapper(topicConfigSerializeWrapper); ConcurrentMap<String, TopicConfig> topicConfigTable = new ConcurrentHashMap<String, TopicConfig>(); for (int i = 0; i < 10000; i++) { topicConfigTable.put(String.valueOf(i), new TopicConfig(String.valueOf(i))); } topicConfigSerializeWrapper.setTopicConfigTable(topicConfigTable); byte[] compareEncode = registerBrokerBody.encode(true); byte[] encode2 = registerBrokerBody.encode(false); System.out.println(compareEncode.length); System.out.println(encode2.length); RegisterBrokerBody decodeRegisterBrokerBody = RegisterBrokerBody.decode(compareEncode, true); assertEquals(registerBrokerBody.getTopicConfigSerializeWrapper().getTopicConfigTable().size(), decodeRegisterBrokerBody.getTopicConfigSerializeWrapper().getTopicConfigTable().size()); }
Example #28
Source File: BrokerOuterAPITest.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void test_register_normal() throws Exception { init(); brokerOuterAPI.start(); final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class); final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader) response.readCustomHeader(); response.setCode(ResponseCode.SUCCESS); response.setRemark(null); TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); when(nettyRemotingClient.getNameServerAddressList()).thenReturn(Lists.asList(nameserver1, nameserver2, new String[] {nameserver3})); when(nettyRemotingClient.invokeSync(anyString(), any(RemotingCommand.class), anyLong())).thenReturn(response); List<RegisterBrokerResult> registerBrokerResultList = brokerOuterAPI.registerBrokerAll(clusterName, brokerAddr, brokerName, brokerId, "hasServerAddr", topicConfigSerializeWrapper, Lists.<String>newArrayList(), false, timeOut, true); assertTrue(registerBrokerResultList.size() > 0); }
Example #29
Source File: TopicConfigManager.java From rocketmq-read 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 #30
Source File: TopicConfigManager.java From rocketmq-all-4.1.0-incubating 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); } } }