webapps.admin.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.webapp.StaticHttpServer" %>
<%@ page import="java.text.NumberFormat" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="org.apache.tajo.master.TajoMaster" %>
<%@ page import="org.apache.tajo.util.history.HistoryReader" %>
<%@ page import="org.apache.tajo.util.history.QueryHistory" %>
<%@ page import="org.apache.tajo.util.history.StageHistory" %>
<%@ page import="org.apache.tajo.master.rm.Worker" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.tajo.util.history.TaskHistory" %>
<%@ page import="org.apache.tajo.util.*" %>
<%@ page import="org.apache.commons.lang.math.NumberUtils" %>
<%
TajoMaster master = (TajoMaster) StaticHttpServer.getInstance().getAttribute("tajo.info.server.object");
HistoryReader reader = master.getContext().getHistoryReader();
String queryId = request.getParameter("queryId");
String startTime = request.getParameter("startTime");
String ebId = request.getParameter("ebid");
QueryHistory queryHistory = reader.getQueryHistory(queryId, NumberUtils.toLong(startTime, 0));
List stageHistories =
queryHistory != null ? JSPUtil.sortStageHistories(queryHistory.getStageHistories()) : null;
StageHistory stage = null;
if (stageHistories != null) {
for (StageHistory eachStage: stageHistories) {
if (eachStage.getExecutionBlockId().equals(ebId)) {
stage = eachStage;
break;
}
}
}
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";
}
Collection allWorkers = master.getContext().getResourceManager().getWorkers().values();
Map workerMap = new HashMap();
if(allWorkers != null) {
for(Worker eachWorker: allWorkers) {
workerMap.put(eachWorker.getConnectionInfo().getHostAndPeerRpcPort(), eachWorker);
}
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long totalInputBytes = 0;
long totalReadBytes = 0;
long totalReadRows = 0;
long totalWriteBytes = 0;
long totalWriteRows = 0;
if (stage != null) {
totalInputBytes = stage.getTotalInputBytes();
totalReadBytes = stage.getTotalReadBytes();
totalReadRows = stage.getTotalReadRows();
totalWriteBytes = stage.getTotalWriteBytes();
totalWriteRows = stage.getTotalWriteRows();
}
List allTasks = reader.getTaskHistory(queryId, ebId);
int numTasks = allTasks.size();
int numShuffles = 0;
float totalProgress = 0.0f;
if (allTasks != null) {
for(TaskHistory eachTask: allTasks) {
totalProgress += eachTask.getProgress();
numShuffles = eachTask.getNumShuffles();
}
}
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 + "&startTime=" + startTime +
"&page=" + currentPage + "&pageSize=" + pageSize +
"&status=" + status + "&sortOrder=" + nextSortOrder + "&sort=";
String pageUrl = "querytasks.jsp?queryId=" + queryId + "&ebid=" + ebId + "&startTime=" + startTime +
"&status=" + status + "&sortOrder=" + nextSortOrder + "&sort=";
NumberFormat nf = NumberFormat.getInstance(Locale.US);
%>
Query Detail Info
<%@ include file="header.jsp"%>
Tajo Master: <%=master.getMasterName()%> <%=JSPUtil.getMasterActiveLabel(master.getContext())%>
<%=ebId.toString()%>
<%=stage.getPlan()%>
Status: <%=stage.getState()%>
Started: <%=df.format(stage.getStartTime())%> ~ <%=stage.getFinishTime() == 0 ? "-" : df.format(stage.getFinishTime())%>
# Tasks: <%=numTasks%> (Local Tasks: <%=stage.getHostLocalAssigned()%>, Rack Local Tasks: <%=stage.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 filteredTasks = new ArrayList();
for(TaskHistory eachTask: allTasks) {
if (!"ALL".equals(status)) {
if (!status.equals(eachTask.getState().toString())) {
continue;
}
}
filteredTasks.add(eachTask);
}
JSPUtil.sortTaskHistory(filteredTasks, sort, sortOrder);
List tasks = JSPUtil.getPageNavigationList(filteredTasks, currentPage, pageSize);
int numOfTasks = filteredTasks.size();
int totalPage = numOfTasks % pageSize == 0 ?
numOfTasks / pageSize : numOfTasks / pageSize + 1;
%>
# Tasks: <%=numOfTasks%> / # Pages: <%=totalPage%>
No Id Status Progress Started Running Time Host
<%
int rowNo = (currentPage - 1) * pageSize + 1;
for (TaskHistory eachTask: tasks) {
String taskDetailUrl = "";
if (eachTask.getId() != null) {
taskDetailUrl = "task.jsp?queryId=" + queryId + "&ebid=" + ebId + "&startTime=" + startTime +
"&taskAttemptId=" + eachTask.getId() + "&sort=" + sort + "&sortOrder=" + sortOrder;
}
String taskHost = eachTask.getHostAndPort() == null ? "-" : eachTask.getHostAndPort();
if (eachTask.getHostAndPort() != null) {
Worker worker = workerMap.get(eachTask.getHostAndPort());
if (worker != null) {
String[] hostTokens = eachTask.getHostAndPort().split(":");
taskHost = "" + eachTask.getHostAndPort() + "";
}
}
%>
<%=rowNo%>
<%=eachTask.getId()%>
<%=eachTask.getState()%>
<%=JSPUtil.percentFormat(eachTask.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