webapps.worker.querytasks.jsp Maven / Gradle / Ivy
<%
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.apache.tajo.ExecutionBlockId" %>
<%@ page import="org.apache.tajo.QueryId" %>
<%@ page import="org.apache.tajo.TaskAttemptId" %>
<%@ page import="org.apache.tajo.catalog.statistics.TableStats" %>
<%@ page import="org.apache.tajo.plan.util.PlannerUtil" %>
<%@ page import="org.apache.tajo.ipc.QueryCoordinatorProtocol" %>
<%@ page import="org.apache.tajo.querymaster.*" %>
<%@ page import="org.apache.tajo.webapp.StaticHttpServer" %>
<%@ page import="org.apache.tajo.worker.TajoWorker" %>
<%@ page import="java.text.NumberFormat" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="org.apache.tajo.util.history.HistoryReader" %>
<%@ page import="org.apache.tajo.util.*" %>
<%@ page import="java.util.*" %>
<%
String paramQueryId = request.getParameter("queryId");
String paramEbId = request.getParameter("ebid");
QueryId queryId = TajoIdUtils.parseQueryId(paramQueryId);
ExecutionBlockId ebid = TajoIdUtils.createExecutionBlockId(paramEbId);
String sort = request.getParameter("sort");
if(sort == null) {
sort = "id";
}
String sortOrder = request.getParameter("sortOrder");
if(sortOrder == null) {
sortOrder = "asc";
}
String nextSortOrder = "asc";
if("asc".equals(sortOrder)) {
nextSortOrder = "desc";
}
String status = request.getParameter("status");
if(status == null || status.isEmpty() || "null".equals(status)) {
status = "ALL";
}
TajoWorker tajoWorker = (TajoWorker) StaticHttpServer.getInstance().getAttribute("tajo.info.server.object");
List allWorkers = tajoWorker.getWorkerContext()
.getQueryMasterManagerService().getQueryMaster().getAllWorker();
Map workerMap = new HashMap();
if(allWorkers != null) {
for(QueryCoordinatorProtocol.WorkerResourceProto eachWorker: allWorkers) {
workerMap.put(eachWorker.getConnectionInfo().getId(), eachWorker);
}
}
QueryMasterTask queryMasterTask = tajoWorker.getWorkerContext()
.getQueryMasterManagerService().getQueryMaster().getQueryMasterTask(queryId, true);
if(queryMasterTask == null) {
out.write("");
return;
}
Query query = queryMasterTask.getQuery();
Stage stage = query.getStage(ebid);
if(stage == null) {
out.write("");
return;
}
if(stage == null) {
%>
<%
return;
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Task[] allTasks = stage.getTasks();
long totalInputBytes = 0;
long totalReadBytes = 0;
long totalReadRows = 0;
long totalWriteBytes = 0;
long totalWriteRows = 0;
int numTasks = allTasks.length;
int numShuffles = 0;
float totalProgress = 0.0f;
for(Task eachTask : allTasks) {
totalProgress += eachTask.getLastAttempt() != null ? eachTask.getLastAttempt().getProgress(): 0.0f;
numShuffles = eachTask.getShuffleOutpuNum();
if (eachTask.getLastAttempt() != null) {
TableStats inputStats = eachTask.getLastAttempt().getInputStats();
if (inputStats != null) {
totalInputBytes += inputStats.getNumBytes();
totalReadBytes += inputStats.getReadBytes();
totalReadRows += inputStats.getNumRows();
}
TableStats outputStats = eachTask.getLastAttempt().getResultStats();
if (outputStats != null) {
totalWriteBytes += outputStats.getNumBytes();
totalWriteRows += outputStats.getNumRows();
}
}
}
int currentPage = 1;
if (request.getParameter("page") != null && !request.getParameter("page").isEmpty()) {
currentPage = Integer.parseInt(request.getParameter("page"));
}
int pageSize = HistoryReader.DEFAULT_TASK_PAGE_SIZE;
if (request.getParameter("pageSize") != null && !request.getParameter("pageSize").isEmpty()) {
try {
pageSize = Integer.parseInt(request.getParameter("pageSize"));
} catch (NumberFormatException e) {
pageSize = HistoryReader.DEFAULT_TASK_PAGE_SIZE;
}
}
String url = "querytasks.jsp?queryId=" + queryId + "&ebid=" + ebid +
"&page=" + currentPage + "&pageSize=" + pageSize +
"&status=" + status + "&sortOrder=" + nextSortOrder + "&sort=";
String pageUrl = "querytasks.jsp?queryId=" + paramQueryId + "&ebid=" + paramEbId +
"&status=" + status + "&sortOrder=" + nextSortOrder + "&sort=";
NumberFormat nf = NumberFormat.getInstance(Locale.US);
%>
Query Detail Info
<%@ include file="header.jsp"%>
Tajo Worker: <%=tajoWorker.getWorkerContext().getWorkerName()%>
<%=ebid.toString()%>
<%=PlannerUtil.buildExplainString(stage.getBlock().getPlan())%>
Status: <%=stage.getState()%>
Started: <%=df.format(stage.getStartTime())%> ~ <%=stage.getFinishTime() == 0 ? "-" : df.format(stage.getFinishTime())%>
# Tasks: <%=numTasks%> (Local Tasks: <%=stage.getTaskScheduler().getHostLocalAssigned()%>, Rack Local Tasks: <%=stage.getTaskScheduler().getRackLocalAssigned()%>)
Progress: <%=JSPUtil.percentFormat((float) (totalProgress / numTasks))%>%
# Shuffles: <%=numShuffles%>
Input Bytes: <%=FileUtil.humanReadableByteCount(totalInputBytes, false) + " (" + nf.format(totalInputBytes) + " B)"%>
Actual Processed Bytes: <%=totalReadBytes == 0 ? "-" : FileUtil.humanReadableByteCount(totalReadBytes, false) + " (" + nf.format(totalReadBytes) + " B)"%>
Input Rows: <%=nf.format(totalReadRows)%>
Output Bytes: <%=FileUtil.humanReadableByteCount(totalWriteBytes, false) + " (" + nf.format(totalWriteBytes) + " B)"%>
Output Rows: <%=nf.format(totalWriteRows)%>
<%
List filteredTask = new ArrayList();
for(Task eachTask : allTasks) {
if (!"ALL".equals(status)) {
if (!status.equals(eachTask.getLastAttemptStatus().toString())) {
continue;
}
}
filteredTask.add(eachTask);
}
JSPUtil.sortTasks(filteredTask, sort, sortOrder);
List tasks = JSPUtil.getPageNavigationList(filteredTask, currentPage, pageSize);
int numOfTasks = filteredTask.size();
int totalPage = numOfTasks % pageSize == 0 ?
numOfTasks / pageSize : numOfTasks / pageSize + 1;
int rowNo = (currentPage - 1) * pageSize + 1;
%>
# Tasks: <%=numOfTasks%> / # Pages: <%=totalPage%>
No Id Status Progress Started Running Time Host
<%
for(Task eachTask : tasks) {
int taskSeq = eachTask.getId().getId();
String taskDetailUrl = "task.jsp?queryId=" + paramQueryId + "&ebid=" + paramEbId +
"&page=" + currentPage + "&pageSize=" + pageSize +
"&taskSeq=" + taskSeq + "&sort=" + sort + "&sortOrder=" + sortOrder;
String taskHost = eachTask.getSucceededHost() == null ? "-" : eachTask.getSucceededHost();
if(eachTask.getSucceededHost() != null) {
QueryCoordinatorProtocol.WorkerResourceProto worker =
workerMap.get(eachTask.getLastAttempt().getWorkerConnectionInfo().getId());
if(worker != null) {
TaskAttempt lastAttempt = eachTask.getLastAttempt();
if(lastAttempt != null) {
TaskAttemptId lastAttemptId = lastAttempt.getId();
taskHost = "" + eachTask.getSucceededHost() + "";
}
}
}
%>
<%=rowNo%>
<%=eachTask.getId()%>
<%=eachTask.getLastAttemptStatus()%>
<%=JSPUtil.percentFormat(eachTask.getLastAttempt().getProgress())%>%
<%=eachTask.getLaunchTime() == 0 ? "-" : df.format(eachTask.getLaunchTime())%>
<%=eachTask.getLaunchTime() == 0 ? "-" : eachTask.getRunningTime() + " ms"%>
<%=taskHost%>
<%
rowNo++;
}
%>
<%=JSPUtil.getPageNavigation(currentPage, totalPage, pageUrl + "&pageSize=" + pageSize)%>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy