public static boolean isHadoop2Env() {
    Configuration hadoopConf = new Configuration();
    String hadoopVersion = hadoopConf.get(MAPREDUCE_FRAMEWORK_NAME_PROP);
    return hadoopVersion != null && hadoopVersion.equals(YARN);
  }
Detect if the current Hadoop environment is 2.x

@return true if it is Hadoop 2 env, else false
app/com/linkedin/drelephant/analysis/HadoopSystemContext.java