Skip to content

Commit

Permalink
LIHADOOP-16687 Update Dr. Elephant to use the new Hadoop API
Browse files Browse the repository at this point in the history
RB=636803

G=superfriends-reviewers
R=annag,fli,rratti,viramach
A=rratti
  • Loading branch information
Akshay Rai committed Jan 14, 2016
1 parent ce4abb4 commit ba92a86
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 27 deletions.
4 changes: 2 additions & 2 deletions app/com/linkedin/drelephant/ElephantRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import model.JobResult;

import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.conf.Configuration;
import org.apache.log4j.Logger;


Expand All @@ -49,7 +49,7 @@ public class ElephantRunner implements Runnable {
private AnalyticJobGenerator _analyticJobGenerator;

private void loadAnalyticJobGenerator() {
JobConf configuration = new JobConf();
Configuration configuration = new Configuration();
if (HadoopSystemContext.isHadoop2Env()) {
_analyticJobGenerator = new AnalyticJobGeneratorHadoop2();
} else {
Expand Down
3 changes: 1 addition & 2 deletions app/com/linkedin/drelephant/HadoopSecurity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.linkedin.drelephant;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.log4j.Logger;

Expand All @@ -36,7 +35,7 @@ public class HadoopSecurity {
private boolean _securityEnabled = false;

public HadoopSecurity() throws IOException {
Configuration conf = new JobConf();
Configuration conf = new Configuration();
UserGroupInformation.setConfiguration(conf);
_securityEnabled = UserGroupInformation.isSecurityEnabled();
if (_securityEnabled) {
Expand Down
20 changes: 2 additions & 18 deletions app/com/linkedin/drelephant/analysis/HadoopSystemContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,20 @@
package com.linkedin.drelephant.analysis;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapred.JobConf;

public final class HadoopSystemContext {

private static final String MAPREDUCE_FRAMEWORK_NAME_PROP = "mapreduce.framework.name";
private static final String MAPRED_JOB_TRACKER_PROP = "mapred.job.tracker.http.address";
private static final String YARN = "yarn";
private static final String CLASSIC = "classic";

/**
* Detect if the current Hadoop environment is 1.x
*
* @return true if it is Hadoop 1 env, else false
*/
public static boolean isHadoop1Env() {
Configuration hadoopConf = new JobConf();
String hadoopVersion = hadoopConf.get(MAPREDUCE_FRAMEWORK_NAME_PROP);
if (hadoopVersion == null) {
return hadoopConf.get(MAPRED_JOB_TRACKER_PROP) != null;
}
return hadoopVersion.equals(CLASSIC);
}

/**
* Detect if the current Hadoop environment is 2.x
*
* @return true if it is Hadoop 2 env, else false
*/
public static boolean isHadoop2Env() {
Configuration hadoopConf = new JobConf();
Configuration hadoopConf = new Configuration();
String hadoopVersion = hadoopConf.get(MAPREDUCE_FRAMEWORK_NAME_PROP);
return hadoopVersion != null && hadoopVersion.equals(YARN);
}
Expand All @@ -57,6 +41,6 @@ public static boolean isHadoop2Env() {
* @return true if we have a major version match else false
*/
public static boolean matchCurrentHadoopVersion(int majorVersion) {
return majorVersion == 2 && isHadoop2Env() || majorVersion == 1 && isHadoop1Env();
return majorVersion == 2 && isHadoop2Env();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.authentication.client.AuthenticatedURL;
import org.apache.hadoop.security.authentication.client.AuthenticationException;
import org.apache.log4j.Logger;
Expand All @@ -51,7 +51,7 @@ public class MapReduceFetcherHadoop2 implements ElephantFetcher<MapReduceApplica

public MapReduceFetcherHadoop2() throws IOException {
logger.info("Connecting to the job history server...");
final String jhistoryAddr = new JobConf().get("mapreduce.jobhistory.webapp.address");
final String jhistoryAddr = new Configuration().get("mapreduce.jobhistory.webapp.address");
_urlFactory = new URLFactory(jhistoryAddr);
_jsonFactory = new JSONFactory();
_jhistoryWebAddr = "http://" + jhistoryAddr + "/jobhistory/job/";
Expand Down
4 changes: 1 addition & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ unmanagedClasspath in Compile ++= update.value.select(configurationFilter("compi
libraryDependencies ++= Seq(
"com.linkedin.hadoop" % "hadoop-common" % "2.3.0.+" % "compileonly",
"com.linkedin.hadoop" % "hadoop-hdfs" % "2.3.0.+" % "compileonly",
"com.linkedin.hadoop" % "hadoop-mapreduce-client-core" % "2.3.0.+" % "compileonly",
"com.linkedin.hadoop" % "hadoop-common" % "2.3.0.+" % "test",
"com.linkedin.hadoop" % "hadoop-hdfs" % "2.3.0.+" % "test",
"com.linkedin.hadoop" % "hadoop-mapreduce-client-core" % "2.3.0.+" % "test"
"com.linkedin.hadoop" % "hadoop-hdfs" % "2.3.0.+" % "test"
)

val LinkedInPatterns = Patterns(
Expand Down

0 comments on commit ba92a86

Please sign in to comment.