说在前面
继续解析管理请求GET_BROKER_CONFIG 获取broker配置
源码解析
进入到这个方法org.apache.rocketmq.broker.processor.AdminBrokerProcessor#getBrokerConfig 获取broker配置
private RemotingCommand getBrokerConfig(ChannelHandlerContext ctx, RemotingCommand request) { final RemotingCommand response = RemotingCommand.createResponseCommand(GetBrokerConfigResponseHeader.class); final GetBrokerConfigResponseHeader responseHeader = (GetBrokerConfigResponseHeader) response.readCustomHeader(); // 从内存中获取配置信息 String content = this.brokerController.getConfiguration().getAllConfigsFormatString(); 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; } } responseHeader.setVersion(this.brokerController.getConfiguration().getDataVersionJson()); response.setCode(ResponseCode.SUCCESS); response.setRemark(null); return response; }
进入这个方法org.apache.rocketmq.common.Configuration#getAllConfigsInternal 从配置中获取broker配置
private String getAllConfigsInternal() { StringBuilder stringBuilder = new StringBuilder(); // reload from config object ? for (Object configObject : this.configObjectList) { Properties properties = MixAll.object2Properties(configObject); if (properties != null) { merge(properties, this.allConfigs); } else { log.warn("getAllConfigsInternal object2Properties is null, {}", configObject.getClass()); } } { stringBuilder.append(MixAll.properties2String(this.allConfigs)); } return stringBuilder.toString(); }
往上返回到这个方法org.apache.rocketmq.broker.processor.AdminBrokerProcessor#getBrokerConfig 解析完毕。
说在最后
本次解析仅代表个人观点,仅供参考。
加入技术微信群
钉钉技术群