說在前面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