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 422d29e..db71ca5 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -206,8 +206,7 @@ public class HiveConf extends Configuration { // Properties with null values are ignored and exist only for the purpose of giving us // a symbolic name to reference in the Hive source code. Properties with non-null // values will override any values set in the underlying Hadoop configuration. - HADOOPBIN("hadoop.bin.path", System.getenv("HADOOP_HOME") + "/bin/hadoop"), - HADOOPCONF("hadoop.config.dir", System.getenv("HADOOP_HOME") + "/conf"), + HADOOPBIN("hadoop.bin.path", findHadoopBinary()), HADOOPFS("fs.default.name", null), HIVE_FS_HAR_IMPL("fs.har.impl", "org.apache.hadoop.hive.shims.HiveHarFileSystem"), HADOOPMAPFILENAME("map.input.file", null), @@ -841,14 +840,6 @@ public class HiveConf extends Configuration { addResource(hiveSiteURL); } - // if hadoop configuration files are already in our path - then define - // the containing directory as the configuration directory - URL hadoopconfurl = getClassLoader().getResource("core-site.xml"); - if (hadoopconfurl != null) { - String conffile = hadoopconfurl.getPath(); - this.setVar(ConfVars.HADOOPCONF, conffile.substring(0, conffile.lastIndexOf('/'))); - } - // Overlay the values of any system properties whose names appear in the list of ConfVars applySystemProperties(); @@ -909,6 +900,16 @@ public class HiveConf extends Configuration { } } + private static String findHadoopBinary() { + String val = System.getenv("HADOOP_HOME"); + // In Hadoop 1.X and Hadoop 2.X HADOOP_HOME is gone and replaced with HADOOP_PREFIX + if (val == null) { + val = System.getenv("HADOOP_PREFIX"); + } + // and if all else fails we can at least try /usr/bin/hadoop + return (val == null ? "/usr" : val) + "/bin/hadoop"; + } + public Properties getChangedProperties() { Properties ret = new Properties(); Properties newProp = getAllProperties();