Search in sources :

Example 6 with TopicConfigSerializeWrapper

use of org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class TopicConfigManager method buildTopicConfigSerializeWrapper.

public TopicConfigSerializeWrapper buildTopicConfigSerializeWrapper() {
    TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper();
    topicConfigSerializeWrapper.setTopicConfigTable(this.topicConfigTable);
    topicConfigSerializeWrapper.setDataVersion(this.dataVersion);
    return topicConfigSerializeWrapper;
}
Also used : TopicConfigSerializeWrapper(org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper)

Example 7 with TopicConfigSerializeWrapper

use of org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class DefaultRequestProcessorTest method registerRouteInfoManager.

private void registerRouteInfoManager() {
    TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper();
    ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>();
    TopicConfig topicConfig = new TopicConfig();
    topicConfig.setWriteQueueNums(8);
    topicConfig.setTopicName("unit-test");
    topicConfig.setPerm(6);
    topicConfig.setReadQueueNums(8);
    topicConfig.setOrder(false);
    topicConfigConcurrentHashMap.put("unit-test", topicConfig);
    topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap);
    Channel channel = mock(Channel.class);
    RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", "127.0.0.1:10911", "default-broker", 1234, "127.0.0.1:1001", topicConfigSerializeWrapper, new ArrayList<String>(), channel);
}
Also used : RegisterBrokerResult(org.apache.rocketmq.common.namesrv.RegisterBrokerResult) TopicConfigSerializeWrapper(org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper) Channel(io.netty.channel.Channel) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TopicConfig(org.apache.rocketmq.common.TopicConfig)

Example 8 with TopicConfigSerializeWrapper

use of org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class DefaultRequestProcessor method registerBroker.

public RemotingCommand registerBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class);
    final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader) response.readCustomHeader();
    final RegisterBrokerRequestHeader requestHeader = (RegisterBrokerRequestHeader) request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
    TopicConfigSerializeWrapper topicConfigWrapper;
    if (request.getBody() != null) {
        topicConfigWrapper = TopicConfigSerializeWrapper.decode(request.getBody(), TopicConfigSerializeWrapper.class);
    } else {
        topicConfigWrapper = new TopicConfigSerializeWrapper();
        topicConfigWrapper.getDataVersion().setCounter(new AtomicLong(0));
        topicConfigWrapper.getDataVersion().setTimestamp(0);
    }
    RegisterBrokerResult result = this.namesrvController.getRouteInfoManager().registerBroker(requestHeader.getClusterName(), requestHeader.getBrokerAddr(), requestHeader.getBrokerName(), requestHeader.getBrokerId(), requestHeader.getHaServerAddr(), topicConfigWrapper, null, ctx.channel());
    responseHeader.setHaServerAddr(result.getHaServerAddr());
    responseHeader.setMasterAddr(result.getMasterAddr());
    byte[] jsonValue = this.namesrvController.getKvConfigManager().getKVListByNamespace(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG);
    response.setBody(jsonValue);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) AtomicLong(java.util.concurrent.atomic.AtomicLong) RegisterBrokerResult(org.apache.rocketmq.common.namesrv.RegisterBrokerResult) TopicConfigSerializeWrapper(org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper) RegisterBrokerResponseHeader(org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerResponseHeader) UnRegisterBrokerRequestHeader(org.apache.rocketmq.common.protocol.header.namesrv.UnRegisterBrokerRequestHeader) RegisterBrokerRequestHeader(org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader)

Example 9 with TopicConfigSerializeWrapper

use of org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper in project rocketmq by apache.

the class DefaultRequestProcessor method registerBroker.

