Skip to content

Commit

Permalink
LIHADOOP-17996: Fix potential issues in Dr. Elephant v2.0.1
Browse files Browse the repository at this point in the history
RB=676126

G=superfriends-reviewers
R=annag,fli,shanm,viramch
A=fli
  • Loading branch information
akshayrai committed Mar 8, 2016
1 parent 8afdffa commit 808a58e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
1 change: 0 additions & 1 deletion app/com/linkedin/drelephant/analysis/AnalyticJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ public AppResult getAnalysis() throws Exception {
if (data == null || data.isEmpty()) {
// Example: a MR job has 0 mappers and 0 reducers
logger.info("No Data Received for analytic job: " + getAppId());
HeuristicResult.NO_DATA.addResultDetail("No Data Received", "");
analysisResults.add(HeuristicResult.NO_DATA);
} else {
List<Heuristic> heuristics = ElephantContext.instance().getHeuristicsForApplicationType(getAppType());
Expand Down
23 changes: 21 additions & 2 deletions app/com/linkedin/drelephant/analysis/HeuristicResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.linkedin.drelephant.analysis;

import com.linkedin.drelephant.util.Utils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.StringUtils;

Expand All @@ -27,7 +27,8 @@
* Holds the Heuristic analysis result Information
*/
public class HeuristicResult {
public static final HeuristicResult NO_DATA = new HeuristicResult("NoDataReceived", "No Data Received", Severity.LOW, 0);
public static final HeuristicResult NO_DATA = new HeuristicResult("NoDataReceived", "No Data Received", Severity.LOW,
0, Collections.singletonList(new HeuristicResultDetails("No Data Received", "", null)));

private String _heuristicClass;
private String _heuristicName;
Expand All @@ -51,6 +52,24 @@ public HeuristicResult(String heuristicClass, String heuristicName, Severity sev
this._heuristicResultDetails = new ArrayList<HeuristicResultDetails>();
}

/**
* Heuristic Result Constructor
*
* @param heuristicClass The Heuristic class
* @param heuristicName The name of the Heursitic
* @param severity The severity of the result
* @param score The computed score
* @param heuristicResultDetails more information on the heuristic details.
*/
public HeuristicResult(String heuristicClass, String heuristicName, Severity severity, int score,
List<HeuristicResultDetails> heuristicResultDetails) {
this._heuristicClass = heuristicClass;
this._heuristicName = heuristicName;
this._severity = severity;
this._score = score;
this._heuristicResultDetails = heuristicResultDetails;
}

/**
* Returns the heuristic analyser class name
*
Expand Down
46 changes: 22 additions & 24 deletions app/controllers/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class Application extends Controller {
private static final int REST_PAGE_LENGTH = 100; // Num of jobs in a rest search page
private static final int JOB_HISTORY_LIMIT = 5000; // Set to avoid memory error.
private static final int MAX_HISTORY_LIMIT = 15; // Upper limit on the number of executions to display
private static final int STAGE_LIMIT = 25; // Upper limit on the number of stages to display

// Form and Rest parameters
private static final String APP_ID = "id";
Expand Down Expand Up @@ -457,8 +458,7 @@ public static Result jobHistory() {
.where().eq(AppResult.TABLE.JOB_DEF_ID, jobDefId)
.order().desc(AppResult.TABLE.FINISH_TIME).setMaxRows(JOB_HISTORY_LIMIT)
.fetch(AppResult.TABLE.APP_HEURISTIC_RESULTS, "*")
.fetch(AppResult.TABLE.APP_HEURISTIC_RESULTS + "."
+ AppHeuristicResult.TABLE.APP_HEURISTIC_RESULT_DETAILS, "*")
.fetch(AppResult.TABLE.APP_HEURISTIC_RESULTS + "." + AppHeuristicResult.TABLE.APP_HEURISTIC_RESULT_DETAILS, "*")
.findList();
if (results.size() == 0) {
return notFound("Unable to find record on job url: " + jobDefId);
Expand Down Expand Up @@ -487,6 +487,9 @@ public static Result jobHistory() {

executionMap.put(entry.getKey(), Lists.reverse(flowExecIdToJobsMap.get(entry.getKey())));
}
if (maxStages > STAGE_LIMIT) {
maxStages = STAGE_LIMIT;
}

return ok(jobHistoryPage.render(jobHistoryResults.render(jobDefId, executionMap, maxStages, flowExecTimeList)));
}
Expand Down Expand Up @@ -633,12 +636,15 @@ public static Result restAppResult(String id) {

AppResult result = AppResult.find.select("*")
.fetch(AppResult.TABLE.APP_HEURISTIC_RESULTS, "*")
.fetch(AppResult.TABLE.APP_HEURISTIC_RESULTS + "."
+ AppHeuristicResult.TABLE.APP_HEURISTIC_RESULT_DETAILS, "*")
.fetch(AppResult.TABLE.APP_HEURISTIC_RESULTS + "." + AppHeuristicResult.TABLE.APP_HEURISTIC_RESULT_DETAILS, "*")
.where()
.idEq(id).findUnique();

return ok(Json.toJson(result));
if (result != null) {
return ok(Json.toJson(result));
} else {
return notFound("Unable to find record on id: " + id);
}
}

/**
Expand Down Expand Up @@ -788,7 +794,11 @@ public static Result restSearch() {
+ AppHeuristicResult.TABLE.APP_HEURISTIC_RESULT_DETAILS, "*")
.where().eq(AppResult.TABLE.FLOW_EXEC_ID, flowExecId)
.findList();
return ok(Json.toJson(results));
if (results.size() == 0) {
return notFound("Unable to find record on flow execution: " + flowExecId);
} else {
return ok(Json.toJson(results));
}
}

int page = 1;
Expand All @@ -808,7 +818,12 @@ public static Result restSearch() {
.fetch(AppResult.TABLE.APP_HEURISTIC_RESULTS, "*")
.fetch(AppResult.TABLE.APP_HEURISTIC_RESULTS + "." + AppHeuristicResult.TABLE.APP_HEURISTIC_RESULT_DETAILS, "*")
.findList();
return ok(Json.toJson(results));

if (results.size() == 0) {
return notFound("No records");
} else {
return ok(Json.toJson(results));
}
}

/**
Expand Down Expand Up @@ -1058,21 +1073,4 @@ public static Result restJobGraphData(String jobDefId) {

return ok(new Gson().toJson(datasets));
}

public static Result testEmail() {

DynamicForm form = Form.form().bindFromRequest(request());
String appId = form.get(APP_ID);
if (appId.contains("job")) {
appId = appId.replaceAll("job", "application");
}
if (appId != null && !appId.isEmpty()) {
AppResult result = AppResult.find.byId(appId);
if (result != null) {
return ok(emailcritical.render(result));
}
}
return notFound();
}

}
1 change: 0 additions & 1 deletion conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# Application calls
GET / controllers.Application.dashboard()
GET /help controllers.Application.help()
GET /email controllers.Application.testEmail()
GET /search controllers.Application.search()
GET /compare controllers.Application.compare()
GET /flowhistory controllers.Application.flowHistory()
Expand Down

0 comments on commit 808a58e

Please sign in to comment.