static ThriftHiveMetastore.Iface callEmbeddedMetastore(Configuration conf) throws MetaException {
    // Instantiate the metastore server handler directly instead of connecting
    // through the network
    //
    // The code below simulates the following code
    //
    // client = HiveMetaStore.newHMSHandler(this.conf);
    //
    // using reflection API. This is done to avoid dependency of MetastoreClient on Hive Metastore.
    // Note that newHMSHandler is static method, so we pass null as the object reference.
    //
    try {
      Class<?> clazz = Class.forName(HIVE_METASTORE_CLASS);
      //noinspection JavaReflectionMemberAccess
      Method method = clazz.getDeclaredMethod(HIVE_METASTORE_CREATE_HANDLER_METHOD, Configuration.class);
      method.setAccessible(true);
      return (ThriftHiveMetastore.Iface) method.invoke(null, conf);
    } catch (InvocationTargetException e) {
      if (e.getCause() != null) {
        MetaStoreUtils.throwMetaException((Exception) e.getCause());
      }
      MetaStoreUtils.throwMetaException(e);
    } catch (ClassNotFoundException
        | NoSuchMethodException
        | IllegalAccessException e) {
      MetaStoreUtils.throwMetaException(e);
    }
    return null;
  }
Instantiate the metastore server handler directly instead of connecting
through the network

@param conf Configuration object passed to embedded metastore
@return embedded client instance
@throws MetaException
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java