HiveServer2启动流程
HiveServer2启动流程
HiveServer2#main() → oprocResponse.getServerOptionsExecutor().execute();
HiveServer2#startHiveServer2()
HiveServer2#init(HiveConf hiveConf) - 初始化
HiveServer2#start() - 启动
init初始化做了哪些事?
- 实例化CLIService
- 将cliService、thriftCLIService添加到ServiceList中
- 创建并注册物化视图
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