Search in sources :

Example 11 with NamesrvController

use of org.apache.rocketmq.namesrv.NamesrvController in project rocketmq by apache.

the class IntegrationTestBase method createAndStartNamesrv.

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

Example 12 with NamesrvController

use of org.apache.rocketmq.namesrv.NamesrvController in project rocketmq-externals by apache.

the class RocketMQSinkTest method startNamesrv.

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();
}
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) EventDeliveryException(org.apache.flume.EventDeliveryException) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RemotingException(org.apache.rocketmq.remoting.exception.RemotingException)

Example 13 with NamesrvController

use of org.apache.rocketmq.namesrv.NamesrvController in project rocketmq-externals by apache.

the class RocketMQSourceTest method startNamesrv.

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();
}
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) EventDeliveryException(org.apache.flume.EventDeliveryException) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 14 with NamesrvController

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

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);
}
Also used : BrokerData(org.apache.rocketmq.common.protocol.route.BrokerData) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NamesrvController(org.apache.rocketmq.namesrv.NamesrvController) TopicRouteData(org.apache.rocketmq.common.protocol.route.TopicRouteData) Field(java.lang.reflect.Field) NamesrvConfig(org.apache.rocketmq.common.namesrv.NamesrvConfig) MQClientAPIImpl(org.apache.rocketmq.client.impl.MQClientAPIImpl) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig) MQClientInstance(org.apache.rocketmq.client.impl.factory.MQClientInstance) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) DefaultMQAdminExtImpl(org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl) Before(org.junit.Before)

Example 15 with NamesrvController

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

Aggregations

NamesrvController (org.apache.rocketmq.namesrv.NamesrvController)16 NamesrvConfig (org.apache.rocketmq.common.namesrv.NamesrvConfig)15 NettyServerConfig (org.apache.rocketmq.remoting.netty.NettyServerConfig)15 MQClientException (org.apache.rocketmq.client.exception.MQClientException)5 Field (java.lang.reflect.Field)4 Before (org.junit.Before)4 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 EventDeliveryException (org.apache.flume.EventDeliveryException)2 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2 MQClientAPIImpl (org.apache.rocketmq.client.impl.MQClientAPIImpl)2 MQClientInstance (org.apache.rocketmq.client.impl.factory.MQClientInstance)2 BrokerData (org.apache.rocketmq.common.protocol.route.BrokerData)2 TopicRouteData (org.apache.rocketmq.common.protocol.route.TopicRouteData)2 RouteInfoManager (org.apache.rocketmq.namesrv.routeinfo.RouteInfoManager)2 DefaultMQAdminExt (org.apache.rocketmq.tools.admin.DefaultMQAdminExt)2 DefaultMQAdminExtImpl (org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl)2 BeforeClass (org.junit.BeforeClass)2