org.apache.rocketmq.common.namesrv.NamesrvConfig Java Examples
The following examples show how to use
org.apache.rocketmq.common.namesrv.NamesrvConfig.
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: IntegrationTestBase.java From rocketmq with Apache License 2.0 | 6 votes |
public static NamesrvController createAndStartNamesrv() { String baseDir = createBaseDir(); NamesrvConfig namesrvConfig = new NamesrvConfig(); NettyServerConfig nameServerNettyServerConfig = new NettyServerConfig(); namesrvConfig.setKvConfigPath(baseDir + SEP + "namesrv" + SEP + "kvConfig.json"); namesrvConfig.setConfigStorePath(baseDir + SEP + "namesrv" + SEP + "namesrv.properties"); nameServerNettyServerConfig.setListenPort(9000 + random.nextInt(1000)); NamesrvController namesrvController = new NamesrvController(namesrvConfig, nameServerNettyServerConfig); try { Assert.assertTrue(namesrvController.initialize()); logger.info("Name Server Start:{}", nameServerNettyServerConfig.getListenPort()); namesrvController.start(); } catch (Exception e) { logger.info("Name Server start failed"); System.exit(1); } NAMESRV_CONTROLLERS.add(namesrvController); return namesrvController; }
Example #2
Source File: IntegrationTestBase.java From rocketmq with Apache License 2.0 | 6 votes |
public static NamesrvController createAndStartNamesrv() { String baseDir = createBaseDir(); NamesrvConfig namesrvConfig = new NamesrvConfig(); NettyServerConfig nameServerNettyServerConfig = new NettyServerConfig(); namesrvConfig.setKvConfigPath(baseDir + SEP + "namesrv" + SEP + "kvConfig.json"); namesrvConfig.setConfigStorePath(baseDir + SEP + "namesrv" + SEP + "namesrv.properties"); nameServerNettyServerConfig.setListenPort(nextPort()); NamesrvController namesrvController = new NamesrvController(namesrvConfig, nameServerNettyServerConfig); try { Assert.assertTrue(namesrvController.initialize()); logger.info("Name Server Start:{}", nameServerNettyServerConfig.getListenPort()); namesrvController.start(); } catch (Exception e) { logger.info("Name Server start failed", e); System.exit(1); } NAMESRV_CONTROLLERS.add(namesrvController); return namesrvController; }
Example #3
Source File: DefaultRequestProcessorTest.java From rocketmq with Apache License 2.0 | 6 votes |
@Before public void init() throws Exception { namesrvConfig = new NamesrvConfig(); nettyServerConfig = new NettyServerConfig(); routeInfoManager = new RouteInfoManager(); namesrvController = new NamesrvController(namesrvConfig, nettyServerConfig); Field field = NamesrvController.class.getDeclaredField("routeInfoManager"); field.setAccessible(true); field.set(namesrvController, routeInfoManager); defaultRequestProcessor = new DefaultRequestProcessor(namesrvController); registerRouteInfoManager(); logger = mock(InternalLogger.class); setFinalStatic(DefaultRequestProcessor.class.getDeclaredField("log"), logger); }
Example #4
Source File: IntegrationTestBase.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
public static NamesrvController createAndStartNamesrv() { String baseDir = createBaseDir(); NamesrvConfig namesrvConfig = new NamesrvConfig(); NettyServerConfig nameServerNettyServerConfig = new NettyServerConfig(); namesrvConfig.setKvConfigPath(baseDir + SEP + "namesrv" + SEP + "kvConfig.json"); namesrvConfig.setConfigStorePath(baseDir + SEP + "namesrv" + SEP + "namesrv.properties"); nameServerNettyServerConfig.setListenPort(9000 + random.nextInt(1000)); NamesrvController namesrvController = new NamesrvController(namesrvConfig, nameServerNettyServerConfig); try { Assert.assertTrue(namesrvController.initialize()); logger.info("Name Server Start:{}", nameServerNettyServerConfig.getListenPort()); namesrvController.start(); } catch (Exception e) { logger.info("Name Server start failed"); System.exit(1); } NAMESRV_CONTROLLERS.add(namesrvController); return namesrvController; }
Example #5
Source File: DefaultRequestProcessorTest.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
@Before public void init() throws Exception { namesrvConfig = new NamesrvConfig(); nettyServerConfig = new NettyServerConfig(); routeInfoManager = new RouteInfoManager(); namesrvController = new NamesrvController(namesrvConfig, nettyServerConfig); Field field = NamesrvController.class.getDeclaredField("routeInfoManager"); field.setAccessible(true); field.set(namesrvController, routeInfoManager); defaultRequestProcessor = new DefaultRequestProcessor(namesrvController); registerRouteInfoManager(); logger = mock(Logger.class); when(logger.isInfoEnabled()).thenReturn(false); setFinalStatic(DefaultRequestProcessor.class.getDeclaredField("log"), logger); }
Example #6
Source File: IntegrationTestBase.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
public static NamesrvController createAndStartNamesrv() { String baseDir = createBaseDir(); NamesrvConfig namesrvConfig = new NamesrvConfig(); NettyServerConfig nameServerNettyServerConfig = new NettyServerConfig(); namesrvConfig.setKvConfigPath(baseDir + SEP + "namesrv" + SEP + "kvConfig.json"); namesrvConfig.setConfigStorePath(baseDir + SEP + "namesrv" + SEP + "namesrv.properties"); nameServerNettyServerConfig.setListenPort(9000 + random.nextInt(1000)); NamesrvController namesrvController = new NamesrvController(namesrvConfig, nameServerNettyServerConfig); try { Assert.assertTrue(namesrvController.initialize()); logger.info("Name Server Start:{}", nameServerNettyServerConfig.getListenPort()); namesrvController.start(); } catch (Exception e) { logger.info("Name Server start failed"); System.exit(1); } NAMESRV_CONTROLLERS.add(namesrvController); return namesrvController; }
Example #7
Source File: DefaultRequestProcessorTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
@Before public void init() throws Exception { namesrvConfig = new NamesrvConfig(); nettyServerConfig = new NettyServerConfig(); routeInfoManager = new RouteInfoManager(); namesrvController = new NamesrvController(namesrvConfig, nettyServerConfig); Field field = NamesrvController.class.getDeclaredField("routeInfoManager"); field.setAccessible(true); field.set(namesrvController, routeInfoManager); defaultRequestProcessor = new DefaultRequestProcessor(namesrvController); registerRouteInfoManager(); logger = mock(Logger.class); when(logger.isInfoEnabled()).thenReturn(false); setFinalStatic(DefaultRequestProcessor.class.getDeclaredField("log"), logger); }
Example #8
Source File: IntegrationTestBase.java From DDMQ with Apache License 2.0 | 6 votes |
public static NamesrvController createAndStartNamesrv() { String baseDir = createBaseDir(); NamesrvConfig namesrvConfig = new NamesrvConfig(); NettyServerConfig nameServerNettyServerConfig = new NettyServerConfig(); namesrvConfig.setKvConfigPath(baseDir + SEP + "namesrv" + SEP + "kvConfig.json"); namesrvConfig.setConfigStorePath(baseDir + SEP + "namesrv" + SEP + "namesrv.properties"); nameServerNettyServerConfig.setListenPort(9000 + random.nextInt(1000)); NamesrvController namesrvController = new NamesrvController(namesrvConfig, nameServerNettyServerConfig); try { Assert.assertTrue(namesrvController.initialize()); logger.info("Name Server Start:{}", nameServerNettyServerConfig.getListenPort()); namesrvController.start(); } catch (Exception e) { logger.info("Name Server start failed"); System.exit(1); } NAMESRV_CONTROLLERS.add(namesrvController); return namesrvController; }
Example #9
Source File: DefaultRequestProcessorTest.java From DDMQ with Apache License 2.0 | 6 votes |
@Before public void init() throws Exception { namesrvConfig = new NamesrvConfig(); nettyServerConfig = new NettyServerConfig(); routeInfoManager = new RouteInfoManager(); namesrvController = new NamesrvController(namesrvConfig, nettyServerConfig); Field field = NamesrvController.class.getDeclaredField("routeInfoManager"); field.setAccessible(true); field.set(namesrvController, routeInfoManager); defaultRequestProcessor = new DefaultRequestProcessor(namesrvController); registerRouteInfoManager(); logger = mock(Logger.class); when(logger.isInfoEnabled()).thenReturn(false); setFinalStatic(DefaultRequestProcessor.class.getDeclaredField("log"), logger); }
Example #10
Source File: DefaultRequestProcessorTest.java From rocketmq with Apache License 2.0 | 6 votes |
@Before public void init() throws Exception { namesrvConfig = new NamesrvConfig(); nettyServerConfig = new NettyServerConfig(); routeInfoManager = new RouteInfoManager(); namesrvController = new NamesrvController(namesrvConfig, nettyServerConfig); Field field = NamesrvController.class.getDeclaredField("routeInfoManager"); field.setAccessible(true); field.set(namesrvController, routeInfoManager); defaultRequestProcessor = new DefaultRequestProcessor(namesrvController); registerRouteInfoManager(); logger = mock(Logger.class); when(logger.isInfoEnabled()).thenReturn(false); setFinalStatic(DefaultRequestProcessor.class.getDeclaredField("log"), logger); }
Example #11
Source File: IntegrationTestBase.java From rocketmq-read with Apache License 2.0 | 6 votes |
public static NamesrvController createAndStartNamesrv() { String baseDir = createBaseDir(); NamesrvConfig namesrvConfig = new NamesrvConfig(); NettyServerConfig nameServerNettyServerConfig = new NettyServerConfig(); namesrvConfig.setKvConfigPath(baseDir + SEP + "namesrv" + SEP + "kvConfig.json"); namesrvConfig.setConfigStorePath(baseDir + SEP + "namesrv" + SEP + "namesrv.properties"); nameServerNettyServerConfig.setListenPort(9000 + random.nextInt(1000)); NamesrvController namesrvController = new NamesrvController(namesrvConfig, nameServerNettyServerConfig); try { Assert.assertTrue(namesrvController.initialize()); logger.info("Name Server Start:{}", nameServerNettyServerConfig.getListenPort()); namesrvController.start(); } catch (Exception e) { logger.info("Name Server start failed"); System.exit(1); } NAMESRV_CONTROLLERS.add(namesrvController); return namesrvController; }
Example #12
Source File: DefaultRequestProcessorTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Before public void init() throws Exception { namesrvConfig = new NamesrvConfig(); nettyServerConfig = new NettyServerConfig(); routeInfoManager = new RouteInfoManager(); namesrvController = new NamesrvController(namesrvConfig, nettyServerConfig); Field field = NamesrvController.class.getDeclaredField("routeInfoManager"); field.setAccessible(true); field.set(namesrvController, routeInfoManager); defaultRequestProcessor = new DefaultRequestProcessor(namesrvController); registerRouteInfoManager(); logger = mock(InternalLogger.class); setFinalStatic(DefaultRequestProcessor.class.getDeclaredField("log"), logger); }
Example #13
Source File: NamesrvController.java From rocketmq-read with Apache License 2.0 | 6 votes |
/** * 初始化NameServerController * @param namesrvConfig nameserverconfig * @param nettyServerConfig nettyServer */ public NamesrvController(NamesrvConfig namesrvConfig, NettyServerConfig nettyServerConfig) { //文件配置集 this.namesrvConfig = namesrvConfig; this.nettyServerConfig = nettyServerConfig; // kv config管理器 this.kvConfigManager = new KVConfigManager(this); //路由管理器 this.routeInfoManager = new RouteInfoManager(); //broker 的心跳长连接保持器,是一个ChannelEventListener this.brokerHousekeepingService = new BrokerHousekeepingService(this); //配置集 this.configuration = new Configuration( log, this.namesrvConfig, this.nettyServerConfig ); //设置配置集 this.configuration.setStorePathFromConfig(this.namesrvConfig, "configStorePath"); }
Example #14
Source File: DefaultRequestProcessorTest.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Before public void init() throws Exception { namesrvConfig = new NamesrvConfig(); nettyServerConfig = new NettyServerConfig(); routeInfoManager = new RouteInfoManager(); namesrvController = new NamesrvController(namesrvConfig, nettyServerConfig); Field field = NamesrvController.class.getDeclaredField("routeInfoManager"); field.setAccessible(true); field.set(namesrvController, routeInfoManager); defaultRequestProcessor = new DefaultRequestProcessor(namesrvController); registerRouteInfoManager(); logger = mock(InternalLogger.class); setFinalStatic(DefaultRequestProcessor.class.getDeclaredField("log"), logger); }
Example #15
Source File: IntegrationTestBase.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
public static NamesrvController createAndStartNamesrv() { String baseDir = createBaseDir(); NamesrvConfig namesrvConfig = new NamesrvConfig(); NettyServerConfig nameServerNettyServerConfig = new NettyServerConfig(); namesrvConfig.setKvConfigPath(baseDir + SEP + "namesrv" + SEP + "kvConfig.json"); namesrvConfig.setConfigStorePath(baseDir + SEP + "namesrv" + SEP + "namesrv.properties"); nameServerNettyServerConfig.setListenPort(9000 + random.nextInt(1000)); NamesrvController namesrvController = new NamesrvController(namesrvConfig, nameServerNettyServerConfig); try { Assert.assertTrue(namesrvController.initialize()); logger.info("Name Server Start:{}", nameServerNettyServerConfig.getListenPort()); namesrvController.start(); } catch (Exception e) { logger.info("Name Server start failed"); System.exit(1); } NAMESRV_CONTROLLERS.add(namesrvController); return namesrvController; }
Example #16
Source File: IntegrationTestBase.java From DDMQ with Apache License 2.0 | 6 votes |
public static NamesrvController createAndStartNamesrv() { String baseDir = createBaseDir(); NamesrvConfig namesrvConfig = new NamesrvConfig(); NettyServerConfig nameServerNettyServerConfig = new NettyServerConfig(); namesrvConfig.setKvConfigPath(baseDir + SEP + "namesrv" + SEP + "kvConfig.json"); namesrvConfig.setConfigStorePath(baseDir + SEP + "namesrv" + SEP + "namesrv.properties"); nameServerNettyServerConfig.setListenPort(9000 + random.nextInt(1000)); NamesrvController namesrvController = new NamesrvController(namesrvConfig, nameServerNettyServerConfig); try { Assert.assertTrue(namesrvController.initialize()); logger.info("Name Server Start:{}", nameServerNettyServerConfig.getListenPort()); namesrvController.start(); } catch (Exception e) { logger.info("Name Server start failed"); System.exit(1); } NAMESRV_CONTROLLERS.add(namesrvController); return namesrvController; }
Example #17
Source File: DefaultRequestProcessorTest.java From DDMQ with Apache License 2.0 | 6 votes |
@Before public void init() throws Exception { namesrvConfig = new NamesrvConfig(); nettyServerConfig = new NettyServerConfig(); routeInfoManager = new RouteInfoManager(); namesrvController = new NamesrvController(namesrvConfig, nettyServerConfig); Field field = NamesrvController.class.getDeclaredField("routeInfoManager"); field.setAccessible(true); field.set(namesrvController, routeInfoManager); defaultRequestProcessor = new DefaultRequestProcessor(namesrvController); registerRouteInfoManager(); logger = mock(Logger.class); when(logger.isInfoEnabled()).thenReturn(false); setFinalStatic(DefaultRequestProcessor.class.getDeclaredField("log"), logger); }
Example #18
Source File: ClusterTestRequestProcessorTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Before public void init() throws NoSuchFieldException, IllegalAccessException, RemotingException, MQClientException, InterruptedException { NamesrvController namesrvController = new NamesrvController( new NamesrvConfig(), new NettyServerConfig() ); clusterTestProcessor = new ClusterTestRequestProcessor(namesrvController, "default-producer"); mQClientAPIImpl = mock(MQClientAPIImpl.class); DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(); defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000); ctx = mock(ChannelHandlerContext.class); Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance"); field.setAccessible(true); field.set(defaultMQAdminExtImpl, mqClientInstance); field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl"); field.setAccessible(true); field.set(mqClientInstance, mQClientAPIImpl); field = ClusterTestRequestProcessor.class.getDeclaredField("adminExt"); field.setAccessible(true); field.set(clusterTestProcessor, defaultMQAdminExt); TopicRouteData topicRouteData = new TopicRouteData(); List<BrokerData> brokerDatas = new ArrayList<>(); HashMap<Long, String> brokerAddrs = new HashMap<>(); brokerAddrs.put(1234l, "127.0.0.1:10911"); BrokerData brokerData = new BrokerData(); brokerData.setCluster("default-cluster"); brokerData.setBrokerName("default-broker"); brokerData.setBrokerAddrs(brokerAddrs); brokerDatas.add(brokerData); topicRouteData.setBrokerDatas(brokerDatas); when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData); }
Example #19
Source File: NamesrvController.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
public NamesrvController(NamesrvConfig namesrvConfig, NettyServerConfig nettyServerConfig) { this.namesrvConfig = namesrvConfig; this.nettyServerConfig = nettyServerConfig; this.kvConfigManager = new KVConfigManager(this); this.routeInfoManager = new RouteInfoManager(); this.brokerHousekeepingService = new BrokerHousekeepingService(this); // =》 this.configuration = new Configuration( log, this.namesrvConfig, this.nettyServerConfig ); // 指定保存namesrv配置的配置文件 this.configuration.setStorePathFromConfig(this.namesrvConfig, "configStorePath"); }
Example #20
Source File: AbstractTestCase.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
/** * Start rocketmq name server * @throws Exception */ private static void startNamesrv() throws Exception { NamesrvConfig namesrvConfig = new NamesrvConfig(); NettyServerConfig nettyServerConfig = new NettyServerConfig(); nettyServerConfig.setListenPort(9876); namesrvController = new NamesrvController(namesrvConfig, nettyServerConfig); boolean initResult = namesrvController.initialize(); if (!initResult) { namesrvController.shutdown(); throw new Exception(); } namesrvController.start(); }
Example #21
Source File: NamesrvController.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
public NamesrvController(NamesrvConfig namesrvConfig, NettyServerConfig nettyServerConfig) { this.namesrvConfig = namesrvConfig; this.nettyServerConfig = nettyServerConfig; this.kvConfigManager = new KVConfigManager(this); this.routeInfoManager = new RouteInfoManager(); this.brokerHousekeepingService = new BrokerHousekeepingService(this); //接收Broker连接事件 this.configuration = new Configuration( log, this.namesrvConfig, this.nettyServerConfig ); this.configuration.setStorePathFromConfig(this.namesrvConfig, "configStorePath"); }
Example #22
Source File: BrokerHousekeepingServiceTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() { NamesrvController namesrvController = new NamesrvController( new NamesrvConfig(), new NettyServerConfig() ); brokerHousekeepingService = new BrokerHousekeepingService(namesrvController); }
Example #23
Source File: NamesrvControllerTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
/** * Tests if the controller can be properly stopped and started. * * @throws Exception If fails. */ @Test public void testRestart() throws Exception { for (int i = 0; i < RESTARTNUM; i++) { NamesrvController namesrvController = new NamesrvController( new NamesrvConfig(), new NettyServerConfig() ); boolean initResult = namesrvController.initialize(); assertThat(initResult).isEqualTo(true); namesrvController.start(); namesrvController.shutdown(); } }
Example #24
Source File: ClusterTestRequestProcessorTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Before public void init() throws NoSuchFieldException, IllegalAccessException, RemotingException, MQClientException, InterruptedException { NamesrvController namesrvController = new NamesrvController( new NamesrvConfig(), new NettyServerConfig() ); clusterTestProcessor = new ClusterTestRequestProcessor(namesrvController, "default-producer"); mQClientAPIImpl = mock(MQClientAPIImpl.class); DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(); defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000); ctx = mock(ChannelHandlerContext.class); Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance"); field.setAccessible(true); field.set(defaultMQAdminExtImpl, mqClientInstance); field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl"); field.setAccessible(true); field.set(mqClientInstance, mQClientAPIImpl); field = ClusterTestRequestProcessor.class.getDeclaredField("adminExt"); field.setAccessible(true); field.set(clusterTestProcessor, defaultMQAdminExt); TopicRouteData topicRouteData = new TopicRouteData(); List<BrokerData> brokerDatas = new ArrayList<>(); HashMap<Long, String> brokerAddrs = new HashMap<>(); brokerAddrs.put(1234l, "127.0.0.1:10911"); BrokerData brokerData = new BrokerData(); brokerData.setCluster("default-cluster"); brokerData.setBrokerName("default-broker"); brokerData.setBrokerAddrs(brokerAddrs); brokerDatas.add(brokerData); topicRouteData.setBrokerDatas(brokerDatas); when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData); }
Example #25
Source File: NamesrvController.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
public NamesrvController(NamesrvConfig namesrvConfig, NettyServerConfig nettyServerConfig) { this.namesrvConfig = namesrvConfig; this.nettyServerConfig = nettyServerConfig; this.kvConfigManager = new KVConfigManager(this); this.routeInfoManager = new RouteInfoManager(); this.brokerHousekeepingService = new BrokerHousekeepingService(this); this.configuration = new Configuration( log, this.namesrvConfig, this.nettyServerConfig ); this.configuration.setStorePathFromConfig(this.namesrvConfig, "configStorePath"); }
Example #26
Source File: BrokerHousekeepingServiceTest.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() { NamesrvController namesrvController = new NamesrvController( new NamesrvConfig(), new NettyServerConfig() ); brokerHousekeepingService = new BrokerHousekeepingService(namesrvController); }
Example #27
Source File: NamesrvControllerTest.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
/** * Tests if the controller can be properly stopped and started. * * @throws Exception If fails. */ @Test public void testRestart() throws Exception { for (int i = 0; i < RESTARTNUM; i++) { NamesrvController namesrvController = new NamesrvController( new NamesrvConfig(), new NettyServerConfig() ); boolean initResult = namesrvController.initialize(); assertThat(initResult).isEqualTo(true); namesrvController.start(); namesrvController.shutdown(); } }
Example #28
Source File: ClusterTestRequestProcessorTest.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
@Before public void init() throws NoSuchFieldException, IllegalAccessException, RemotingException, MQClientException, InterruptedException { NamesrvController namesrvController = new NamesrvController( new NamesrvConfig(), new NettyServerConfig() ); clusterTestProcessor = new ClusterTestRequestProcessor(namesrvController, "default-producer"); mQClientAPIImpl = mock(MQClientAPIImpl.class); DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(); defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000); ctx = mock(ChannelHandlerContext.class); Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance"); field.setAccessible(true); field.set(defaultMQAdminExtImpl, mqClientInstance); field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl"); field.setAccessible(true); field.set(mqClientInstance, mQClientAPIImpl); field = ClusterTestRequestProcessor.class.getDeclaredField("adminExt"); field.setAccessible(true); field.set(clusterTestProcessor, defaultMQAdminExt); TopicRouteData topicRouteData = new TopicRouteData(); List<BrokerData> brokerDatas = new ArrayList<>(); HashMap<Long, String> brokerAddrs = new HashMap<>(); brokerAddrs.put(1234l, "127.0.0.1:10911"); BrokerData brokerData = new BrokerData(); brokerData.setCluster("default-cluster"); brokerData.setBrokerName("default-broker"); brokerData.setBrokerAddrs(brokerAddrs); brokerDatas.add(brokerData); topicRouteData.setBrokerDatas(brokerDatas); when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData); }
Example #29
Source File: ClusterTestRequestProcessorTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Before public void init() throws NoSuchFieldException, IllegalAccessException, RemotingException, MQClientException, InterruptedException { NamesrvController namesrvController = new NamesrvController( new NamesrvConfig(), new NettyServerConfig() ); clusterTestProcessor = new ClusterTestRequestProcessor(namesrvController, "default-producer"); mQClientAPIImpl = mock(MQClientAPIImpl.class); DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(); defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000); ctx = mock(ChannelHandlerContext.class); Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance"); field.setAccessible(true); field.set(defaultMQAdminExtImpl, mqClientInstance); field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl"); field.setAccessible(true); field.set(mqClientInstance, mQClientAPIImpl); field = ClusterTestRequestProcessor.class.getDeclaredField("adminExt"); field.setAccessible(true); field.set(clusterTestProcessor, defaultMQAdminExt); TopicRouteData topicRouteData = new TopicRouteData(); List<BrokerData> brokerDatas = new ArrayList<>(); HashMap<Long, String> brokerAddrs = new HashMap<>(); brokerAddrs.put(1234l, "127.0.0.1:10911"); BrokerData brokerData = new BrokerData(); brokerData.setCluster("default-cluster"); brokerData.setBrokerName("default-broker"); brokerData.setBrokerAddrs(brokerAddrs); brokerDatas.add(brokerData); topicRouteData.setBrokerDatas(brokerDatas); when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData); }
Example #30
Source File: BrokerHousekeepingServiceTest.java From DDMQ with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() { NamesrvController namesrvController = new NamesrvController( new NamesrvConfig(), new NettyServerConfig() ); brokerHousekeepingService = new BrokerHousekeepingService(namesrvController); }