protected override void Render(HtmlBlock.Block html) { if (!IsValidRequest()) { html.H2($(Title)); return; } Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > tbody = html .Table("#attempts").Thead().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").().().Tbody(); // Write all the data into a JavaScript array of arrays for JQuery // DataTables to display StringBuilder attemptsTableData = new StringBuilder("[\n"); foreach (TaskAttempt attempt in GetTaskAttempts()) { TaskAttemptInfo ta = new TaskAttemptInfo(attempt, true); string progress = StringHelper.Percent(ta.GetProgress() / 100); string nodeHttpAddr = ta.GetNode(); string diag = ta.GetNote() == null ? string.Empty : ta.GetNote(); attemptsTableData.Append("[\"").Append(ta.GetId()).Append("\",\"").Append(progress ).Append("\",\"").Append(ta.GetState().ToString()).Append("\",\"").Append(StringEscapeUtils .EscapeJavaScript(StringEscapeUtils.EscapeHtml(ta.GetStatus()))).Append("\",\"") .Append(nodeHttpAddr == null ? "N/A" : "<a class='nodelink' href='" + MRWebAppUtil .GetYARNWebappScheme() + nodeHttpAddr + "'>" + nodeHttpAddr + "</a>").Append("\",\"" ).Append(ta.GetAssignedContainerId() == null ? "N/A" : "<a class='logslink' href='" + Url(MRWebAppUtil.GetYARNWebappScheme(), nodeHttpAddr, "node", "containerlogs" , ta.GetAssignedContainerIdStr(), app.GetJob().GetUserName()) + "'>logs</a>").Append ("\",\"").Append(ta.GetStartTime()).Append("\",\"").Append(ta.GetFinishTime()).Append ("\",\"").Append(ta.GetElapsedTime()).Append("\",\"").Append(StringEscapeUtils.EscapeJavaScript (StringEscapeUtils.EscapeHtml(diag))).Append("\"],\n"); } //Remove the last comma and close off the array of arrays if (attemptsTableData[attemptsTableData.Length - 2] == ',') { attemptsTableData.Delete(attemptsTableData.Length - 2, attemptsTableData.Length - 1); } attemptsTableData.Append("]"); html.Script().$type("text/javascript").("var attemptsTableData=" + attemptsTableData ).(); tbody.().(); }
protected override void Render(HtmlBlock.Block html) { if (!IsValidRequest()) { html.H2($(Title)); return; } TaskType type = null; string symbol = $(AMParams.TaskType); if (!symbol.IsEmpty()) { type = MRApps.TaskType(symbol); } else { type = app.GetTask().GetType(); } Hamlet.TR <Hamlet.THEAD <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > > headRow = html.Table("#attempts").Thead().Tr(); headRow.Th(".id", "Attempt").Th(".state", "State").Th(".status", "Status").Th(".node" , "Node").Th(".logs", "Logs").Th(".tsh", "Start Time"); if (type == TaskType.Reduce) { headRow.Th("Shuffle Finish Time"); headRow.Th("Merge Finish Time"); } headRow.Th("Finish Time"); //Attempt if (type == TaskType.Reduce) { headRow.Th("Elapsed Time Shuffle"); //Attempt headRow.Th("Elapsed Time Merge"); //Attempt headRow.Th("Elapsed Time Reduce"); } //Attempt headRow.Th("Elapsed Time").Th(".note", "Note"); Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > tbody = headRow .().().Tbody(); // Write all the data into a JavaScript array of arrays for JQuery // DataTables to display StringBuilder attemptsTableData = new StringBuilder("[\n"); foreach (TaskAttempt attempt in GetTaskAttempts()) { TaskAttemptInfo ta = new TaskAttemptInfo(attempt, false); string taid = ta.GetId(); string nodeHttpAddr = ta.GetNode(); string containerIdString = ta.GetAssignedContainerIdStr(); string nodeIdString = attempt.GetAssignedContainerMgrAddress(); string nodeRackName = ta.GetRack(); long attemptStartTime = ta.GetStartTime(); long shuffleFinishTime = -1; long sortFinishTime = -1; long attemptFinishTime = ta.GetFinishTime(); long elapsedShuffleTime = -1; long elapsedSortTime = -1; long elapsedReduceTime = -1; if (type == TaskType.Reduce) { shuffleFinishTime = attempt.GetShuffleFinishTime(); sortFinishTime = attempt.GetSortFinishTime(); elapsedShuffleTime = Times.Elapsed(attemptStartTime, shuffleFinishTime, false); elapsedSortTime = Times.Elapsed(shuffleFinishTime, sortFinishTime, false); elapsedReduceTime = Times.Elapsed(sortFinishTime, attemptFinishTime, false); } long attemptElapsed = Times.Elapsed(attemptStartTime, attemptFinishTime, false); int sortId = attempt.GetID().GetId() + (attempt.GetID().GetTaskId().GetId() * 10000 ); attemptsTableData.Append("[\"").Append(sortId + " ").Append(taid).Append("\",\"") .Append(ta.GetState()).Append("\",\"").Append(StringEscapeUtils.EscapeJavaScript (StringEscapeUtils.EscapeHtml(ta.GetStatus()))).Append("\",\"").Append("<a class='nodelink' href='" + MRWebAppUtil.GetYARNWebappScheme() + nodeHttpAddr + "'>").Append(nodeRackName + "/" + nodeHttpAddr + "</a>\",\"").Append("<a class='logslink' href='").Append (Url("logs", nodeIdString, containerIdString, taid, app.GetJob().GetUserName())) .Append("'>logs</a>\",\"").Append(attemptStartTime).Append("\",\""); if (type == TaskType.Reduce) { attemptsTableData.Append(shuffleFinishTime).Append("\",\"").Append(sortFinishTime ).Append("\",\""); } attemptsTableData.Append(attemptFinishTime).Append("\",\""); if (type == TaskType.Reduce) { attemptsTableData.Append(elapsedShuffleTime).Append("\",\"").Append(elapsedSortTime ).Append("\",\"").Append(elapsedReduceTime).Append("\",\""); } attemptsTableData.Append(attemptElapsed).Append("\",\"").Append(StringEscapeUtils .EscapeJavaScript(StringEscapeUtils.EscapeHtml(ta.GetNote()))).Append("\"],\n"); } //Remove the last comma and close off the array of arrays if (attemptsTableData[attemptsTableData.Length - 2] == ',') { attemptsTableData.Delete(attemptsTableData.Length - 2, attemptsTableData.Length - 1); } attemptsTableData.Append("]"); html.Script().$type("text/javascript").("var attemptsTableData=" + attemptsTableData ).(); Hamlet.TR <Hamlet.TFOOT <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > > footRow = tbody.().Tfoot().Tr(); footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("attempt_name" ).$value("Attempt").().().Th().Input("search_init").$type(HamletSpec.InputType.text ).$name("attempt_state").$value("State").().().Th().Input("search_init").$type(HamletSpec.InputType .text).$name("attempt_status").$value("Status").().().Th().Input("search_init"). $type(HamletSpec.InputType.text).$name("attempt_node").$value("Node").().().Th() .Input("search_init").$type(HamletSpec.InputType.text).$name("attempt_node").$value ("Logs").().().Th().Input("search_init").$type(HamletSpec.InputType.text).$name( "attempt_start_time").$value("Start Time").().(); if (type == TaskType.Reduce) { footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("shuffle_time" ).$value("Shuffle Time").().(); footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("merge_time" ).$value("Merge Time").().(); } footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("attempt_finish" ).$value("Finish Time").().(); if (type == TaskType.Reduce) { footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("elapsed_shuffle_time" ).$value("Elapsed Shuffle Time").().(); footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("elapsed_merge_time" ).$value("Elapsed Merge Time").().(); footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("elapsed_reduce_time" ).$value("Elapsed Reduce Time").().(); } footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("attempt_elapsed" ).$value("Elapsed Time").().().Th().Input("search_init").$type(HamletSpec.InputType .text).$name("note").$value("Note").().(); footRow.().().(); }