Search in sources :

Example 21 with NamesrvConfig

use of org.apache.rocketmq.common.namesrv.NamesrvConfig in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class NamesrvControllerTest method testRestart.

/**
 * 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();
    }
}
Also used : NamesrvConfig(org.apache.rocketmq.common.namesrv.NamesrvConfig) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig) Test(org.junit.Test)

Example 22 with NamesrvConfig

use of org.apache.rocketmq.common.namesrv.NamesrvConfig in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

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 23 with NamesrvConfig

use of org.apache.rocketmq.common.namesrv.NamesrvConfig 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)

Aggregations

NamesrvConfig (org.apache.rocketmq.common.namesrv.NamesrvConfig)23 NettyServerConfig (org.apache.rocketmq.remoting.netty.NettyServerConfig)23 NamesrvController (org.apache.rocketmq.namesrv.NamesrvController)20 MQClientException (org.apache.rocketmq.client.exception.MQClientException)9 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 Field (java.lang.reflect.Field)4 RemotingException (org.apache.rocketmq.remoting.exception.RemotingException)4 Before (org.junit.Before)4 Logger (org.slf4j.Logger)4 EventDeliveryException (org.apache.flume.EventDeliveryException)3 LoggerContext (ch.qos.logback.classic.LoggerContext)2 JoranConfigurator (ch.qos.logback.classic.joran.JoranConfigurator)2 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)2 BufferedInputStream (java.io.BufferedInputStream)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2