MAPREDUCE-6364. Add a Kill link to Task Attempts page. Contributed by Ryu Kobayashi.
(cherry picked from commit 022f49d59e
)
This commit is contained in:
parent
cf5c1adf4f
commit
e694c3339e
|
@ -9,6 +9,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
MAPREDUCE-6284. Add Task Attempt State API to MapReduce Application
|
MAPREDUCE-6284. Add Task Attempt State API to MapReduce Application
|
||||||
Master REST API. (Ryu Kobayashi via ozawa)
|
Master REST API. (Ryu Kobayashi via ozawa)
|
||||||
|
|
||||||
|
MAPREDUCE-6364. Add a "Kill" link to Task Attempts page. (Ryu Kobayashi
|
||||||
|
via ozawa)
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
|
|
||||||
MAPREDUCE-6291. Correct mapred queue usage command.
|
MAPREDUCE-6291. Correct mapred queue usage command.
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId;
|
import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId;
|
||||||
import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState;
|
import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState;
|
||||||
import org.apache.hadoop.mapreduce.v2.api.records.TaskType;
|
import org.apache.hadoop.mapreduce.v2.api.records.TaskType;
|
||||||
|
@ -40,8 +41,8 @@ import com.google.inject.Inject;
|
||||||
public class AttemptsPage extends TaskPage {
|
public class AttemptsPage extends TaskPage {
|
||||||
static class FewAttemptsBlock extends TaskPage.AttemptsBlock {
|
static class FewAttemptsBlock extends TaskPage.AttemptsBlock {
|
||||||
@Inject
|
@Inject
|
||||||
FewAttemptsBlock(App ctx) {
|
FewAttemptsBlock(App ctx, Configuration conf) {
|
||||||
super(ctx);
|
super(ctx, conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,6 +27,8 @@ import static org.apache.hadoop.yarn.webapp.view.JQueryUI.tableInit;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringEscapeUtils;
|
import org.apache.commons.lang.StringEscapeUtils;
|
||||||
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.mapreduce.MRConfig;
|
||||||
import org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt;
|
import org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt;
|
||||||
import org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskAttemptInfo;
|
import org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskAttemptInfo;
|
||||||
import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
|
import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
|
||||||
|
@ -35,6 +37,8 @@ import org.apache.hadoop.yarn.webapp.SubView;
|
||||||
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
|
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
|
||||||
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
|
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
|
||||||
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
|
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
|
||||||
|
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.THEAD;
|
||||||
|
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TR;
|
||||||
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
|
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
@ -43,10 +47,15 @@ public class TaskPage extends AppView {
|
||||||
|
|
||||||
static class AttemptsBlock extends HtmlBlock {
|
static class AttemptsBlock extends HtmlBlock {
|
||||||
final App app;
|
final App app;
|
||||||
|
final boolean enableUIActions;
|
||||||
|
private String stateURLFormat;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AttemptsBlock(App ctx) {
|
AttemptsBlock(App ctx, Configuration conf) {
|
||||||
app = ctx;
|
app = ctx;
|
||||||
|
this.enableUIActions =
|
||||||
|
conf.getBoolean(MRConfig.MASTER_WEBAPP_UI_ACTIONS_ENABLED,
|
||||||
|
MRConfig.DEFAULT_MASTER_WEBAPP_UI_ACTIONS_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,21 +65,58 @@ public class TaskPage extends AppView {
|
||||||
h2($(TITLE));
|
h2($(TITLE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TBODY<TABLE<Hamlet>> tbody = html.
|
|
||||||
table("#attempts").
|
if (enableUIActions) {
|
||||||
thead().
|
// Kill task attempt
|
||||||
tr().
|
String appID = app.getJob().getID().getAppId().toString();
|
||||||
th(".id", "Attempt").
|
String jobID = app.getJob().getID().toString();
|
||||||
th(".progress", "Progress").
|
String taskID = app.getTask().getID().toString();
|
||||||
th(".state", "State").
|
stateURLFormat =
|
||||||
th(".status", "Status").
|
String.format("/proxy/%s/ws/v1/mapreduce/jobs/%s/tasks/%s/"
|
||||||
th(".node", "Node").
|
+ "attempts", appID, jobID, taskID) + "/%s/state";
|
||||||
th(".logs", "Logs").
|
|
||||||
th(".tsh", "Started").
|
String current =
|
||||||
th(".tsh", "Finished").
|
String.format("/proxy/%s/mapreduce/task/%s", appID, taskID);
|
||||||
th(".tsh", "Elapsed").
|
|
||||||
th(".note", "Note")._()._().
|
StringBuilder script = new StringBuilder();
|
||||||
tbody();
|
script.append("function confirmAction(stateURL) {")
|
||||||
|
.append(" b = confirm(\"Are you sure?\");")
|
||||||
|
.append(" if (b == true) {")
|
||||||
|
.append(" $.ajax({")
|
||||||
|
.append(" type: 'PUT',")
|
||||||
|
.append(" url: stateURL,")
|
||||||
|
.append(" contentType: 'application/json',")
|
||||||
|
.append(" data: '{\"state\":\"KILLED\"}',")
|
||||||
|
.append(" dataType: 'json'")
|
||||||
|
.append(" }).done(function(data){")
|
||||||
|
.append(" setTimeout(function(){")
|
||||||
|
.append(" location.href = '").append(current).append("';")
|
||||||
|
.append(" }, 1000);")
|
||||||
|
.append(" }).fail(function(data){")
|
||||||
|
.append(" console.log(data);")
|
||||||
|
.append(" });")
|
||||||
|
.append(" }")
|
||||||
|
.append("}");
|
||||||
|
|
||||||
|
html.script().$type("text/javascript")._(script.toString())._();
|
||||||
|
}
|
||||||
|
|
||||||
|
TR<THEAD<TABLE<Hamlet>>> tr = html.table("#attempts").thead().tr();
|
||||||
|
tr.th(".id", "Attempt").
|
||||||
|
th(".progress", "Progress").
|
||||||
|
th(".state", "State").
|
||||||
|
th(".status", "Status").
|
||||||
|
th(".node", "Node").
|
||||||
|
th(".logs", "Logs").
|
||||||
|
th(".tsh", "Started").
|
||||||
|
th(".tsh", "Finished").
|
||||||
|
th(".tsh", "Elapsed").
|
||||||
|
th(".note", "Note");
|
||||||
|
if (enableUIActions) {
|
||||||
|
tr.th(".actions", "Actions");
|
||||||
|
}
|
||||||
|
|
||||||
|
TBODY<TABLE<Hamlet>> tbody = tr._()._().tbody();
|
||||||
// Write all the data into a JavaScript array of arrays for JQuery
|
// Write all the data into a JavaScript array of arrays for JQuery
|
||||||
// DataTables to display
|
// DataTables to display
|
||||||
StringBuilder attemptsTableData = new StringBuilder("[\n");
|
StringBuilder attemptsTableData = new StringBuilder("[\n");
|
||||||
|
@ -103,7 +149,16 @@ public class TaskPage extends AppView {
|
||||||
.append(ta.getFinishTime()).append("\",\"")
|
.append(ta.getFinishTime()).append("\",\"")
|
||||||
.append(ta.getElapsedTime()).append("\",\"")
|
.append(ta.getElapsedTime()).append("\",\"")
|
||||||
.append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
|
.append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
|
||||||
diag))).append("\"],\n");
|
diag)));
|
||||||
|
if (enableUIActions) {
|
||||||
|
attemptsTableData.append("\",\"")
|
||||||
|
.append("<a href=javascript:void(0) onclick=confirmAction('")
|
||||||
|
.append(String.format(stateURLFormat, ta.getId()))
|
||||||
|
.append("');>Kill</a>")
|
||||||
|
.append("\"],\n");
|
||||||
|
} else {
|
||||||
|
attemptsTableData.append("\"],\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Remove the last comma and close off the array of arrays
|
//Remove the last comma and close off the array of arrays
|
||||||
if(attemptsTableData.charAt(attemptsTableData.length() - 2) == ',') {
|
if(attemptsTableData.charAt(attemptsTableData.length() - 2) == ',') {
|
||||||
|
|
|
@ -124,5 +124,12 @@ public interface MRConfig {
|
||||||
@Unstable
|
@Unstable
|
||||||
public static final boolean DEFAULT_MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM =
|
public static final boolean DEFAULT_MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM =
|
||||||
false;
|
false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable application master webapp ui actions.
|
||||||
|
*/
|
||||||
|
String MASTER_WEBAPP_UI_ACTIONS_ENABLED =
|
||||||
|
"mapreduce.webapp.ui-actions.enabled";
|
||||||
|
boolean DEFAULT_MASTER_WEBAPP_UI_ACTIONS_ENABLED = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue