Search in sources :

Example 1 with NamesrvController

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

the class TestRocketMQServer method startNameServer.

/**
 * Starts a test nameserver.
 *
 * @throws Exception If fails.
 */
private void startNameServer() throws Exception {
    NamesrvConfig namesrvConfig = new NamesrvConfig();
    NettyServerConfig nameServerNettyServerConfig = new NettyServerConfig();
    namesrvConfig.setKvConfigPath(System.getProperty("java.io.tmpdir") + separator + "namesrv" + separator + "kvConfig.json");
    nameServerNettyServerConfig.setListenPort(NAME_SERVER_PORT);
    nameSrv = new NamesrvController(namesrvConfig, nameServerNettyServerConfig);
    nameSrv.initialize();
    nameSrv.start();
    log.info("Started nameserver at " + NAME_SERVER_PORT);
}
Also used : NamesrvConfig(org.apache.rocketmq.common.namesrv.NamesrvConfig) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig) NamesrvController(org.apache.rocketmq.namesrv.NamesrvController)

Example 2 with NamesrvController

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

the class TestRocketMQServer method startNameServer.

private void startNameServer() {
    namesrvConfig.setKvConfigPath(serverDir + separator + "namesrv" + separator + "kvConfig.json");
    nameServerNettyServerConfig.setListenPort(TestConstant.NAME_SERVER_PORT);
    namesrvController = new NamesrvController(namesrvConfig, nameServerNettyServerConfig);
    try {
        namesrvController.initialize();
        log.info("Success to start Name Server:{}", TestConstant.NAME_SERVER_ADDRESS);
        namesrvController.start();
    } catch (Exception e) {
        log.error("Failed to start Name Server", e);
        System.exit(1);
    }
    System.setProperty(MixAll.NAMESRV_ADDR_PROPERTY, TestConstant.NAME_SERVER_ADDRESS);
}
Also used : NamesrvController(org.apache.rocketmq.namesrv.NamesrvController)

Example 3 with NamesrvController

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

the class RocketMQServerMock method startNamesrv.

private 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("Namesvr init failure!");
    }
    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)

Example 4 with NamesrvController

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

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 5 with NamesrvController

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

the class BrokerHousekeepingServiceTest method setup.

@BeforeClass
public static void setup() {
    NamesrvController namesrvController = new NamesrvController(new NamesrvConfig(), new NettyServerConfig());
    brokerHousekeepingService = new BrokerHousekeepingService(namesrvController);
}
Also used : NamesrvConfig(org.apache.rocketmq.common.namesrv.NamesrvConfig) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig) NamesrvController(org.apache.rocketmq.namesrv.NamesrvController) BeforeClass(org.junit.BeforeClass)

Aggregations

NamesrvController (org.apache.rocketmq.namesrv.NamesrvController)21 NamesrvConfig (org.apache.rocketmq.common.namesrv.NamesrvConfig)20 NettyServerConfig (org.apache.rocketmq.remoting.netty.NettyServerConfig)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 EventDeliveryException (org.apache.flume.EventDeliveryException)3 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)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