org.apache.hadoop.mapred.JSPUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hadoop-core Show documentation
Show all versions of hadoop-core Show documentation
Hadoop is the distributed computing framework of Apache; hadoop-core contains
the filesystem, job tracker and map/reduce modules
The newest version!
/**
* 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.
*/
package org.apache.hadoop.mapred;
import java.io.IOException;
import java.util.Iterator;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.util.ServletUtil;
class JSPUtil {
private static final String PRIVATE_ACTIONS_KEY = "webinterface.private.actions";
public static final Configuration conf = new Configuration();
/**
* Method used to process the request from the job page based on the
* request which it has received. For example like changing priority.
*
* @param request HTTP request Object.
* @param response HTTP response object.
* @param tracker {@link JobTracker} instance
* @throws IOException
*/
public static void processButtons(HttpServletRequest request,
HttpServletResponse response, JobTracker tracker) throws IOException {
if (conf.getBoolean(PRIVATE_ACTIONS_KEY, false)
&& request.getParameter("killJobs") != null) {
String[] jobs = request.getParameterValues("jobCheckBox");
if (jobs != null) {
for (String job : jobs) {
tracker.killJob(JobID.forName(job));
}
}
}
if (conf.getBoolean(PRIVATE_ACTIONS_KEY, false) &&
request.getParameter("changeJobPriority") != null) {
String[] jobs = request.getParameterValues("jobCheckBox");
if (jobs != null) {
JobPriority jobPri = JobPriority.valueOf(request
.getParameter("setJobPriority"));
for (String job : jobs) {
tracker.setJobPriority(JobID.forName(job), jobPri);
}
}
}
}
/**
* Method used to generate the Job table for Job pages.
*
* @param label display heading to be used in the job table.
* @param jobs vector of jobs to be displayed in table.
* @param refresh refresh interval to be used in jobdetails page.
* @param rowId beginning row id to be used in the table.
* @return
* @throws IOException
*/
public static String generateJobTable(String label, Collection jobs
, int refresh, int rowId) throws IOException {
boolean isModifiable = label.equals("Running")
&& conf.getBoolean(
PRIVATE_ACTIONS_KEY, false);
StringBuffer sb = new StringBuffer();
sb.append("\n");
if (jobs.size() > 0) {
if (isModifiable) {
sb.append("\n");
}
} else {
sb.append("none" +
" \n");
}
sb.append("
\n");
return sb.toString();
}
}