Search in sources :

Example 1 with NettyClientConfig

use of org.apache.rocketmq.remoting.netty.NettyClientConfig in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class IntegrationTestBase method createAndStartBroker.

public static BrokerController createAndStartBroker(String nsAddr) {
    String baseDir = createBaseDir();
    BrokerConfig brokerConfig = new BrokerConfig();
    NettyServerConfig nettyServerConfig = new NettyServerConfig();
    NettyClientConfig nettyClientConfig = new NettyClientConfig();
    MessageStoreConfig storeConfig = new MessageStoreConfig();
    brokerConfig.setBrokerName(BROKER_NAME_PREFIX + BROKER_INDEX.getAndIncrement());
    brokerConfig.setBrokerIP1("127.0.0.1");
    brokerConfig.setNamesrvAddr(nsAddr);
    brokerConfig.setEnablePropertyFilter(true);
    storeConfig.setStorePathRootDir(baseDir);
    storeConfig.setStorePathCommitLog(baseDir + SEP + "commitlog");
    storeConfig.setHaListenPort(8000 + random.nextInt(1000));
    storeConfig.setMapedFileSizeCommitLog(COMMIT_LOG_SIZE);
    storeConfig.setMaxIndexNum(INDEX_NUM);
    storeConfig.setMaxHashSlotNum(INDEX_NUM * 4);
    nettyServerConfig.setListenPort(10000 + random.nextInt(1000));
    BrokerController brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, storeConfig);
    try {
        Assert.assertTrue(brokerController.initialize());
        logger.info("Broker Start name:{} addr:{}", brokerConfig.getBrokerName(), brokerController.getBrokerAddr());
        brokerController.start();
    } catch (Exception e) {
        logger.info("Broker start failed");
        System.exit(1);
    }
    BROKER_CONTROLLERS.add(brokerController);
    return brokerController;
}
Also used : MessageStoreConfig(org.apache.rocketmq.store.config.MessageStoreConfig) BrokerConfig(org.apache.rocketmq.common.BrokerConfig) NettyClientConfig(org.apache.rocketmq.remoting.netty.NettyClientConfig) BrokerController(org.apache.rocketmq.broker.BrokerController) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig)

Example 2 with NettyClientConfig

use of org.apache.rocketmq.remoting.netty.NettyClientConfig in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class BrokerControllerTest method testBrokerRestart.

/**
 * Tests if the controller can be properly stopped and started.
 *
 * @throws Exception If fails.
 */
@Test
public void testBrokerRestart() throws Exception {
    for (int i = 0; i < 2; i++) {
        BrokerController brokerController = new // 
        BrokerController(// 
        new BrokerConfig(), // 
        new NettyServerConfig(), // 
        new NettyClientConfig(), new MessageStoreConfig());
        assertThat(brokerController.initialize());
        brokerController.start();
        brokerController.shutdown();
    }
}
Also used : MessageStoreConfig(org.apache.rocketmq.store.config.MessageStoreConfig) BrokerConfig(org.apache.rocketmq.common.BrokerConfig) NettyClientConfig(org.apache.rocketmq.remoting.netty.NettyClientConfig) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig) Test(org.junit.Test)

Example 3 with NettyClientConfig

use of org.apache.rocketmq.remoting.netty.NettyClientConfig in project rocketmq-externals by apache.

the class RocketMQSinkTest method startBroker.

private static void startBroker() throws Exception {
    System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
    BrokerConfig brokerConfig = new BrokerConfig();
    brokerConfig.setNamesrvAddr(nameServer);
    brokerConfig.setBrokerId(MixAll.MASTER_ID);
    NettyServerConfig nettyServerConfig = new NettyServerConfig();
    nettyServerConfig.setListenPort(10911);
    NettyClientConfig nettyClientConfig = new NettyClientConfig();
    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, messageStoreConfig);
    boolean initResult = brokerController.initialize();
    if (!initResult) {
        brokerController.shutdown();
        throw new Exception();
    }
    brokerController.start();
}
Also used : MessageStoreConfig(org.apache.rocketmq.store.config.MessageStoreConfig) BrokerConfig(org.apache.rocketmq.common.BrokerConfig) NettyClientConfig(org.apache.rocketmq.remoting.netty.NettyClientConfig) BrokerController(org.apache.rocketmq.broker.BrokerController) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig) MQClientException(org.apache.rocketmq.client.exception.MQClientException) EventDeliveryException(org.apache.flume.EventDeliveryException) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RemotingException(org.apache.rocketmq.remoting.exception.RemotingException)

