美文网首页
Rocket NameSrv 大致分析

Rocket NameSrv 大致分析

作者: 运动书生 | 来源:发表于2018-05-16 21:06 被阅读0次

    NameSrv实现还是相当轻量级的,就是本地维护一些配置,各种api请求进行crud。
    类目录如下


    nameser-class.png

    NamesrvStartup:启动类
    NamesrvController:主要控制类

        private final NamesrvConfig namesrvConfig;
        private final NettyServerConfig nettyServerConfig;
        private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
            "NSScheduledThread"));
        private final KVConfigManager kvConfigManager;
        private final RouteInfoManager routeInfoManager;
        private RemotingServer remotingServer;
        private BrokerHousekeepingService brokerHousekeepingService;
        private ExecutorService remotingExecutor;
        private Configuration configuration;
    

    RouteInfoManager:存储数据

    private final HashMap<String/* topic */, List<QueueData>> topicQueueTable;
       private final HashMap<String/* brokerName */, BrokerData> brokerAddrTable;
       private final HashMap<String/* clusterName */, Set<String/* brokerName */>> clusterAddrTable;
       private final HashMap<String/* brokerAddr */, BrokerLiveInfo> brokerLiveTable;
       private final HashMap<String/* brokerAddr */, List<String>/* Filter Server */> filterServerTable;
    

    DefaultRequestProcessor:处理请求的类

    switch (request.getCode()) {
                case RequestCode.PUT_KV_CONFIG:
                    return this.putKVConfig(ctx, request);
                case RequestCode.GET_KV_CONFIG:
                    return this.getKVConfig(ctx, request);
                case RequestCode.DELETE_KV_CONFIG:
                    return this.deleteKVConfig(ctx, request);
                case RequestCode.REGISTER_BROKER:
                    Version brokerVersion = MQVersion.value2Version(request.getVersion());
                    if (brokerVersion.ordinal() >= MQVersion.Version.V3_0_11.ordinal()) {
                        return this.registerBrokerWithFilterServer(ctx, request);
                    } else {
                        return this.registerBroker(ctx, request);
                    }
                case RequestCode.UNREGISTER_BROKER:
                    return this.unregisterBroker(ctx, request);
                case RequestCode.GET_ROUTEINTO_BY_TOPIC:
                    return this.getRouteInfoByTopic(ctx, request);
                case RequestCode.GET_BROKER_CLUSTER_INFO:
                    return this.getBrokerClusterInfo(ctx, request);
                case RequestCode.WIPE_WRITE_PERM_OF_BROKER:
                    return this.wipeWritePermOfBroker(ctx, request);
                case RequestCode.GET_ALL_TOPIC_LIST_FROM_NAMESERVER:
                    return getAllTopicListFromNameserver(ctx, request);
                case RequestCode.DELETE_TOPIC_IN_NAMESRV:
                    return deleteTopicInNamesrv(ctx, request);
                case RequestCode.GET_KVLIST_BY_NAMESPACE:
                    return this.getKVListByNamespace(ctx, request);
                case RequestCode.GET_TOPICS_BY_CLUSTER:
                    return this.getTopicsByCluster(ctx, request);
                case RequestCode.GET_SYSTEM_TOPIC_LIST_FROM_NS:
                    return this.getSystemTopicListFromNs(ctx, request);
                case RequestCode.GET_UNIT_TOPIC_LIST:
                    return this.getUnitTopicList(ctx, request);
                case RequestCode.GET_HAS_UNIT_SUB_TOPIC_LIST:
                    return this.getHasUnitSubTopicList(ctx, request);
                case RequestCode.GET_HAS_UNIT_SUB_UNUNIT_TOPIC_LIST:
                    return this.getHasUnitSubUnUnitTopicList(ctx, request);
                case RequestCode.UPDATE_NAMESRV_CONFIG:
                    return this.updateConfig(ctx, request);
                case RequestCode.GET_NAMESRV_CONFIG:
                    return this.getConfig(ctx, request);
                default:
                    break;
            }
    

    启动逻辑
    todo

    相关文章

      网友评论

          本文标题:Rocket NameSrv 大致分析

          本文链接:https://www.haomeiwen.com/subject/pdbclftx.html