%
/*
* 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 import = "java.text.DecimalFormat,java.text.NumberFormat,java.sql.*,java.io.*, org.json.*, java.util.Calendar, java.util.Date, java.text.SimpleDateFormat, java.util.*, org.apache.hadoop.chukwa.hicc.ClusterConfig, org.apache.hadoop.chukwa.hicc.TimeHandler, org.apache.hadoop.chukwa.util.DatabaseWriter, org.apache.hadoop.chukwa.database.Macro, org.apache.hadoop.chukwa.util.XssFilter, org.apache.hadoop.chukwa.database.DatabaseConfig, java.util.ArrayList" %>
<%
XssFilter xf = new XssFilter(request);
NumberFormat nf = new DecimalFormat("###,###,###,##0.00");
response.setHeader("boxId", xf.getParameter("boxId"));
response.setContentType("text/html; chartset=UTF-8//IGNORE"); %>
<%
String boxId=xf.getParameter("boxId");
String cluster = (String) session.getAttribute("cluster");
DatabaseWriter dbw = new DatabaseWriter(cluster);
String path = "";
Calendar now = Calendar.getInstance();
HashMap index = new HashMap();
long start = 0;
long end = now.getTimeInMillis();
String startS="";
String endS="";
TimeHandler time = new TimeHandler(request, (String)session.getAttribute("time_zone"));
startS = time.getStartTimeText();
endS = time.getEndTimeText();
start = time.getStartTime();
end = time.getEndTime();
Macro mp = new Macro(start,end,"[util]", request);
int averageBy=600;
String tmpTable = mp.toString();
DatabaseConfig dbc = new DatabaseConfig();
String[] tableList = dbc.findTableNameForCharts("util", start, end);
if(tableList[0].endsWith("_week")) {
averageBy=600;
} else if(tableList[0].endsWith("_month")) {
averageBy=600;
} else if(tableList[0].endsWith("_quarter")) {
averageBy=1800;
} else if(tableList[0].endsWith("_year")) {
averageBy=10800;
} else if(tableList[0].endsWith("_decade")) {
averageBy=43200;
}
StringBuilder queryBuilder = new StringBuilder();
String query = "";
queryBuilder.append("select * from [mr_job] where finish_time between '[start]' and '[end]' ");
if(xf.getParameter("job_id")!=null) {
queryBuilder = new StringBuilder();
mp = new Macro(start,end,"[mr_job]", request);
query = mp.toString();
queryBuilder.append("select * from ");
queryBuilder.append(query);
queryBuilder.append(" where finish_time between ? and ? ");
queryBuilder.append(" and job_id=?");
ArrayList