从宏观上总结下吧,因为内部底层很多。
NamesrvController包含四部分:服务器远程连接、执行器、定时任务、文件监控
接下来回到起点:KVConfigManager。
抱歉,KVConfigManager也结束了。现在明白了,其实我们的起点KVConfigManager是一个小类,属于是对于全局配置的管理,还是我们之前说的,基于namespace做key的kv配置存储
private final HashMap<String/* Namespace */, HashMap<String/* Key */, String/* Value */>> configTable =
new HashMap<String, HashMap<String, String>>();
org.apache.rocketmq.namesrv.processor.ClusterTestRequestProcessor
接下来顺着包继续找,是一个集群测试请求处理器,看下对集群请求的处理是怎样的:
private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
private final DefaultMQAdminExt adminExt;
private final String productEnvName;
进来首先声明一个日志,字符串类型生产环境名称,还有一个DefaultMQAdminExt 默认mq管理扩展(我们暂且这样称呼它),之后我们进去看下这个管理扩展内部到底干了什么:
org.apache.rocketmq.tools.admin.DefaultMQAdminExt
private final DefaultMQAdminExtImpl defaultMQAdminExtImpl;
private String adminExtGroup = "admin_ext_group";
private String createTopicKey = TopicValidator.AUTO_CREATE_TOPIC_KEY_TOPIC;
private long timeoutMillis = 5000;
进来后首先声明一个默认mq管理扩展实现,超时时间,还有一个枚举类,获取的值是自动创建topic的topic,这里有两个类,一个是DefaultMQAdminExtImpl,一个是TopicValidator。我们分别看下:
org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl
private final InternalLogger log = ClientLogger.getLog();
private final DefaultMQAdminExt defaultMQAdminExt;
private ServiceState serviceState = ServiceState.CREATE_JUST;
private MQClientInstance mqClientInstance;
private RPCHook rpcHook;
private long timeoutMillis = 20000;
private Random random = new Random();
还是先看声明,这些声明里我们还没有读过的,应该就是ServiceState和MQClientInstance 看下ServiceState:
org.apache.rocketmq.common.ServiceState
/**
* Service just created,not start
*/
CREATE_JUST,
/**
* Service Running
*/
RUNNING,
/**
* Service shutdown
*/
SHUTDOWN_ALREADY,
/**
* Service Start failure
*/
START_FAILED;
是一个服务的状态枚举类,包含:刚创建,运行中,已销毁,启动失败