}
public RemotingCommand registerBroker(ChannelHandlerContext ctx, RemotingCommand request)
throws RemotingCommandException {
final RemotingCommand response =
RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class);
final RegisterBrokerResponseHeader responseHeader =
(RegisterBrokerResponseHeader) response.getCustomHeader();
final RegisterBrokerRequestHeader requestHeader =
(RegisterBrokerRequestHeader) request
.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
TopicConfigSerializeWrapper topicConfigWrapper = null;
if (request.getBody() != null) {
topicConfigWrapper =
TopicConfigSerializeWrapper.decode(request.getBody(), TopicConfigSerializeWrapper.class);
}
else {
topicConfigWrapper = new TopicConfigSerializeWrapper();
topicConfigWrapper.getDataVersion().setCounter(new AtomicLong(0));
topicConfigWrapper.getDataVersion().setTimestatmp(0);
}
RegisterBrokerResult result = this.namesrvController.getRouteInfoManager().registerBroker(//
requestHeader.getClusterName(), // 1
requestHeader.getBrokerAddr(), // 2
requestHeader.getBrokerName(), // 3
requestHeader.getBrokerId(), // 4
requestHeader.getHaServerAddr(),// 5
topicConfigWrapper, // 6
null,//
ctx.channel()// 7
);
responseHeader.setHaServerAddr(result.getHaServerAddr());
responseHeader.setMasterAddr(result.getMasterAddr());
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
return response;
}