Search in sources :

Example 31 with NettyServerConfig

use of org.apache.rocketmq.remoting.netty.NettyServerConfig in project rocketmq by apache.

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 {
    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 32 with NettyServerConfig

use of org.apache.rocketmq.remoting.netty.NettyServerConfig in project rocketmq by apache.

the class DefaultRequestProcessorTest method init.

@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);
}
Also used : Field(java.lang.reflect.Field) NamesrvConfig(org.apache.rocketmq.common.namesrv.NamesrvConfig) RouteInfoManager(org.apache.rocketmq.namesrv.routeinfo.RouteInfoManager) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig) Logger(org.slf4j.Logger) NamesrvController(org.apache.rocketmq.namesrv.NamesrvController) Before(org.junit.Before)

Example 33 with NettyServerConfig

use of org.apache.rocketmq.remoting.netty.NettyServerConfig in project rocketmq 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);
    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 34 with NettyServerConfig

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

the class RocketMQServerMock method startBroker.

private void startBroker() throws Exception {
    System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
    BrokerConfig brokerConfig = new BrokerConfig();
    brokerConfig.setNamesrvAddr(getNameServerAddr());
    brokerConfig.setBrokerId(MixAll.MASTER_ID);
    NettyServerConfig nettyServerConfig = new NettyServerConfig();
    nettyServerConfig.setListenPort(brokerPort);
    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("Broker init failure!");
    }
    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)

Example 35 with NettyServerConfig

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

the class RocketMQServerMock method startNameServer.

private void startNameServer() throws Exception {
    NamesrvConfig namesrvConfig = new NamesrvConfig();
    NettyServerConfig nettyServerConfig = new NettyServerConfig();
    nettyServerConfig.setListenPort(nameServerPort);
    nameServerController = new NamesrvController(namesrvConfig, nettyServerConfig);
    boolean initResult = nameServerController.initialize();
    if (!initResult) {
        nameServerController.shutdown();
        throw new Exception("Namesvr init failure!");
    }
    nameServerController.start();
}
Also used : NamesrvConfig(org.apache.rocketmq.common.namesrv.NamesrvConfig) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig) NamesrvController(org.apache.rocketmq.namesrv.NamesrvController) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Aggregations

NettyServerConfig (org.apache.rocketmq.remoting.netty.NettyServerConfig)46 NamesrvConfig (org.apache.rocketmq.common.namesrv.NamesrvConfig)23 NamesrvController (org.apache.rocketmq.namesrv.NamesrvController)20 MQClientException (org.apache.rocketmq.client.exception.MQClientException)17 BrokerConfig (org.apache.rocketmq.common.BrokerConfig)17 NettyClientConfig (org.apache.rocketmq.remoting.netty.NettyClientConfig)17 MessageStoreConfig (org.apache.rocketmq.store.config.MessageStoreConfig)17 BrokerController (org.apache.rocketmq.broker.BrokerController)13 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)10 UnsupportedEncodingException (java.io.UnsupportedEncodingException)8 RemotingException (org.apache.rocketmq.remoting.exception.RemotingException)8 LoggerContext (ch.qos.logback.classic.LoggerContext)6 JoranConfigurator (ch.qos.logback.classic.joran.JoranConfigurator)6 BufferedInputStream (java.io.BufferedInputStream)6 FileInputStream (java.io.FileInputStream)6 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 Properties (java.util.Properties)6 Options (org.apache.commons.cli.Options)6 PosixParser (org.apache.commons.cli.PosixParser)6