use of org.apache.rocketmq.namesrv.NamesrvController in project ignite by apache.
the class TestRocketMQServer method startNameServer.
/**
* Starts a test nameserver.
*
* @throws Exception If fails.
*/
private void startNameServer() throws Exception {
NamesrvConfig namesrvConfig = new NamesrvConfig();
NettyServerConfig nameServerNettyServerConfig = new NettyServerConfig();
namesrvConfig.setKvConfigPath(System.getProperty("java.io.tmpdir") + separator + "namesrv" + separator + "kvConfig.json");
nameServerNettyServerConfig.setListenPort(NAME_SERVER_PORT);
nameSrv = new NamesrvController(namesrvConfig, nameServerNettyServerConfig);
nameSrv.initialize();
nameSrv.start();
log.info("Started nameserver at " + NAME_SERVER_PORT);
}
use of org.apache.rocketmq.namesrv.NamesrvController in project rocketmq-externals by apache.
the class TestRocketMQServer method startNameServer.
private void startNameServer() {
namesrvConfig.setKvConfigPath(serverDir + separator + "namesrv" + separator + "kvConfig.json");
nameServerNettyServerConfig.setListenPort(TestConstant.NAME_SERVER_PORT);
namesrvController = new NamesrvController(namesrvConfig, nameServerNettyServerConfig);
try {
namesrvController.initialize();
log.info("Success to start Name Server:{}", TestConstant.NAME_SERVER_ADDRESS);
namesrvController.start();
} catch (Exception e) {
log.error("Failed to start Name Server", e);
System.exit(1);
}
System.setProperty(MixAll.NAMESRV_ADDR_PROPERTY, TestConstant.NAME_SERVER_ADDRESS);
}
use of org.apache.rocketmq.namesrv.NamesrvController in project rocketmq-externals by apache.
the class RocketMQServerMock method startNamesrv.
private 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("Namesvr init failure!");
}
namesrvController.start();
}
use of org.apache.rocketmq.namesrv.NamesrvController in project rocketmq by apache.
the class ClusterTestRequestProcessorTest method init.
@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);
}
use of org.apache.rocketmq.namesrv.NamesrvController in project rocketmq by apache.
the class BrokerHousekeepingServiceTest method setup.
@BeforeClass
public static void setup() {
NamesrvController namesrvController = new NamesrvController(new NamesrvConfig(), new NettyServerConfig());
brokerHousekeepingService = new BrokerHousekeepingService(namesrvController);
}
Aggregations