说在前面apache
今天解析管理请求处理之GET_ALL_TOPIC_CONFIG获取全部topic配置信息json
源码解析缓存
进入这个方法org.apache.rocketmq.broker.processor.AdminBrokerProcessor#getAllTopicConfig微信
private RemotingCommand getAllTopicConfig(ChannelHandlerContext ctx, RemotingCommand request) { final RemotingCommand response = RemotingCommand.createResponseCommand(GetAllTopicConfigResponseHeader.class); // final GetAllTopicConfigResponseHeader responseHeader = // (GetAllTopicConfigResponseHeader) response.readCustomHeader(); // 从本地缓存中获取信息 String content = this.brokerController.getTopicConfigManager().encode(); if (content != null && content.length() > 0) { try { response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET)); } catch (UnsupportedEncodingException e) { log.error("", e); response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("UnsupportedEncodingException " + e); return response; } } else { log.error("No topic in this broker, client: {}", ctx.channel().remoteAddress()); response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("No topic in this broker"); return response; } response.setCode(ResponseCode.SUCCESS); response.setRemark(null); return response; }
进入这个方法org.apache.rocketmq.broker.topic.TopicConfigManager#encode(boolean) 对topicConfig信息进行json编码app
public String encode(final boolean prettyFormat) { TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); topicConfigSerializeWrapper.setTopicConfigTable(this.topicConfigTable); topicConfigSerializeWrapper.setDataVersion(this.dataVersion); return topicConfigSerializeWrapper.toJson(prettyFormat); }
往上返回到这个方法org.apache.rocketmq.broker.processor.AdminBrokerProcessor#getAllTopicConfig 解析结束。this
说在最后编码
本次解析仅表明我的观点,仅供参考。code
加入技术微信群orm
钉钉技术群blog