@Test public void testLoadHadoopConfFiles() { String confPath = "src/test/resources/conf/example_conf/"; Configuration conf = ConfigurationUtil.generateConfig(confPath); System.out.println(" works? " + conf.get("fs.default.name")); }
public static Configuration generateConfig(String baseConfPath) { String baseConfPathTrimmed = baseConfPath.trim(); if (false == "/".equals(baseConfPathTrimmed.endsWith("/"))) { baseConfPathTrimmed += "/"; } Configuration conf = new Configuration(); conf.addResource(new Path(baseConfPathTrimmed + "core-site.xml")); conf.addResource(new Path(baseConfPathTrimmed + "hdfs-site.xml")); conf.addResource(new Path(baseConfPathTrimmed + "mapred-site.xml")); return conf; }
ConfigurationUtil { public static Configuration generateConfig(String baseConfPath) { String baseConfPathTrimmed = baseConfPath.trim(); if (false == "/".equals(baseConfPathTrimmed.endsWith("/"))) { baseConfPathTrimmed += "/"; } Configuration conf = new Configuration(); conf.addResource(new Path(baseConfPathTrimmed + "core-site.xml")); conf.addResource(new Path(baseConfPathTrimmed + "hdfs-site.xml")); conf.addResource(new Path(baseConfPathTrimmed + "mapred-site.xml")); return conf; } }
ConfigurationUtil { public static Configuration generateConfig(String baseConfPath) { String baseConfPathTrimmed = baseConfPath.trim(); if (false == "/".equals(baseConfPathTrimmed.endsWith("/"))) { baseConfPathTrimmed += "/"; } Configuration conf = new Configuration(); conf.addResource(new Path(baseConfPathTrimmed + "core-site.xml")); conf.addResource(new Path(baseConfPathTrimmed + "hdfs-site.xml")); conf.addResource(new Path(baseConfPathTrimmed + "mapred-site.xml")); return conf; }  }
ConfigurationUtil { public static Configuration generateConfig(String baseConfPath) { String baseConfPathTrimmed = baseConfPath.trim(); if (false == "/".equals(baseConfPathTrimmed.endsWith("/"))) { baseConfPathTrimmed += "/"; } Configuration conf = new Configuration(); conf.addResource(new Path(baseConfPathTrimmed + "core-site.xml")); conf.addResource(new Path(baseConfPathTrimmed + "hdfs-site.xml")); conf.addResource(new Path(baseConfPathTrimmed + "mapred-site.xml")); return conf; }  static Configuration generateConfig(String baseConfPath); }
ConfigurationUtil { public static Configuration generateConfig(String baseConfPath) { String baseConfPathTrimmed = baseConfPath.trim(); if (false == "/".equals(baseConfPathTrimmed.endsWith("/"))) { baseConfPathTrimmed += "/"; } Configuration conf = new Configuration(); conf.addResource(new Path(baseConfPathTrimmed + "core-site.xml")); conf.addResource(new Path(baseConfPathTrimmed + "hdfs-site.xml")); conf.addResource(new Path(baseConfPathTrimmed + "mapred-site.xml")); return conf; }  static Configuration generateConfig(String baseConfPath);  }