HiveServer2启动流程

肖钟城
  • 大数据技术栈
  • Hive
小于 1 分钟

HiveServer2启动流程

HiveServer2#main() → oprocResponse.getServerOptionsExecutor().execute();

HiveServer2#startHiveServer2()

HiveServer2#init(HiveConf hiveConf) - 初始化

HiveServer2#start() - 启动

init初始化做了哪些事?

  1. 实例化CLIService
  2. 将cliService、thriftCLIService添加到ServiceList中
  3. 创建并注册物化视图

start启动做了哪些事?

主要继承了父类的start方法,主要内容如下:

  @Override
  public synchronized void start() {
    int i = 0;
    try {
      for (int n = serviceList.size(); i < n; i++) {
        Service service = serviceList.get(i);
        service.start();
      }
      super.start();
    } catch (Throwable e) {
      LOG.error("Error starting services " + getName(), e);
      // Note that the state of the failed service is still INITED and not
      // STARTED. Even though the last service is not started completely, still
      // call stop() on all services including failed service to make sure cleanup
      // happens.
      stop(i);
      throw new ServiceException("Failed to Start " + getName(), e);
    }

  }

主要是将初始化中的service进行启动。

根据配置hive.server2.transport.mode(默认为binary,也可设置为http),hiveserver2决定启动的ThriftCLIService是ThriftHttpCLIService还是ThriftBinaryCLIService。

ThriftCLIService中的start方法为:

  @Override
  public synchronized void start() {
    super.start();
    if (!isStarted && !isEmbedded) {
      initServer();
      serverThread = new Thread(this);
      serverThread.setName("Thrift Server");
      serverThread.start();
      isStarted = true;
    }
  }

在initServer()中,启动处理线程、配置thrift、配置其他参数以及启动TCP Server

评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v2.14.1