private static ThriftServer startHttpMetastore(int port, Configuration conf)
      throws Exception {
    LOG.info("Attempting to start http metastore server on port: {}", port);
    // login principal if security is enabled
    ServletSecurity.loginServerPrincipal(conf);

    long maxMessageSize = MetastoreConf.getLongVar(conf, ConfVars.SERVER_MAX_MESSAGE_SIZE);
    int minWorkerThreads = MetastoreConf.getIntVar(conf, ConfVars.SERVER_MIN_THREADS);
    int maxWorkerThreads = MetastoreConf.getIntVar(conf, ConfVars.SERVER_MAX_THREADS);
    // Server thread pool
    // Start with minWorkerThreads, expand till maxWorkerThreads and reject
    // subsequent requests
    // TODO: Add a config for keepAlive time of threads ?
    ExecutorService executorService = new ThreadPoolExecutor(minWorkerThreads, maxWorkerThreads, 60L,
        TimeUnit.SECONDS, new SynchronousQueue<>(), r -> {
      Thread thread = new Thread(r);
      thread.setDaemon(true);
      thread.setName("Metastore-HttpHandler-Pool: Thread-" + thread.getId());
      return thread;
    }) {
      @Override
      public void setThreadFactory(ThreadFactory threadFactory) {
        // Avoid ExecutorThreadPool overriding the ThreadFactory
        LOG.warn("Ignore setting the thread factory as the pool has already provided his own: {}", getThreadFactory());
      }
    };
    ExecutorThreadPool threadPool = new ExecutorThreadPool((ThreadPoolExecutor) executorService);
    // HTTP Server
    org.eclipse.jetty.server.Server server = new Server(threadPool);
    server.setStopAtShutdown(true);

    ServerConnector connector;
    final HttpConfiguration httpServerConf = new HttpConfiguration();
    httpServerConf.setRequestHeaderSize(
        MetastoreConf.getIntVar(conf, ConfVars.METASTORE_THRIFT_HTTP_REQUEST_HEADER_SIZE));
    httpServerConf.setResponseHeaderSize(
        MetastoreConf.getIntVar(conf, ConfVars.METASTORE_THRIFT_HTTP_RESPONSE_HEADER_SIZE));
    httpServerConf.setSendServerVersion(false);
    httpServerConf.setSendXPoweredBy(false);

    final HttpConnectionFactory http = new HttpConnectionFactory(httpServerConf);

    final SslContextFactory sslContextFactory = ServletSecurity.createSslContextFactory(conf);
    if (sslContextFactory != null) {
      connector = new ServerConnector(server, sslContextFactory, http);
    } else {
      connector = new ServerConnector(server, http);
    }
    connector.setPort(port);
    connector.setReuseAddress(true);
    // TODO: What should the idle timeout be for the metastore? Currently it is 30 minutes
    long maxIdleTimeout = MetastoreConf.getTimeVar(conf, ConfVars.METASTORE_THRIFT_HTTP_MAX_IDLE_TIME,
        TimeUnit.MILLISECONDS);
    connector.setIdleTimeout(maxIdleTimeout);
    // TODO: AcceptQueueSize needs to be higher for HMS
    connector.setAcceptQueueSize(maxWorkerThreads);
    // TODO: Connection keepalive configuration?

    server.addConnector(connector);
    TProcessor processor;
    boolean useCompactProtocol = MetastoreConf.getBoolVar(conf, ConfVars.USE_THRIFT_COMPACT_PROTOCOL);
    final TProtocolFactory protocolFactory;
    if (useCompactProtocol) {
      protocolFactory = new TCompactProtocol.Factory();
    } else {
      protocolFactory = new TBinaryProtocol.Factory();
    }

    HMSHandler baseHandler = new HMSHandler("new db based metaserver", conf);
    IHMSHandler handler = HMSHandlerProxyFactory.getProxy(conf, baseHandler, false);
    processor = new ThriftHiveMetastore.Processor<>(handler);
    LOG.info("Starting DB backed MetaStore Server with generic processor");
    boolean jwt = MetastoreConf.getVar(conf, ConfVars.THRIFT_METASTORE_AUTHENTICATION).equalsIgnoreCase("jwt");
    ServletSecurity security = new ServletSecurity(conf, jwt);
    Servlet thriftHttpServlet = security.proxy(new TServlet(processor, protocolFactory));

    boolean directSqlEnabled = MetastoreConf.getBoolVar(conf, ConfVars.TRY_DIRECT_SQL);
    HMSHandler.LOG.info("Direct SQL optimization = {}",  directSqlEnabled);

    String httpPath =
        MetaStoreUtils.getHttpPath(
            MetastoreConf.getVar(conf, ConfVars.METASTORE_CLIENT_THRIFT_HTTP_PATH));

    ServletContextHandler context = new ServletContextHandler(
        ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);

    // Tons of stuff skipped as compared the HS2.
    // Sesions, XSRF, Compression, path configuration, etc.
    constraintHttpMethods(context, false);

    context.addServlet(new ServletHolder(thriftHttpServlet), httpPath);
    // adding a listener on servlet request so as to clean up
    // rawStore when http request is completed
    context.addEventListener(new ServletRequestListener() {
      @Override
      public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
        Request baseRequest = Request.getBaseRequest(servletRequestEvent.getServletRequest());
        HttpChannel channel = baseRequest.getHttpChannel();
        if (LOG.isDebugEnabled()) {
          LOG.debug("request: " + baseRequest + " destroyed " + ", http channel: " + channel);
        }
        HMSHandler.cleanupHandlerContext();
      }
      @Override
      public void requestInitialized(ServletRequestEvent servletRequestEvent) {
        Request baseRequest = Request.getBaseRequest(servletRequestEvent.getServletRequest());
        HttpChannel channel = baseRequest.getHttpChannel();
        if (LOG.isDebugEnabled()) {
          LOG.debug("request: " + baseRequest + " initialized " + ", http channel: " + channel);
        }
      }
    });
    server.setHandler(context);
    return new ThriftServer() {
      @Override
      public void start() throws Throwable {
        HMSHandler.LOG.debug("Starting HTTPServer for HMS");
        server.setStopAtShutdown(true);
        server.start();
        HMSHandler.LOG.info("Started the new HTTPServer for metastore on port [{}]...", port);
        HMSHandler.LOG.info("Options.minWorkerThreads = {}", minWorkerThreads);
        HMSHandler.LOG.info("Options.maxWorkerThreads = {}", maxWorkerThreads);
        HMSHandler.LOG.info("Enable SSL = {}", (sslContextFactory != null));
        server.join();
      }

      @Override
      public boolean isRunning() {
        return server != null && server.isRunning();
      }

      @Override
      public IHMSHandler getHandler() {
        return handler;
      }
    };
  }
Start the metastore store.
@param port
@param bridge
@param conf
@throws Throwable
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java