public static Configuration newMetastoreConf(Configuration conf) {

    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    if (classLoader == null) {
      classLoader = MetastoreConf.class.getClassLoader();
    }
    // We don't add this to the resources because we don't want to read config values from it.
    // But we do find it because we want to remember where it is for later in case anyone calls
    // getHiveDefaultLocation().
    hiveDefaultURL = classLoader.getResource("hive-default.xml");

    // Add in hive-site.xml.  We add this first so that it gets overridden by the new metastore
    // specific files if they exist.
    if(hiveSiteURL == null) {
      /*
       * this 'if' is pretty lame - QTestUtil.QTestUtil() uses hiveSiteURL to load a specific
       * hive-site.xml from data/conf/<subdir> so this makes it follow the same logic - otherwise
       * HiveConf and MetastoreConf may load different hive-site.xml  ( For example,
       * HiveConf uses data/conf/tez/hive-site.xml and MetastoreConf data/conf/hive-site.xml)
       */
      hiveSiteURL = findConfigFile(classLoader, "hive-site.xml");
    }
    if (hiveSiteURL != null) {
      conf.addResource(hiveSiteURL);
    }

    // Now add hivemetastore-site.xml.  Again we add this before our own config files so that the
    // newer overrides the older.
    hiveMetastoreSiteURL = findConfigFile(classLoader, "hivemetastore-site.xml");
    if (hiveMetastoreSiteURL != null) {
      conf.addResource(hiveMetastoreSiteURL);
    }

    // Add in our conf file
    metastoreSiteURL = findConfigFile(classLoader, "metastore-site.xml");
    if (metastoreSiteURL !=  null) {
      conf.addResource(metastoreSiteURL);
    }

    // If a system property that matches one of our conf value names is set then use the value
    // it's set to to set our own conf value.
    for (ConfVars var : ConfVars.values()) {
      if (System.getProperty(var.varname) != null) {
        LOG.debug("Setting conf value " + var.varname + " using value " +
            System.getProperty(var.varname));
        conf.set(var.varname, System.getProperty(var.varname));
      }
    }

    // Pick up any system properties that start with "hive." and set them in our config.  This
    // way we can properly pull any Hive values from the environment without needing to know all
    // of the Hive config values.
    System.getProperties().stringPropertyNames().stream()
        .filter(s -> s.startsWith("hive."))
        .forEach(s -> {
          String v = System.getProperty(s);
          LOG.debug("Picking up system property " + s + " with value " + v);
          conf.set(s, v);
        });

    // If we are going to validate the schema, make sure we don't create it
    if (getBoolVar(conf, ConfVars.SCHEMA_VERIFICATION)) {
      setBoolVar(conf, ConfVars.AUTO_CREATE_ALL, false);
    }

    if (!beenDumped.getAndSet(true) && getBoolVar(conf, ConfVars.DUMP_CONFIG_ON_CREATION) &&
        LOG.isDebugEnabled()) {
      LOG.debug(dumpConfig(conf));
    }

    /*
    Add deprecated config names to configuration.
    The parameters for Configuration.addDeprecation are (oldKey, newKey) and it is assumed that the config is set via
    newKey and the value is retrieved via oldKey.
    However in this case we assume the value is set with the deprecated key (oldKey) in some config file and we
    retrieve it in the code via the new key. So the parameter order we use here is: (newKey, deprecatedKey).
    We do this with the HiveConf configs as well.
     */
    for (ConfVars var : ConfVars.values()) {
      if (var.deprecatedName != null) {
        Configuration.addDeprecation(var.getVarname(), var.deprecatedName);
      }
      if (var.hiveDeprecatedName != null) {
        Configuration.addDeprecation(var.getHiveName(), var.hiveDeprecatedName);
      }
    }

    return conf;
  }
This is useful if you need the variable name for a LOG message or
{@link System#setProperty(String, String)}, beware however that you should only use this
with setProperty if you're going to create a configuration via
{@link MetastoreConf#newMetastoreConf()}.  If you are going to create it with HiveConf,
then use {@link #getHiveName()}.
@return metastore.* configuration key
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java