public Server startServer() throws Exception {
    // add all servlets
    Map<Integer, ServletContextHandler> handlersMap = new HashMap<>();
    for (Descriptor descriptor : descriptorsMap.values()) {
      addServlet(handlersMap, descriptor);
    }
    final int size = handlersMap.size();
    if (size == 0) {
      return null;
    }
    final Server server = createServer();
    // create the connectors
    final SslContextFactory sslFactory = ServletSecurity.createSslContextFactory(configuration);
    final ServerConnector[] connectors = new ServerConnector[size];
    final ServletContextHandler[] handlers = new ServletContextHandler[size];
    Iterator<Map.Entry<Integer, ServletContextHandler>> it = handlersMap.entrySet().iterator();
    for (int c = 0; it.hasNext(); ++c) {
      Map.Entry<Integer, ServletContextHandler> entry = it.next();
      int key = entry.getKey();
      int port = Math.max(key, 0);
      ServerConnector connector = createConnector(server, sslFactory, port);
      connectors[c] = connector;
      ServletContextHandler handler = entry.getValue();
      handlers[c] = handler;
      // make each servlet context be served only by its dedicated connector
      String host = "hms" + c;
      connector.setName(host);
      handler.setVirtualHosts(new String[]{"@" + host});
    }
    // hook the connectors and the handlers
    server.setConnectors(connectors);
    HandlerCollection portHandler = new ContextHandlerCollection();
    portHandler.setHandlers(handlers);
    server.setHandler(portHandler);
    // start the server
    server.start();
    // collect automatically assigned connector ports
    for (int i = 0; i < connectors.length; ++i) {
      int port = connectors[i].getLocalPort();
      ServletContextHandler handler = handlers[i];
      ServletHolder[] holders = handler.getServletHandler().getServlets();
      for (ServletHolder holder : holders) {
        Servlet servlet = holder.getServletInstance();
        if (servlet != null) {
          Descriptor descriptor = descriptorsMap.get(servlet);
          if (descriptor != null) {
            descriptor.setPort(port);
          }
        }
      }
    }
    return server;
  }
Convenience method to start a http server that serves all configured
servlets.

@return the server instance or null if no servlet was configured
@throws Exception if servlet initialization fails
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ServletServerBuilder.java