Repository: hive Updated Branches: refs/heads/master aa3a56193 -> 59cf159a7
HIVE-19767: HiveServer2 should take hiveconf for non Hive properties (Szehon Ho, reviewed by Aihua Xu) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/59cf159a Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/59cf159a Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/59cf159a Branch: refs/heads/master Commit: 59cf159a795435b2e72bc0167c7fe85b762a8305 Parents: aa3a561 Author: Szehon Ho <[email protected]> Authored: Fri Aug 17 11:32:50 2018 +0200 Committer: Szehon Ho <[email protected]> Committed: Fri Aug 17 11:32:50 2018 +0200 ---------------------------------------------------------------------- .../java/org/apache/hadoop/hive/conf/HiveConf.java | 14 ++++++++++++-- .../org/apache/hive/service/server/HiveServer2.java | 2 +- .../service/server/TestServerOptionsProcessor.java | 5 +++-- 3 files changed, 16 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/59cf159a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java ---------------------------------------------------------------------- diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index d406f51..402d66d 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -421,6 +421,7 @@ public class HiveConf extends Configuration { * 1) Hadoop configuration properties are applied. * 2) ConfVar properties with non-null values are overlayed. * 3) hive-site.xml properties are overlayed. + * 4) System Properties and Manual Overrides are overlayed. * * WARNING: think twice before adding any Hadoop configuration properties * with non-null values to this list as they will override any values defined @@ -5242,7 +5243,7 @@ public class HiveConf extends Configuration { addResource(hiveServer2SiteUrl); } - // Overlay the values of any system properties whose names appear in the list of ConfVars + // Overlay the values of any system properties and manual overrides applySystemProperties(); if ((this.get("hive.metastore.ds.retry.attempts") != null) || @@ -5509,7 +5510,9 @@ public class HiveConf extends Configuration { }; - + //Take care of conf overrides. + //Includes values in ConfVars as well as underlying configuration properties (ie, hadoop) + public static final Map<String, String> overrides = new HashMap<String, String>(); /** * Apply system properties to this object if the property name is defined in ConfVars @@ -5537,6 +5540,13 @@ public class HiveConf extends Configuration { } } + for (Map.Entry<String, String> oneVar : overrides.entrySet()) { + if (overrides.get(oneVar.getKey()) != null) { + if (overrides.get(oneVar.getKey()).length() > 0) { + systemProperties.put(oneVar.getKey(), oneVar.getValue()); + } + } + } return systemProperties; } http://git-wip-us.apache.org/repos/asf/hive/blob/59cf159a/service/src/java/org/apache/hive/service/server/HiveServer2.java ---------------------------------------------------------------------- diff --git a/service/src/java/org/apache/hive/service/server/HiveServer2.java b/service/src/java/org/apache/hive/service/server/HiveServer2.java index c4d110e..1f8dc6d 100644 --- a/service/src/java/org/apache/hive/service/server/HiveServer2.java +++ b/service/src/java/org/apache/hive/service/server/HiveServer2.java @@ -1229,7 +1229,7 @@ public class HiveServer2 extends CompositeService { + " or use the set the value in the configuration file" + " (see HIVE-19886)"); } - System.setProperty(propKey, confProps.getProperty(propKey)); + HiveConf.overrides.put(propKey, confProps.getProperty(propKey)); } // Process --help http://git-wip-us.apache.org/repos/asf/hive/blob/59cf159a/service/src/test/org/apache/hive/service/server/TestServerOptionsProcessor.java ---------------------------------------------------------------------- diff --git a/service/src/test/org/apache/hive/service/server/TestServerOptionsProcessor.java b/service/src/test/org/apache/hive/service/server/TestServerOptionsProcessor.java index d5e4ed6..652483a 100644 --- a/service/src/test/org/apache/hive/service/server/TestServerOptionsProcessor.java +++ b/service/src/test/org/apache/hive/service/server/TestServerOptionsProcessor.java @@ -18,6 +18,7 @@ package org.apache.hive.service.server; +import org.apache.hadoop.hive.conf.HiveConf; import org.junit.Assert; import org.junit.Test; @@ -39,14 +40,14 @@ public class TestServerOptionsProcessor { Assert.assertEquals( "checking system property before processing options", null, - System.getProperty(key)); + HiveConf.overrides.get(key)); optProcessor.parse(args); Assert.assertEquals( "checking system property after processing options", value, - System.getProperty(key)); + HiveConf.overrides.get(key)); } }
