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);
}
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;
}
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;
}
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;
}
Aggregations