public static void startMetaStore(int port, HadoopThriftAuthBridge bridge,
      Configuration conf, boolean startMetaStoreThreads, AtomicBoolean startedBackgroundThreads) throws Throwable {
    isMetaStoreRemote = true;
    String transportMode = MetastoreConf.getVar(conf, ConfVars.THRIFT_TRANSPORT_MODE, "binary");
    boolean isHttpTransport = transportMode.equalsIgnoreCase("http");
    if (isHttpTransport) {
      thriftServer = startHttpMetastore(port, conf);
    } else {
      thriftServer = startBinaryMetastore(port, bridge, conf);
    }

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

    if (startMetaStoreThreads) {
      Lock metaStoreThreadsLock = new ReentrantLock();
      Condition startCondition = metaStoreThreadsLock.newCondition();
      AtomicBoolean startedServing = new AtomicBoolean();
      startMetaStoreThreads(conf, metaStoreThreadsLock, startCondition, startedServing, startedBackgroundThreads);
      signalOtherThreadsToStart(thriftServer, metaStoreThreadsLock, startCondition, startedServing);
    }

    // If dynamic service discovery through ZooKeeper is enabled, add this server to the ZooKeeper.
    if (MetastoreConf.getVar(conf, ConfVars.THRIFT_SERVICE_DISCOVERY_MODE)
            .equalsIgnoreCase("zookeeper")) {
      try {
        zooKeeperHelper = MetastoreConf.getZKConfig(conf);
        String serverInstanceURI = getServerInstanceURI(port);
        zooKeeperHelper.addServerInstanceToZooKeeper(serverInstanceURI, serverInstanceURI, null,
            new ZKDeRegisterWatcher(zooKeeperHelper));
        LOG.info("Metastore server instance with URL " + serverInstanceURI + " added to " +
            "the zookeeper");
      } catch (Exception e) {
        LOG.error("Error adding this metastore instance to ZooKeeper: ", e);
        throw e;
      }
    }

    // optionally create and start the property and Iceberg REST server
    ServletServerBuilder builder = new ServletServerBuilder(conf);
    ServletServerBuilder.Descriptor properties = builder.addServlet(PropertyServlet.createServlet(conf));
    ServletServerBuilder.Descriptor catalog = builder.addServlet(createIcebergServlet(conf));
    servletServer = builder.start(LOG);
    if (servletServer != null) {
      if (properties != null) {
          propertyServletPort = properties.getPort();
      }
      if (catalog != null) {
        catalogServletPort = catalog.getPort();
      }
    }

    // main server
    thriftServer.start();
  }
Start Metastore based on a passed {@link HadoopThriftAuthBridge}.

@param port The port on which the Thrift server will start to serve
@param bridge
@param conf Configuration overrides
@param startMetaStoreThreads Start the background threads (initiator, cleaner, statsupdater, etc.)
@param startedBackgroundThreads If startMetaStoreThreads is true, this AtomicBoolean will be switched to true,
 when all of the background threads are scheduled. Useful for testing purposes to wait
 until the MetaStore is fully initialized.
@throws Throwable
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java