Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2014 Microsoft Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 import java.util.List;
An external constructor that creates YarnConfiguration instances.
   private static final Logger LOG = Logger.getLogger(YarnConfigurationConstructor.class.getName());
   private final Optional<PathconfigurationPath;
   private YarnConfigurationConstructor(final Optional<PathconfigurationFilePath) {
     this. = configurationFilePath;
     .log(."Instantiated 'YarnConfigurationConstructor' with path {0}"configurationFilePath);
   public YarnConfiguration newInstance() {
     final YarnConfiguration yarnConfiguration = new YarnConfiguration();
     if (this..isPresent()) {
     // TODO: This should not be needed.
     .log(."Instantiated 'YarnConfiguration' with path [{0}] and contents [{1}] ",
         new Object[]{this.yarnConfiguration});
     return yarnConfiguration;
   public String toString() {
     return "YarnConfigurationConstructor{configurationPath=" + this. + '}';


A Configuration primed with the contents of $HADOOP_HOME/etc/hadoop/*.xml *
   // TODO: This is a hack. Just calling new Configuration(true) should do this, but did not on HDInsight.
   private static Configuration getDefaultConfiguration() throws IOException {
     final Configuration conf = new Configuration(false);
     final File hadoopConfigurationFolder = getHadoopConfFolder();
     final List<FileconfigurationFiles = new ArrayList<>();
     for (final File f : hadoopConfigurationFolder.listFiles()) {
       if (f.isFile() && f.getName().endsWith(".xml")) {
         conf.addResource(new Path(f.getAbsolutePath()));
     return conf;

Finds the folder containing the hadoop configuration files.

the folder containing the hadoop configuration files.
Throws: if the folder can't be found.
   private static File getHadoopConfFolder() throws IOException {
     if (System.getenv().containsKey("HADOOP_CONF_DIR")) {
       return new File(System.getenv("HADOOP_CONF_DIR"));
     } else if (System.getenv().containsKey("HADOOP_HOME")) {
       return new File(System.getenv("HADOOP_HOME") + "/etc/hadoop/");
     } else {
       throw new IOException("Unable to find hadoop configuration folder.");
New to GrepCode? Check out our FAQ X