Search in sources :

Example 6 with ConfVars

use of org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars in project hive by apache.

the class TestHiveMetaStoreGetMetaConf method testGetMetaConfDefault.

@Test
public void testGetMetaConfDefault() throws TException {
    ConfVars metaConfVar = ConfVars.TRY_DIRECT_SQL;
    String expected = metaConfVar.getDefaultVal().toString();
    String actual = hmsc.getMetaConf(metaConfVar.toString());
    assertEquals(expected, actual);
}
Also used : ConfVars(org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars) Test(org.junit.Test) MetastoreUnitTest(org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)

Example 7 with ConfVars

use of org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars in project hive by apache.

the class ObjectStore method getDataSourceProps.

/**
 * Properties specified in hive-default.xml override the properties specified
 * in jpox.properties.
 */
@SuppressWarnings("nls")
private static Properties getDataSourceProps(Configuration conf) {
    Properties prop = new Properties();
    correctAutoStartMechanism(conf);
    // has to be a separate first step because we don't set the default values in the config object.
    for (ConfVars var : MetastoreConf.dataNucleusAndJdoConfs) {
        String confVal = MetastoreConf.getAsString(conf, var);
        String varName = var.getVarname();
        Object prevVal = prop.setProperty(varName, confVal);
        if (MetastoreConf.isPrintable(varName)) {
            LOG.debug("Overriding {} value {} from jpox.properties with {}", varName, prevVal, confVal);
        }
    }
    // Password may no longer be in the conf, use getPassword()
    try {
        String passwd = MetastoreConf.getPassword(conf, MetastoreConf.ConfVars.PWD);
        if (org.apache.commons.lang.StringUtils.isNotEmpty(passwd)) {
            // We can get away with the use of varname here because varname == hiveName for PWD
            prop.setProperty(ConfVars.PWD.getVarname(), passwd);
        }
    } catch (IOException err) {
        throw new RuntimeException("Error getting metastore password: " + err.getMessage(), err);
    }
    if (LOG.isDebugEnabled()) {
        for (Entry<Object, Object> e : prop.entrySet()) {
            if (MetastoreConf.isPrintable(e.getKey().toString())) {
                LOG.debug("{} = {}", e.getKey(), e.getValue());
            }
        }
    }
    return prop;
}
Also used : IOException(java.io.IOException) MMetastoreDBProperties(org.apache.hadoop.hive.metastore.model.MMetastoreDBProperties) Properties(java.util.Properties) ConfVars(org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars)

Example 8 with ConfVars

use of org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars in project hive by apache.

the class HiveMetaStoreClient method isCompatibleWith.

@Override
public boolean isCompatibleWith(Configuration conf) {
    // Make a copy of currentMetaVars, there is a race condition that
    // currentMetaVars might be changed during the execution of the method
    Map<String, String> currentMetaVarsCopy = currentMetaVars;
    if (currentMetaVarsCopy == null) {
        // recreate
        return false;
    }
    boolean compatible = true;
    for (ConfVars oneVar : MetastoreConf.metaVars) {
        // Since metaVars are all of different types, use string for comparison
        String oldVar = currentMetaVarsCopy.get(oneVar.getVarname());
        String newVar = MetastoreConf.getAsString(conf, oneVar);
        if (oldVar == null || (oneVar.isCaseSensitive() ? !oldVar.equals(newVar) : !oldVar.equalsIgnoreCase(newVar))) {
            LOG.info("Mestastore configuration {} changed from {} to {}", oneVar, oldVar, newVar);
            compatible = false;
        }
    }
    return compatible;
}
Also used : ConfVars(org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars)

Example 9 with ConfVars

use of org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars in project hive by apache.

the class PersistenceManagerProvider method getDataSourceProps.

/**
 * Properties specified in hive-default.xml override the properties specified
 * in jpox.properties.
 */
@SuppressWarnings("nls")
private static Properties getDataSourceProps(Configuration conf) {
    Properties prop = new Properties();
    correctAutoStartMechanism(conf);
    // has to be a separate first step because we don't set the default values in the config object.
    for (ConfVars var : MetastoreConf.dataNucleusAndJdoConfs) {
        String confVal = MetastoreConf.getAsString(conf, var);
        String varName = var.getVarname();
        Object prevVal = prop.setProperty(varName, confVal);
        if (MetastoreConf.isPrintable(varName)) {
            LOG.debug("Overriding {} value {} from jpox.properties with {}", varName, prevVal, confVal);
        }
    }
    // Now, we need to look for any values that the user set that MetastoreConf doesn't know about.
    // TODO Commenting this out for now, as it breaks because the conf values aren't getting properly
    // interpolated in case of variables.  See HIVE-17788.
    /*
    for (Map.Entry<String, String> e : conf) {
      if (e.getKey().startsWith("datanucleus.") || e.getKey().startsWith("javax.jdo.")) {
        // We have to handle this differently depending on whether it is a value known to
        // MetastoreConf or not.  If it is, we need to get the default value if a value isn't
        // provided.  If not, we just set whatever the user has set.
        Object prevVal = prop.setProperty(e.getKey(), e.getValue());
        if (LOG.isDebugEnabled() && MetastoreConf.isPrintable(e.getKey())) {
          LOG.debug("Overriding " + e.getKey() + " value " + prevVal
              + " from  jpox.properties with " + e.getValue());
        }
      }
    }
    */
    // Password may no longer be in the conf, use getPassword()
    passwordProvider = passwordProvider != null ? passwordProvider : Suppliers.memoize(() -> {
        try {
            return MetastoreConf.getPassword(conf, ConfVars.PWD);
        } catch (IOException err) {
            throw new RuntimeException("Error getting metastore password: " + err.getMessage(), err);
        }
    });
    String passwd = passwordProvider.get();
    if (org.apache.commons.lang3.StringUtils.isNotEmpty(passwd)) {
        // We can get away with the use of varname here because varname == hiveName for PWD
        prop.setProperty(ConfVars.PWD.getVarname(), passwd);
    }
    if (LOG.isDebugEnabled()) {
        for (Entry<Object, Object> e : prop.entrySet()) {
            if (MetastoreConf.isPrintable(e.getKey().toString())) {
                LOG.debug("{} = {}", e.getKey(), e.getValue());
            }
        }
    }
    return prop;
}
Also used : IOException(java.io.IOException) Properties(java.util.Properties) ConfVars(org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars)

Aggregations

ConfVars (org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars)9 MetastoreUnitTest (org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 Properties (java.util.Properties)2 Configuration (org.apache.hadoop.conf.Configuration)1 ExceptionHandler.newMetaException (org.apache.hadoop.hive.metastore.ExceptionHandler.newMetaException)1 ExceptionHandler.throwMetaException (org.apache.hadoop.hive.metastore.ExceptionHandler.throwMetaException)1 MMetastoreDBProperties (org.apache.hadoop.hive.metastore.model.MMetastoreDBProperties)1