Skip to content

Commit

Permalink
Multiple fixes on Dr. Elephant: (linkedin#159)
Browse files Browse the repository at this point in the history
        * Added not-found page
	* Search panel on pages served by play
	* Piwik integration
  • Loading branch information
nntnag17 authored Nov 7, 2016
1 parent 4fee0b2 commit 9eaefea
Show file tree
Hide file tree
Showing 45 changed files with 500 additions and 101 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ RUNNING_PID
.DS_Store

*.jar

#web
public/assets/ember/
public/assets/fonts/
web/bower_components/
web/node_modules/
96 changes: 73 additions & 23 deletions app/controllers/api/v1/Web.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import models.AppHeuristicResult;
import models.AppHeuristicResultDetails;
import models.AppResult;
Expand Down Expand Up @@ -345,6 +346,7 @@ public static Result restApplicationSummariesForUser(String username) {
* "resourceused": 101382144,
* "resourcewasted": 15993417,
* "severity": "Moderate",
* "scheduler": "azkaban",
* "tasksseverity": [
* {
* "severity": "Moderate",
Expand Down Expand Up @@ -384,6 +386,9 @@ public static Result restJobSummariesForUser(String username) {
String jobName = "";
String user = null;
String queueName = "";
String scheduler = "";
String jobDefId = "";
String jobExecId = "";

Map<Severity, Long> applicationSeverityCount = new HashMap<Severity, Long>();

Expand All @@ -394,8 +399,11 @@ public static Result restJobSummariesForUser(String username) {

jobType = application.jobType;
jobName = application.jobName;
jobDefId = application.jobDefId;
jobExecId = application.jobExecId;

queueName = application.queueName;
scheduler = application.scheduler;

if (application.startTime < jobStartTime) {
jobStartTime = application.startTime;
Expand All @@ -419,14 +427,15 @@ public static Result restJobSummariesForUser(String username) {
}

JsonArray applicationSeverity = new JsonArray();

for (Map.Entry<Severity, Long> entry : applicationSeverityCount.entrySet()) {
List<Severity> keys = getSortedSeverityKeys(applicationSeverityCount.keySet());
for (Severity key: keys) {
JsonObject severityObject = new JsonObject();
severityObject.addProperty(JsonKeys.SEVERITY, entry.getKey().getText());
severityObject.addProperty(JsonKeys.COUNT, entry.getValue());
severityObject.addProperty(JsonKeys.SEVERITY, key.getText());
severityObject.addProperty(JsonKeys.COUNT, applicationSeverityCount.get(key));
applicationSeverity.add(severityObject);
}


totalJobDelay = Utils.getTotalWaittime(jobExecIdToJobsMap.get(jobDefPair));
totalJobRuntime = Utils.getTotalRuntime(jobExecIdToJobsMap.get(jobDefPair));

Expand All @@ -442,7 +451,10 @@ public static Result restJobSummariesForUser(String username) {
jobObject.addProperty(JsonKeys.RESOURCE_USED, totalJobMemoryUsed);
jobObject.addProperty(JsonKeys.RESOURCE_WASTED, totalJobMemoryWasted);
jobObject.addProperty(JsonKeys.QUEUE, queueName);
jobObject.addProperty(JsonKeys.SCHEDULER, scheduler);
jobObject.addProperty(JsonKeys.SEVERITY, jobSeverity.getText());
jobObject.addProperty(JsonKeys.JOB_DEF_ID, jobDefId);
jobObject.addProperty(JsonKeys.JOB_EXEC_ID, jobExecId);

jobObject.add(JsonKeys.TASKS_SEVERITY, applicationSeverity);

Expand Down Expand Up @@ -560,12 +572,11 @@ public static Result restWorkflowSummariesForUser(String username) {
totalFlowRuntime = Utils.getTotalRuntime(flowExecIdToJobsMap.get(flowExecPair));

JsonArray jobSeverity = new JsonArray();

// add severity object
for (Map.Entry<Severity, Long> entry : jobSeverityCount.entrySet()) {
List<Severity> keys = getSortedSeverityKeys(jobSeverityCount.keySet());
for (Severity key: keys) {
JsonObject severityObject = new JsonObject();
severityObject.addProperty(JsonKeys.SEVERITY, entry.getKey().getText());
severityObject.addProperty(JsonKeys.COUNT, entry.getValue());
severityObject.addProperty(JsonKeys.SEVERITY, key.getText());
severityObject.addProperty(JsonKeys.COUNT, jobSeverityCount.get(key));
jobSeverity.add(severityObject);
}

Expand Down Expand Up @@ -645,6 +656,13 @@ public static Result restWorkflowSummariesForUser(String username) {
* </pre>
*/
public static Result restWorkflowFromFlowId(String flowId) {

if (flowId==null || flowId.isEmpty()) {
JsonObject parent = new JsonObject();
parent.add(JsonKeys.WORKFLOWS, new JsonObject());
return notFound(new Gson().toJson(parent));
}

JsonArray jobSeverityArray = new JsonArray();
JsonArray jobSummaryArray = new JsonArray();
JsonObject data = new JsonObject();
Expand All @@ -668,7 +686,7 @@ public static Result restWorkflowFromFlowId(String flowId) {
if (results.isEmpty()) {
JsonObject parent = new JsonObject();
parent.add(JsonKeys.WORKFLOWS, data);
return ok(new Gson().toJson(parent));
return notFound(new Gson().toJson(parent));
}

Map<IdUrlPair, List<AppResult>> jobExecIdToJobsMap =
Expand Down Expand Up @@ -724,12 +742,13 @@ public static Result restWorkflowFromFlowId(String flowId) {
jobSeverityCount.put(jobSeverity, 1L);
}


JsonArray taskSeverity = new JsonArray();
// add severity object
for (Map.Entry<Severity, Long> entry : taskSeverityCount.entrySet()) {
List<Severity> keys = getSortedSeverityKeys(taskSeverityCount.keySet());
for (Severity key: keys) {
JsonObject severityObject = new JsonObject();
severityObject.addProperty(JsonKeys.SEVERITY, entry.getKey().getText());
severityObject.addProperty(JsonKeys.COUNT, entry.getValue());
severityObject.addProperty(JsonKeys.SEVERITY, key.getText());
severityObject.addProperty(JsonKeys.COUNT, taskSeverityCount.get(key));
taskSeverity.add(severityObject);
}

Expand Down Expand Up @@ -771,10 +790,12 @@ public static Result restWorkflowFromFlowId(String flowId) {
}
}// job map scope ends here

for (Map.Entry<Severity, Long> entry : jobSeverityCount.entrySet()) {

List<Severity> keys = getSortedSeverityKeys(jobSeverityCount.keySet());
for (Severity key: keys) {
JsonObject severityObject = new JsonObject();
severityObject.addProperty(JsonKeys.SEVERITY, entry.getKey().getText());
severityObject.addProperty(JsonKeys.COUNT, entry.getValue());
severityObject.addProperty(JsonKeys.SEVERITY, key.getText());
severityObject.addProperty(JsonKeys.COUNT, jobSeverityCount.get(key));
jobSeverityArray.add(severityObject);
}

Expand Down Expand Up @@ -893,6 +914,14 @@ public static Result restWorkflowFromFlowId(String flowId) {
* </pre>
*/
public static Result restJobFromJobId(String jobid) {


if (jobid==null || jobid.isEmpty()) {
JsonObject parent = new JsonObject();
parent.add(JsonKeys.JOBS, new JsonObject());
return notFound(new Gson().toJson(parent));
}

JsonArray taskSummaryArray = new JsonArray();

String jobDefID = jobid;
Expand All @@ -911,13 +940,14 @@ public static Result restJobFromJobId(String jobid) {
String flowDefinitionId = "";
String jobname = "";
String queueName = "";
String scheduler = "";

List<AppResult> results = getRestJobResultsFromJobExecutionId(jobid);

if (results.isEmpty()) {
JsonObject parent = new JsonObject();
parent.add(JsonKeys.JOBS, new JsonObject());
return ok(new Gson().toJson(parent));
return notFound(new Gson().toJson(parent));
}

Map<Severity, Long> taskSeverityCount = new HashMap<Severity, Long>();
Expand All @@ -931,6 +961,7 @@ public static Result restJobFromJobId(String jobid) {
flowExecutionId = task.flowExecId;
flowDefinitionId = task.flowDefId;
queueName = task.queueName;
scheduler = task.scheduler;

JsonObject taskObject = new JsonObject();
JsonArray heuristicsArray = new JsonArray();
Expand Down Expand Up @@ -981,11 +1012,11 @@ public static Result restJobFromJobId(String jobid) {
}

JsonArray taskSeverity = new JsonArray();

for (Map.Entry<Severity, Long> entry : taskSeverityCount.entrySet()) {
List<Severity> keys = getSortedSeverityKeys(taskSeverityCount.keySet());
for (Severity key: keys) {
JsonObject severityObject = new JsonObject();
severityObject.addProperty(JsonKeys.SEVERITY, entry.getKey().getText());
severityObject.addProperty(JsonKeys.COUNT, entry.getValue());
severityObject.addProperty(JsonKeys.SEVERITY, key.getText());
severityObject.addProperty(JsonKeys.COUNT, taskSeverityCount.get(key));
taskSeverity.add(severityObject);
}

Expand All @@ -1008,6 +1039,7 @@ public static Result restJobFromJobId(String jobid) {
data.addProperty(JsonKeys.FLOW_EXEC_ID, flowExecutionId);
data.addProperty(JsonKeys.FLOW_DEF_ID, flowDefinitionId);
data.addProperty(JsonKeys.QUEUE, queueName);
data.addProperty(JsonKeys.SCHEDULER, scheduler);
data.add(JsonKeys.TASKS_SUMMARIES, taskSummaryArray);
data.add(JsonKeys.TASKS_SEVERITY, taskSeverity);

Expand Down Expand Up @@ -1089,6 +1121,13 @@ public static Result restJobFromJobId(String jobid) {
* </pre>
*/
public static Result restApplicationFromApplicationId(String applicationid) {

if (applicationid==null || applicationid.isEmpty()) {
JsonObject parent = new JsonObject();
parent.add(JsonKeys.APPLICATIONS, new JsonObject());
return notFound(new Gson().toJson(parent));
}

JsonObject applicationObject = new JsonObject();
JsonArray heuristicsArray = new JsonArray();

Expand All @@ -1097,7 +1136,7 @@ public static Result restApplicationFromApplicationId(String applicationid) {
if (result == null) {
JsonObject parent = new JsonObject();
parent.add(JsonKeys.APPLICATIONS, new JsonObject());
return ok(new Gson().toJson(parent));
return notFound(new Gson().toJson(parent));
}

for (AppHeuristicResult appHeuristicResult : result.yarnAppHeuristicResults) {
Expand Down Expand Up @@ -1435,4 +1474,15 @@ public int compare(JsonObject a, JsonObject b) {
}
return sortedJsonArray;
}

private static List<Severity> getSortedSeverityKeys(Set<Severity> severities) {
List<Severity> severityList = new ArrayList<Severity>();
severityList.addAll(severities);
Collections.sort(severityList, new Comparator<Severity>() {
public int compare(Severity a, Severity b) {
return b.getValue() - a.getValue();
}
});
return severityList;
}
}
2 changes: 1 addition & 1 deletion app/views/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" type="image/png" href='@routes.Assets.at("images/favicon.png")'>
<title>DrElephant</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand All @@ -36,7 +37,6 @@
<script src="assets/assets/ember/vendor.js"></script>
<script src="assets/assets/ember/dr-elephant.js"></script>


</body>
</html>

12 changes: 10 additions & 2 deletions app/views/newmain.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

</head>

<body role="document">
<body>
<!-- Fixed navbar -->
<div class="navbar-default navbar-inverse navbar-static-top" role="navigation">
<div class="container">
Expand All @@ -59,7 +59,7 @@
<a class="navbar-brand" href="new">Dr Elephant</a>
</div>

<div class="navbar-collapse collapse">
<div class="navbar-collapse collapse" style="float:left">
<ul class="nav navbar-nav">
<li><a href="new" class="active">Dashboard</a></li>
<li><a href="newjobhistory">JobHistory</a></li>
Expand All @@ -69,6 +69,13 @@


</div>
<div class="col-sm-3 col-md-3">
<div class="navbar-form">
<div>
@tags.searchPanel()
</div>
</div>
</div>

</div>
</div>
Expand All @@ -85,6 +92,7 @@
<script src="@routes.Assets.at("assets/bootstrap-datepicker/js/bootstrap-datepicker.js")" type="text/javascript"></script>
<script src="@routes.Assets.at("assets/jquery/jquery.deserialize.min.js")" type="text/javascript"></script>
<script src="@routes.Assets.at("js/searchform.js")" type="text/javascript"></script>
<script src="@routes.Assets.at("js/searchpanel.js")" type="text/javascript"></script>
<script src="@routes.Assets.at("assets/d3/d3.min.js")" type="text/javascript"></script>
@if(analytics) {
<script src="@routes.Assets.at("assets/analytics/track.js")" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion app/views/results/flowHistoryResults.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h4><a href="@flowDefPair.getId()">Flow History</a></h4>
<!-- Performance Score Graph -->
<div class="history-graph">
<img src='@routes.Assets.at("images/loading.gif")' id='loading-indicator' alt='Loading...' class="loading-indicator"/>
<svg class="svg-graph" id="visualisation" ></svg>
<svg class="svg-graph graph-padding" id="visualisation" ></svg>
</div>

<hr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/results/flowMetricsHistoryResults.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h4><a href="@flowDefPair.getId()">Flow History</a></h4>
<!-- Performance Score Graph -->
<div class="history-graph">
<img src='@routes.Assets.at("images/loading.gif")' id='loading-indicator' alt='Loading...' class="loading-indicator"/>
<svg class="svg-graph" id="visualisation" ></svg>
<svg class="svg-graph graph-padding" id="visualisation" ></svg>
</div>

<hr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/results/jobHistoryResults.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h4><a href="@jobDefPair.getId()">Job History</a></h4>
<!-- Performance Score Graph -->
<div class="history-graph">
<img src='@routes.Assets.at("images/loading.gif")' id='loading-indicator' alt='Loading...' class="loading-indicator"/>
<svg class="svg-graph" id="visualisation" ></svg>
<svg class="svg-graph graph-padding" id="visualisation" ></svg>
</div>

<hr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/results/jobMetricsHistoryResults.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h4><a href="@jobDefPair.getId()">Job History</a></h4>
<!-- history graph -->
<div class="history-graph">
<img src='@routes.Assets.at("images/loading.gif")' id='loading-indicator' alt='Loading...' class="loading-indicator"/>
<svg class="svg-graph" id="visualisation" ></svg>
<svg class="svg-graph graph-padding" id="visualisation" ></svg>
</div>

<hr>
Expand Down
40 changes: 40 additions & 0 deletions app/views/tags/searchPanel.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!--
Copyright 2016 LinkedIn Corp.
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
http://www.apache.org/licenses/LICENSE-2.0
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.
-->


<div class="input-group search-top">
<div class="input-group-btn search-panel">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span id="search_concept">Workflow</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a id="workflow_search" class="search_opt" href="javascript:void(0)">Workflow</a></li>
<li><a id="job_search" class="search_opt" href="javascript:void(0)">Job</a></li>
<li><a id="application_search" class="search_opt" href="javascript:void(0)">Application</a></li>
<li class="divider"></li>
<li><a href="/new#/search">Advanced</a></li>
</ul>
</div>

<div>
<input id = "primary_search" type="text" class="form-control" placeholder="Search" enter='search'>
</div>
<span class="input-group-btn">
<button id="search_button" class="btn btn-default" type="button"><span class="glyphicon glyphicon-search"></span></button>
</span>
</div>
Loading

0 comments on commit 9eaefea

Please sign in to comment.