Example 4 with NettyClientConfig

use of org.apache.rocketmq.remoting.netty.NettyClientConfig in project rocketmq-externals by apache.

the class RocketMQSourceTest method startBroker.

private static void startBroker() throws Exception {
    System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
    BrokerConfig brokerConfig = new BrokerConfig();
    brokerConfig.setNamesrvAddr(nameServer);
    brokerConfig.setBrokerId(MixAll.MASTER_ID);
    NettyServerConfig nettyServerConfig = new NettyServerConfig();
    nettyServerConfig.setListenPort(10911);
    NettyClientConfig nettyClientConfig = new NettyClientConfig();
    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, messageStoreConfig);
    boolean initResult = brokerController.initialize();
    if (!initResult) {
        brokerController.shutdown();
        throw new Exception();
    }
    brokerController.start();
}
Also used : MessageStoreConfig(org.apache.rocketmq.store.config.MessageStoreConfig) BrokerConfig(org.apache.rocketmq.common.BrokerConfig) NettyClientConfig(org.apache.rocketmq.remoting.netty.NettyClientConfig) BrokerController(org.apache.rocketmq.broker.BrokerController) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig) MQClientException(org.apache.rocketmq.client.exception.MQClientException) EventDeliveryException(org.apache.flume.EventDeliveryException) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 5 with NettyClientConfig

use of org.apache.rocketmq.remoting.netty.NettyClientConfig in project rocketmq-externals by apache.

the class IntegrationTestBase method createAndStartBroker.

public static BrokerController createAndStartBroker(String nsAddr) {
    String baseDir = createBaseDir();
    BrokerConfig brokerConfig = new BrokerConfig();
    NettyServerConfig nettyServerConfig = new NettyServerConfig();
    NettyClientConfig nettyClientConfig = new NettyClientConfig();
    MessageStoreConfig storeConfig = new MessageStoreConfig();
    brokerConfig.setBrokerName(BROKER_NAME_PREFIX + BROKER_INDEX.getAndIncrement());
    brokerConfig.setBrokerIP1("127.0.0.1");
    brokerConfig.setNamesrvAddr(nsAddr);
    storeConfig.setStorePathRootDir(baseDir);
    storeConfig.setStorePathCommitLog(baseDir + SEP + "commitlog");
    storeConfig.setHaListenPort(8000 + random.nextInt(1000));
    nettyServerConfig.setListenPort(10000 + random.nextInt(1000));
    BrokerController brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, storeConfig);
    try {
        Assert.assertTrue(brokerController.initialize());
        logger.info("Broker Start name:{} addr:{}", brokerConfig.getBrokerName(), brokerController.getBrokerAddr());
        brokerController.start();
    } catch (Exception e) {
        System.out.println("Broker start failed");
        System.exit(1);
    }
    BROKER_CONTROLLERS.add(brokerController);
    return brokerController;
}
Also used : MessageStoreConfig(org.apache.rocketmq.store.config.MessageStoreConfig) BrokerConfig(org.apache.rocketmq.common.BrokerConfig) NettyClientConfig(org.apache.rocketmq.remoting.netty.NettyClientConfig) BrokerController(org.apache.rocketmq.broker.BrokerController) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Aggregations

NettyClientConfig (org.apache.rocketmq.remoting.netty.NettyClientConfig)15 BrokerConfig (org.apache.rocketmq.common.BrokerConfig)13 NettyServerConfig (org.apache.rocketmq.remoting.netty.NettyServerConfig)13 MessageStoreConfig (org.apache.rocketmq.store.config.MessageStoreConfig)13 BrokerController (org.apache.rocketmq.broker.BrokerController)9 MQClientException (org.apache.rocketmq.client.exception.MQClientException)5 LoggerContext (ch.qos.logback.classic.LoggerContext)2 JoranConfigurator (ch.qos.logback.classic.joran.JoranConfigurator)2 BufferedInputStream (java.io.BufferedInputStream)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Properties (java.util.Properties)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Options (org.apache.commons.cli.Options)2 PosixParser (org.apache.commons.cli.PosixParser)2 EventDeliveryException (org.apache.flume.EventDeliveryException)2 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2 Test (org.junit.Test)2 Logger (org.slf4j.Logger)2