zoukankan      html  css  js  c++  java
  • HDFS源码分析之NameNode(1)————启动过程

    源码:2.8.0

    入口类:org.apache.hadoop.hdfs.server.namenode.NameNode

    main方法会调用createNameNode 创建 NameNode 实例,如果是 FORMAT 戒 FINALIZE,调用对应的方法后退出,如果是其他的参数,将创建NameNode 对象。创建的服务如下:

    服务                             类                              
    server                   ipc.RPC.Server      server.namenode.NameNodeRpcServer
    serviceRpcServer         ipc.RPC.Server    
    HttpServer               http.HttpServer    
    Trash Emptier            fs.Trash.Trash.Emptier    
    hbthread                 hdfs.server.namenode.FSNamesystem.HeartbeatMonitor      
    lmthread                 hdfs.server.namenode.LeaseManager.Monitor    
    replthread               hdfs.server.namenode.FSNamesystem.ReplicationMonitor    
    dnthread                 hdfs.server.namenode.DecommissionManager.Monitor  
    

      

    初始化步骤如下:

    分析启动模式: Format(格式化NameNode元数据及日志信息)

    // Parse the rest, NN specific args.
        StartupOption startOpt = parseArguments(argv);
        if (startOpt == null) {
          printUsage(System.err);
          return null;
        }
        setStartupOption(conf, startOpt);

    准备工作:

    setClientNamenodeAddress(conf);  //设置clients访问nomenode或nameservice的访问地址  配置项fs.defaultFS  

    1.初始化登录认证,如果HADOOP开启了Kerberos认证,则进行认证。

    UserGroupInformation.setConfiguration(conf);
    loginAsNameNodeUser(conf);

    认证的配置信息来自hdfs-site.xml

    配置项
    Dfs.namenode.keytab.file		     	#keytab文件
    Dfs.namenode.kerberos.principal	          #kerberos认证个体

    最后调用接口进行认证

    //UserGroupInformation管理用户登录
    UserGroupInformation.loginUserFromKeytab(principalName, keytabFilename);
    

      

    2.如果当前启动的NameNode角色是启用状态,启动HTTPServer服务

        if (NamenodeRole.NAMENODE == role) {
          startHttpServer(conf);
        }
    

      

    3.创建RPCServer

    rpcServer = createRpcServer(conf);

    创建过程如下:

    #初始化NameNode线程数,dfs.namenode.handler.count 默认10
    int handlerCount = 
          conf.getInt(DFS_NAMENODE_HANDLER_COUNT_KEY, 
                      DFS_NAMENODE_HANDLER_COUNT_DEFAULT);
    
    #设置初始化的RPC Engine 
    RPC.setProtocolEngine(conf, ClientNamenodeProtocolPB.class,
            ProtobufRpcEngine.class);

    NameNodeRpcServer实现NamenodeProtocols  支持以下Rpc调用

    public interface NamenodeProtocols
      extends ClientProtocol,
              DatanodeProtocol,
              DatanodeLifelineProtocol,
              NamenodeProtocol,
              RefreshAuthorizationPolicyProtocol,
              RefreshUserMappingsProtocol,
              RefreshCallQueueProtocol,
              GenericRefreshProtocol,
              GetUserMappingsProtocol,
              HAServiceProtocol,
              TraceAdminProtocol {
    }

    NameNodeRpcServer

      /** The RPC server that listens to requests from DataNodes 
        ##Address配置:dfs.namenode.servicerpc-address 默认8022
        ##dfs.namenode.service.handler.count 处理线程数
      */
      private final RPC.Server serviceRpcServer;
      private final InetSocketAddress serviceRPCAddress;
    
      /** The RPC server that listens to lifeline requests 
       #
    dfs.namenode.lifeline.rpc-address 默认50070*/
      private final RPC.Server lifelineRpcServer;
      private final InetSocketAddress lifelineRPCAddress;
      
      /** The RPC server that listens to requests from clients
        dfs.namenode.rpc-bind-host 默认8020*/
    protected final RPC.Server clientRpcServer; 
    protected final InetSocketAddress clientRpcAddress;
  • 相关阅读:
    字符串、组合练习
    national flag
    常用的Linux操作
    大数据概述
    LL(1)文法
    简单有穷自动机
    简单C语言文法
    词法分析
    编译原理 141
    综合练习
  • 原文地址:https://www.cnblogs.com/Dhouse/p/6890141.html
Copyright © 2011-2022 走看看