Java Code Examples for org.apache.rocketmq.namesrv.NamesrvController#start()

The following examples show how to use org.apache.rocketmq.namesrv.NamesrvController#start() . 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 DDMQ with Apache License 2.0 6 votes vote down vote up
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-4.3.0 with Apache License 2.0 6 votes vote down vote up
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 3
Source File: IntegrationTestBase.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
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 4
Source File: IntegrationTestBase.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
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: IntegrationTestBase.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
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 6
Source File: IntegrationTestBase.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
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: IntegrationTestBase.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
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 8
Source File: IntegrationTestBase.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
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 9
Source File: NamesrvControllerTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
/**
 * namesrv 启动
 */
@Test
public void testStart() throws Exception {
    final NamesrvConfig namesrvConfig = new NamesrvConfig();
    final NettyServerConfig nettyServerConfig = new NettyServerConfig();
    nettyServerConfig.setListenPort(9876);
    NamesrvController namesrvController = new NamesrvController(namesrvConfig, nettyServerConfig);
    namesrvController.initialize();
    namesrvController.start();
    Thread.sleep(DateUtils.MILLIS_PER_DAY);
}
 
Example 10
Source File: AbstractTestCase.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}