Search in sources :

Example 1 with ConfVars

use of org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars in project flink 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 " + oneVar.toString() + " changed from " + oldVar + " to " + newVar);
            compatible = false;
        }
    }
    return compatible;
}
Also used : ConfVars(org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars)

Example 2 with ConfVars

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

the class HMSHandler method setMetaConf.

@Override
public void setMetaConf(String key, String value) throws MetaException {
    ConfVars confVar = MetastoreConf.getMetaConf(key);
    if (confVar == null) {
        throw new MetaException("Invalid configuration key " + key);
    }
    try {
        confVar.validate(value);
    } catch (IllegalArgumentException e) {
        throw new MetaException("Invalid configuration value " + value + " for key " + key + " by " + e.getMessage());
    }
    Configuration configuration = getConf();
    String oldValue = MetastoreConf.get(configuration, key);
    // Save prev val of the key on threadLocal
    Map<String, String> modifiedConf = HMSHandlerContext.getModifiedConfig();
    if (!modifiedConf.containsKey(key)) {
        modifiedConf.put(key, oldValue);
    }
    // metaListeners in HiveMetaStore#cleanupHandlerContext
    if (!HMSHandlerContext.getHMSHandler().isPresent()) {
        HMSHandlerContext.setHMSHandler(this);
    }
    configuration.set(key, value);
    notifyMetaListeners(key, oldValue, value);
    if (ConfVars.TRY_DIRECT_SQL == confVar) {
        HMSHandler.LOG.info("Direct SQL optimization = {}", value);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) ConfVars(org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars) ExceptionHandler.newMetaException(org.apache.hadoop.hive.metastore.ExceptionHandler.newMetaException) ExceptionHandler.throwMetaException(org.apache.hadoop.hive.metastore.ExceptionHandler.throwMetaException)

Example 3 with ConfVars

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

the class TestHiveMetaStoreGetMetaConf method testGetMetaConfDefaultEmptyString.

@Test
public void testGetMetaConfDefaultEmptyString() throws TException {
    ConfVars metaConfVar = ConfVars.PARTITION_NAME_WHITELIST_PATTERN;
    String expected = "";
    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 4 with ConfVars

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

the class TestHiveMetaStoreGetMetaConf method testGetMetaConfOverridden.

@Test
public void testGetMetaConfOverridden() throws TException {
    ConfVars metaConfVar = ConfVars.TRY_DIRECT_SQL_DDL;
    String expected = "false";
    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 5 with ConfVars

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

the class HiveMetaStoreClientPreCatalog 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 " + oneVar.toString() + " changed from " + oldVar + " to " + newVar);
            compatible = false;
        }
    }
    return compatible;
}
Also used : 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