List of usage examples for org.apache.hadoop.util Shell getHadoopHome
public static String getHadoopHome() throws IOException
From source file:eu.stratosphere.yarn.Utils.java
License:Apache License
public static Configuration initializeYarnConfiguration() { Configuration conf = new YarnConfiguration(); String configuredHadoopConfig = GlobalConfiguration.getString(ConfigConstants.PATH_HADOOP_CONFIG, null); if (configuredHadoopConfig != null) { LOG.info("Using hadoop configuration path from " + ConfigConstants.PATH_HADOOP_CONFIG + " setting."); addPathToConfig(conf, new File(configuredHadoopConfig)); setDefaultConfValues(conf);/*from w w w. j ava 2s .c o m*/ return conf; } String[] envs = { "YARN_CONF_DIR", "HADOOP_CONF_DIR", "HADOOP_CONF_PATH" }; for (int i = 0; i < envs.length; ++i) { String confPath = System.getenv(envs[i]); if (confPath != null) { LOG.info("Found " + envs[i] + ", adding it to configuration"); addPathToConfig(conf, new File(confPath)); setDefaultConfValues(conf); return conf; } } LOG.info("Could not find HADOOP_CONF_PATH, using HADOOP_HOME."); String hadoopHome = null; try { hadoopHome = Shell.getHadoopHome(); } catch (IOException e) { LOG.fatal("Unable to get hadoop home. Please set HADOOP_HOME variable!", e); System.exit(1); } File tryConf = new File(hadoopHome + "/etc/hadoop"); if (tryConf.exists()) { LOG.info("Found configuration using hadoop home."); addPathToConfig(conf, tryConf); } else { tryConf = new File(hadoopHome + "/conf"); if (tryConf.exists()) { addPathToConfig(conf, tryConf); } } setDefaultConfValues(conf); return conf; }
From source file:org.apache.atlas.web.listeners.LoginProcessor.java
License:Apache License
/** * Uses a hadoop shell to discern whether a hadoop cluster is available/configured. * @return true if a hadoop cluster is detected. *//* ww w. ja v a 2 s.co m*/ protected boolean isHadoopCluster() { boolean isHadoopCluster = false; try { isHadoopCluster = Shell.getHadoopHome() != null; } catch (IOException e) { // ignore - false is default setting } return isHadoopCluster; }