diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java index ffb2abdf62..b8bb1d9f06 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java @@ -531,9 +531,9 @@ private static Properties getDataSourceProps(Configuration 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); - Object prevVal = prop.setProperty(var.varname, confVal); - if (LOG.isDebugEnabled() && MetastoreConf.isPrintable(var.varname)) { - LOG.debug("Overriding " + var.varname + " value " + prevVal + Object prevVal = prop.setProperty(var.getVarname(), confVal); + if (LOG.isDebugEnabled() && MetastoreConf.isPrintable(var.getVarname())) { + LOG.debug("Overriding " + var.getVarname() + " value " + prevVal + " from jpox.properties with " + confVal); } } @@ -561,7 +561,7 @@ private static Properties getDataSourceProps(Configuration conf) { String passwd = MetastoreConf.getPassword(conf, MetastoreConf.ConfVars.PWD); if (passwd != null && !passwd.isEmpty()) { // We can get away with the use of varname here because varname == hiveName for PWD - prop.setProperty(ConfVars.PWD.varname, passwd); + prop.setProperty(ConfVars.PWD.getVarname(), passwd); } } catch (IOException err) { throw new RuntimeException("Error getting metastore password: " + err.getMessage(), err); diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java index df2453b115..4672e5525f 100755 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java @@ -77,7 +77,7 @@ public Warehouse(Configuration conf) throws MetaException { this.conf = conf; whRootString = MetastoreConf.getVar(conf, ConfVars.WAREHOUSE); if (StringUtils.isBlank(whRootString)) { - throw new MetaException(ConfVars.WAREHOUSE.varname + throw new MetaException(ConfVars.WAREHOUSE.getVarname() + " is not set in the config or blank"); } fsHandler = getMetaStoreFsHandler(conf); diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java index 5933318e64..ba58ae490f 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java @@ -42,6 +42,21 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * A set of definitions of config values used by the Metastore. One of the key aims of this + * class is to provide backwards compatibility with existing Hive configuration keys while + * allowing the metastore to have its own, Hive independant keys. For this reason access to the + * underlying Configuration object should always be done via the static methods provided here + * rather than directly via {@link Configuration#get(String)} and + * {@link Configuration#set(String, String)}. All the methods of this class will handle checking + * both the MetastoreConf key and the Hive key. The algorithm is, on reads, to check first the + * MetastoreConf key, then the Hive key, then return the default if neither are set. On write + * the Metastore key only is set. + * + * This class does not extend Configuration. Rather it provides static methods for operating on + * a Configuration object. This allows it to work on HiveConf objects, which otherwise would not + * be the case. + */ public class MetastoreConf { private static final Logger LOG = LoggerFactory.getLogger(MetastoreConf.class); @@ -772,11 +787,11 @@ public static ConfVars getMetaConf(String name) { BOOLEAN_TEST_ENTRY("test.bool", "hive.test.bool", true, "comment"), CLASS_TEST_ENTRY("test.class", "hive.test.class", "", "comment"); - public final String varname; - public final String hiveName; - public final Object defaultVal; - public final Validator validator; - public final boolean caseSensitive; + private final String varname; + private final String hiveName; + private final Object defaultVal; + private final Validator validator; + private final boolean caseSensitive; ConfVars(String varname, String hiveName, String defaultVal, String comment) { this.varname = varname; @@ -864,6 +879,30 @@ public boolean isCaseSensitive() { return caseSensitive; } + /** + * If you are calling this, you're probably doing it wrong. You shouldn't need to use the + * underlying variable name. Use one of the getVar methods instead. Only use this if you + * are 100% sure you know you're doing. The reason for this is that MetastoreConf goes to a + * lot of trouble to make sure it checks both Hive and Metastore values for config keys. If + * you call conf.get(varname) you are undermining that. + * @return variable name + */ + public String getVarname() { + return varname; + } + + /** + * If you are calling this, you're probably doing it wrong. You shouldn't need to use the + * underlying variable name. Use one of the getVar methods instead. Only use this if you + * are 100% sure you know you're doing. The reason for this is that MetastoreConf goes to a + * lot of trouble to make sure it checks both Hive and Metastore values for config keys. If + * you call conf.get(hivename) you are undermining that. + * @return variable hive name + */ + public String getHiveName() { + return hiveName; + } + @Override public String toString() { return varname; diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/datasource/BoneCPDataSourceProvider.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/datasource/BoneCPDataSourceProvider.java index 6a2f7704d3..4ff2bb77d3 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/datasource/BoneCPDataSourceProvider.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/datasource/BoneCPDataSourceProvider.java @@ -80,8 +80,7 @@ public boolean mayReturnClosedConnection() { @Override public boolean supports(Configuration configuration) { - String poolingType = - MetastoreConf.getVar(configuration, + String poolingType = MetastoreConf.getVar(configuration, MetastoreConf.ConfVars.CONNECTION_POOLING_TYPE).toLowerCase(); if (BONECP.equals(poolingType)) { int boneCpPropsNr = DataSourceProvider.getPrefixedProperties(configuration, BONECP).size(); diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java index 9fc369754c..6ffc24a27a 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java @@ -75,8 +75,7 @@ public boolean mayReturnClosedConnection() { @Override public boolean supports(Configuration configuration) { - String poolingType = - MetastoreConf.getVar(configuration, + String poolingType = MetastoreConf.getVar(configuration, MetastoreConf.ConfVars.CONNECTION_POOLING_TYPE).toLowerCase(); if (HIKARI.equals(poolingType)) { int hikariPropsNr = DataSourceProvider.getPrefixedProperties(configuration, HIKARI).size(); diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/metrics/Metrics.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/metrics/Metrics.java index c0b1ebc39a..b081026467 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/metrics/Metrics.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/metrics/Metrics.java @@ -173,15 +173,15 @@ private Metrics(Configuration conf) { */ // Check our config value first. I'm explicitly avoiding getting the default value for now, // as I don't want our default to override a Hive set value. - String reportersToStart = conf.get(MetastoreConf.ConfVars.METRICS_REPORTERS.varname); + String reportersToStart = conf.get(MetastoreConf.ConfVars.METRICS_REPORTERS.getVarname()); if (reportersToStart == null) { // Now look in the current Hive config value. Again, avoiding getting defaults reportersToStart = - conf.get(MetastoreConf.ConfVars.HIVE_CODAHALE_METRICS_REPORTER_CLASSES.hiveName); + conf.get(MetastoreConf.ConfVars.HIVE_CODAHALE_METRICS_REPORTER_CLASSES.getHiveName()); if (reportersToStart == null) { // Last chance, look in the old Hive config value. Still avoiding defaults. reportersToStart = - conf.get(MetastoreConf.ConfVars.HIVE_METRICS_REPORTER.hiveName); + conf.get(MetastoreConf.ConfVars.HIVE_METRICS_REPORTER.getHiveName()); if (reportersToStart == null) { // Alright fine, we'll use our defaults reportersToStart = MetastoreConf.getVar(conf, MetastoreConf.ConfVars.METRICS_REPORTERS); diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/security/DelegationTokenTool.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/security/DelegationTokenTool.java index 2bcb2b6416..9ac2d64758 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/security/DelegationTokenTool.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/security/DelegationTokenTool.java @@ -192,7 +192,8 @@ private void init() throws Exception { Configuration conf = new Configuration(); conf.addResource(new Path(confLocation)); - String tokenStoreClassName = conf.get(MetastoreConf.ConfVars.DELEGATION_TOKEN_STORE_CLS.varname, ""); + String tokenStoreClassName = + MetastoreConf.getVar(conf,MetastoreConf.ConfVars.DELEGATION_TOKEN_STORE_CLS, ""); if (StringUtils.isBlank(tokenStoreClassName)) { throw new Exception("Could not find Delegation TokenStore implementation."); } diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/tools/HiveSchemaHelper.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/tools/HiveSchemaHelper.java index 4ba11b8abd..08a3af5e02 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/tools/HiveSchemaHelper.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/tools/HiveSchemaHelper.java @@ -90,9 +90,9 @@ public static Connection getConnectionToMetastore(MetaStoreConnectionInfo info) public static String getValidConfVar(MetastoreConf.ConfVars confVar, Configuration conf) throws IOException { - String confVarStr = conf.get(confVar.varname); + String confVarStr = MetastoreConf.getAsString(conf, confVar); if (confVarStr == null || confVarStr.isEmpty()) { - throw new IOException("Empty " + confVar.varname); + throw new IOException("Empty " + confVar.getVarname()); } return confVarStr.trim(); } diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java index e676b91a70..7f1b331ff3 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java @@ -792,9 +792,9 @@ private int getFailedCompactionRetention() { int failedThreshold = MetastoreConf.getIntVar(conf, ConfVars.COMPACTOR_INITIATOR_FAILED_THRESHOLD); int failedRetention = MetastoreConf.getIntVar(conf, ConfVars.COMPACTOR_HISTORY_RETENTION_FAILED); if(failedRetention < failedThreshold) { - LOG.warn("Invalid configuration " + ConfVars.COMPACTOR_INITIATOR_FAILED_THRESHOLD.varname + + LOG.warn("Invalid configuration " + ConfVars.COMPACTOR_INITIATOR_FAILED_THRESHOLD.getVarname() + "=" + failedRetention + " < " + ConfVars.COMPACTOR_HISTORY_RETENTION_FAILED + "=" + - failedRetention + ". Will use " + ConfVars.COMPACTOR_INITIATOR_FAILED_THRESHOLD.varname + + failedRetention + ". Will use " + ConfVars.COMPACTOR_INITIATOR_FAILED_THRESHOLD.getVarname() + "=" + failedRetention); failedRetention = failedThreshold; } diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java index 7087b03296..ec1a98828e 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java @@ -3570,7 +3570,7 @@ public Connection getConnection(String username, String password) throws SQLExce String driverName = MetastoreConf.getVar(conf, ConfVars.CONNECTION_DRIVER); if (driverName == null || driverName.equals("")) { String msg = "JDBC driver for transaction db not set in configuration " + - "file, need to set " + ConfVars.CONNECTION_DRIVER.varname; + "file, need to set " + ConfVars.CONNECTION_DRIVER.getVarname(); LOG.error(msg); throw new RuntimeException(msg); } diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnUtils.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnUtils.java index 2eb967eda4..2f01233f42 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnUtils.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnUtils.java @@ -236,12 +236,12 @@ public static void buildQueryWithINClause(Configuration conf, if (querySize > maxQueryLength * 1024) { // Check an edge case where the DIRECT_SQL_MAX_QUERY_LENGTH does not allow one 'IN' clause with single value. if (cursor4queryOfInClauses == 1 && cursor4InClauseElements == 0) { - throw new IllegalArgumentException("The current " + ConfVars.DIRECT_SQL_MAX_QUERY_LENGTH.varname + " is set too small to have one IN clause with single value!"); + throw new IllegalArgumentException("The current " + ConfVars.DIRECT_SQL_MAX_QUERY_LENGTH.getVarname() + " is set too small to have one IN clause with single value!"); } // Check en edge case to throw Exception if we can not build a single query for 'NOT IN' clause cases as mentioned at the method comments. if (notIn) { - throw new IllegalArgumentException("The NOT IN list has too many elements for the current " + ConfVars.DIRECT_SQL_MAX_QUERY_LENGTH.varname + "!"); + throw new IllegalArgumentException("The NOT IN list has too many elements for the current " + ConfVars.DIRECT_SQL_MAX_QUERY_LENGTH.getVarname() + "!"); } // Wrap up the current query string since we can not add another "inList" element value. diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java index 77790adfff..5cae281364 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java @@ -251,7 +251,7 @@ public static void validatePartitionNameCharacters(List partVals, throw new MetaException("Partition value '" + invalidPartitionVal + "' contains a character " + "not matched by whitelist pattern '" + partitionValidationPattern.toString() + "'. " + "(configure with " + - MetastoreConf.ConfVars.PARTITION_NAME_WHITELIST_PATTERN.varname + ")"); + MetastoreConf.ConfVars.PARTITION_NAME_WHITELIST_PATTERN.getVarname() + ")"); } } diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java index 9aff091029..62335c62c3 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java @@ -49,7 +49,7 @@ @After public void unsetProperties() { for (MetastoreConf.ConfVars var : MetastoreConf.dataNucleusAndJdoConfs) { - System.getProperties().remove(var.varname); + System.getProperties().remove(var.getVarname()); } } @@ -130,8 +130,8 @@ public void defaults() { Assert.assertTrue(list.contains("c")); Assert.assertSame(TestClass1.class, MetastoreConf.getClass(conf, ConfVars.CLASS_TEST_ENTRY, TestClass1.class, Runnable.class)); - Assert.assertEquals("defaultval", MetastoreConf.get(conf, ConfVars.STR_TEST_ENTRY.varname)); - Assert.assertEquals("defaultval", MetastoreConf.get(conf, ConfVars.STR_TEST_ENTRY.hiveName)); + Assert.assertEquals("defaultval", MetastoreConf.get(conf, ConfVars.STR_TEST_ENTRY.getVarname())); + Assert.assertEquals("defaultval", MetastoreConf.get(conf, ConfVars.STR_TEST_ENTRY.getHiveName())); Assert.assertEquals("defaultval", MetastoreConf.getAsString(conf, ConfVars.STR_TEST_ENTRY)); Assert.assertEquals("42", MetastoreConf.getAsString(conf, ConfVars.LONG_TEST_ENTRY)); Assert.assertEquals("3.141592654", MetastoreConf.getAsString(conf, ConfVars.DOUBLE_TEST_ENTRY)); @@ -165,8 +165,8 @@ public void readMetastoreSiteWithMetastoreConfDir() throws IOException { Assert.assertTrue(list.contains("e")); Assert.assertSame(TestClass2.class, MetastoreConf.getClass(conf, ConfVars.CLASS_TEST_ENTRY, TestClass1.class, Runnable.class)); - Assert.assertEquals("1.8", MetastoreConf.get(conf, ConfVars.DOUBLE_TEST_ENTRY.varname)); - Assert.assertEquals("1.8", MetastoreConf.get(conf, ConfVars.DOUBLE_TEST_ENTRY.hiveName)); + Assert.assertEquals("1.8", MetastoreConf.get(conf, ConfVars.DOUBLE_TEST_ENTRY.getVarname())); + Assert.assertEquals("1.8", MetastoreConf.get(conf, ConfVars.DOUBLE_TEST_ENTRY.getHiveName())); Assert.assertEquals("notthedefault", MetastoreConf.getAsString(conf, ConfVars.STR_TEST_ENTRY)); Assert.assertEquals("37", MetastoreConf.getAsString(conf, ConfVars.LONG_TEST_ENTRY)); Assert.assertEquals("1.8", MetastoreConf.getAsString(conf, ConfVars.DOUBLE_TEST_ENTRY)); @@ -243,11 +243,11 @@ public void setAndRead() throws IOException { @Test public void valuesSetFromProperties() { try { - System.setProperty(MetastoreConf.ConfVars.STR_TEST_ENTRY.varname, "from-properties"); + System.setProperty(MetastoreConf.ConfVars.STR_TEST_ENTRY.getVarname(), "from-properties"); conf = MetastoreConf.newMetastoreConf(); Assert.assertEquals("from-properties", MetastoreConf.getVar(conf, ConfVars.STR_TEST_ENTRY)); } finally { - System.getProperties().remove(MetastoreConf.ConfVars.STR_TEST_ENTRY.varname); + System.getProperties().remove(MetastoreConf.ConfVars.STR_TEST_ENTRY.getVarname()); } } @@ -289,8 +289,8 @@ public void hiveNames() throws IOException { Assert.assertTrue(list.contains("j")); Assert.assertSame(TestClass2.class, MetastoreConf.getClass(conf, ConfVars.CLASS_TEST_ENTRY, TestClass1.class, Runnable.class)); - Assert.assertEquals("3s", MetastoreConf.get(conf, ConfVars.TIME_TEST_ENTRY.varname)); - Assert.assertEquals("3s", MetastoreConf.get(conf, ConfVars.TIME_TEST_ENTRY.hiveName)); + Assert.assertEquals("3s", MetastoreConf.get(conf, ConfVars.TIME_TEST_ENTRY.getVarname())); + Assert.assertEquals("3s", MetastoreConf.get(conf, ConfVars.TIME_TEST_ENTRY.getHiveName())); Assert.assertEquals("hivedefault", MetastoreConf.getAsString(conf, ConfVars.STR_TEST_ENTRY)); Assert.assertEquals("89", MetastoreConf.getAsString(conf, ConfVars.LONG_TEST_ENTRY)); Assert.assertEquals("1.9", MetastoreConf.getAsString(conf, ConfVars.DOUBLE_TEST_ENTRY)); @@ -301,52 +301,52 @@ public void hiveNames() throws IOException { public void timeUnits() throws IOException { conf = MetastoreConf.newMetastoreConf(); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30s"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30s"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.SECONDS)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30seconds"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30seconds"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.SECONDS)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30ms"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30ms"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.MILLISECONDS)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30msec"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30msec"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.MILLISECONDS)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30us"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30us"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.MICROSECONDS)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30usec"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30usec"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.MICROSECONDS)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30m"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30m"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.MINUTES)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30minutes"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30minutes"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.MINUTES)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30ns"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30ns"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.NANOSECONDS)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30nsec"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30nsec"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.NANOSECONDS)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30h"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30h"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.HOURS)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30hours"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30hours"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.HOURS)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30d"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30d"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.DAYS)); - conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.varname, "30days"); + conf.set(MetastoreConf.ConfVars.TIME_TEST_ENTRY.getVarname(), "30days"); Assert.assertEquals(30, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.DAYS)); } @@ -401,9 +401,9 @@ public void timeOutsideExclusive() { @Test public void unprintable() { - Assert.assertTrue(MetastoreConf.isPrintable(ConfVars.STR_TEST_ENTRY.varname)); - Assert.assertFalse(MetastoreConf.isPrintable(ConfVars.PWD.varname)); - Assert.assertFalse(MetastoreConf.isPrintable(ConfVars.PWD.hiveName)); + Assert.assertTrue(MetastoreConf.isPrintable(ConfVars.STR_TEST_ENTRY.getVarname())); + Assert.assertFalse(MetastoreConf.isPrintable(ConfVars.PWD.getVarname())); + Assert.assertFalse(MetastoreConf.isPrintable(ConfVars.PWD.getHiveName())); } @Test @@ -426,6 +426,6 @@ public void dumpConfig() throws IOException { Assert.assertThat(dump, new StringContains("Key: old hive key: value: ")); Assert.assertThat(dump, new StringEndsWith("Finished MetastoreConf object.\n")); // Make sure the hidden keys didn't get published - Assert.assertThat(dump, CoreMatchers.not(new StringContains(ConfVars.PWD.varname))); + Assert.assertThat(dump, CoreMatchers.not(new StringContains(ConfVars.PWD.getVarname()))); } } diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/metrics/TestMetrics.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/metrics/TestMetrics.java index ebffef72ae..173f5118c6 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/metrics/TestMetrics.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/metrics/TestMetrics.java @@ -81,7 +81,7 @@ public void allReportersHiveConfig() throws Exception { String jsonFile = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "TestMetricsOutput.json"; Configuration conf = MetastoreConf.newMetastoreConf(); - conf.set(MetastoreConf.ConfVars.HIVE_CODAHALE_METRICS_REPORTER_CLASSES.hiveName, + conf.set(MetastoreConf.ConfVars.HIVE_CODAHALE_METRICS_REPORTER_CLASSES.getHiveName(), "org.apache.hadoop.hive.common.metrics.metrics2.JsonFileMetricsReporter," + "org.apache.hadoop.hive.common.metrics.metrics2.JmxMetricsReporter," + "org.apache.hadoop.hive.common.metrics.metrics2.ConsoleMetricsReporter," + @@ -98,7 +98,7 @@ public void allReportersOldHiveConfig() throws Exception { String jsonFile = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "TestMetricsOutput.json"; Configuration conf = MetastoreConf.newMetastoreConf(); - conf.set(MetastoreConf.ConfVars.HIVE_METRICS_REPORTER.hiveName, + conf.set(MetastoreConf.ConfVars.HIVE_METRICS_REPORTER.getHiveName(), "JSON_FILE,JMX,CONSOLE,HADOOP2"); MetastoreConf.setVar(conf, MetastoreConf.ConfVars.METRICS_JSON_FILE_LOCATION, jsonFile);