public RemotingCommand registerBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class);
    final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader) response.readCustomHeader();
    final RegisterBrokerRequestHeader requestHeader = (RegisterBrokerRequestHeader) request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
    TopicConfigSerializeWrapper topicConfigWrapper;
    if (request.getBody() != null) {
        topicConfigWrapper = TopicConfigSerializeWrapper.decode(request.getBody(), TopicConfigSerializeWrapper.class);
    } else {
        topicConfigWrapper = new TopicConfigSerializeWrapper();
        topicConfigWrapper.getDataVersion().setCounter(new AtomicLong(0));
        topicConfigWrapper.getDataVersion().setTimestamp(0);
    }
    RegisterBrokerResult result = this.namesrvController.getRouteInfoManager().registerBroker(requestHeader.getClusterName(), requestHeader.getBrokerAddr(), requestHeader.getBrokerName(), requestHeader.getBrokerId(), requestHeader.getHaServerAddr(), topicConfigWrapper, null, ctx.channel());
    responseHeader.setHaServerAddr(result.getHaServerAddr());
    responseHeader.setMasterAddr(result.getMasterAddr());
    byte[] jsonValue = this.namesrvController.getKvConfigManager().getKVListByNamespace(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG);
    response.setBody(jsonValue);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) AtomicLong(java.util.concurrent.atomic.AtomicLong) RegisterBrokerResult(org.apache.rocketmq.common.namesrv.RegisterBrokerResult) TopicConfigSerializeWrapper(org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper) RegisterBrokerResponseHeader(org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerResponseHeader) UnRegisterBrokerRequestHeader(org.apache.rocketmq.common.protocol.header.namesrv.UnRegisterBrokerRequestHeader) RegisterBrokerRequestHeader(org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader)

Example 10 with TopicConfigSerializeWrapper

use of org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper in project rocketmq by apache.

the class DefaultRequestProcessorTest method registerRouteInfoManager.

private void registerRouteInfoManager() {
    TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper();
    ConcurrentHashMap<String, TopicConfig> topicConfigConcurrentHashMap = new ConcurrentHashMap<>();
    TopicConfig topicConfig = new TopicConfig();
    topicConfig.setWriteQueueNums(8);
    topicConfig.setTopicName("unit-test");
    topicConfig.setPerm(6);
    topicConfig.setReadQueueNums(8);
    topicConfig.setOrder(false);
    topicConfigConcurrentHashMap.put("unit-test", topicConfig);
    topicConfigSerializeWrapper.setTopicConfigTable(topicConfigConcurrentHashMap);
    Channel channel = mock(Channel.class);
    RegisterBrokerResult registerBrokerResult = routeInfoManager.registerBroker("default-cluster", "127.0.0.1:10911", "default-broker", 1234, "127.0.0.1:1001", topicConfigSerializeWrapper, new ArrayList<String>(), channel);
}
Also used : RegisterBrokerResult(org.apache.rocketmq.common.namesrv.RegisterBrokerResult) TopicConfigSerializeWrapper(org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper) Channel(io.netty.channel.Channel) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TopicConfig(org.apache.rocketmq.common.TopicConfig)

Aggregations

TopicConfigSerializeWrapper (org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper)21 RegisterBrokerResult (org.apache.rocketmq.common.namesrv.RegisterBrokerResult)8 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)7 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 TopicConfig (org.apache.rocketmq.common.TopicConfig)6 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)5 Channel (io.netty.channel.Channel)4 IOException (java.io.IOException)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 RegisterBrokerRequestHeader (org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader)2 RegisterBrokerResponseHeader (org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerResponseHeader)2 UnRegisterBrokerRequestHeader (org.apache.rocketmq.common.protocol.header.namesrv.UnRegisterBrokerRequestHeader)2 Test (org.junit.Test)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MQClientException (org.apache.rocketmq.client.exception.MQClientException)1 RemotingClient (org.apache.rocketmq.remoting.RemotingClient)1 RemotingCommandException (org.apache.rocketmq.remoting.exception.RemotingCommandException)1 RemotingConnectException (org.apache.rocketmq.remoting.exception.RemotingConnectException)1 RemotingException (org.apache.rocketmq.remoting.exception.RemotingException)1 RemotingSendRequestException (org.apache.rocketmq.remoting.exception.RemotingSendRequestException)1