merge -r 1330559:1330560 from trunk. FIXES: MAPREDUCE-3613
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1330561 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7f40acc947
commit
bb9cfbb052
|
@ -300,6 +300,9 @@ Release 0.23.3 - UNRELEASED
|
||||||
MAPREDUCE-4194. ConcurrentModificationError in DirectoryCollection
|
MAPREDUCE-4194. ConcurrentModificationError in DirectoryCollection
|
||||||
(Jonathan Eagles via bobby)
|
(Jonathan Eagles via bobby)
|
||||||
|
|
||||||
|
MAPREDUCE-3613. web service calls header contains 2 content types
|
||||||
|
(tgraves)
|
||||||
|
|
||||||
Release 0.23.2 - UNRELEASED
|
Release 0.23.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.hadoop.mapreduce.v2.app.webapp;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
|
@ -67,6 +68,8 @@ import com.google.inject.Inject;
|
||||||
public class AMWebServices {
|
public class AMWebServices {
|
||||||
private final AppContext appCtx;
|
private final AppContext appCtx;
|
||||||
private final App app;
|
private final App app;
|
||||||
|
|
||||||
|
private @Context HttpServletResponse response;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AMWebServices(final App app, final AppContext context) {
|
public AMWebServices(final App app, final AppContext context) {
|
||||||
|
@ -86,6 +89,11 @@ public class AMWebServices {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
//clear content type
|
||||||
|
response.setContentType(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* convert a job id string to an actual job and handle all the error checking.
|
* convert a job id string to an actual job and handle all the error checking.
|
||||||
*/
|
*/
|
||||||
|
@ -205,6 +213,7 @@ public class AMWebServices {
|
||||||
@Path("/info")
|
@Path("/info")
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public AppInfo getAppInfo() {
|
public AppInfo getAppInfo() {
|
||||||
|
init();
|
||||||
return new AppInfo(this.app, this.app.context);
|
return new AppInfo(this.app, this.app.context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +221,7 @@ public class AMWebServices {
|
||||||
@Path("/jobs")
|
@Path("/jobs")
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public JobsInfo getJobs(@Context HttpServletRequest hsr) {
|
public JobsInfo getJobs(@Context HttpServletRequest hsr) {
|
||||||
|
init();
|
||||||
JobsInfo allJobs = new JobsInfo();
|
JobsInfo allJobs = new JobsInfo();
|
||||||
for (Job job : appCtx.getAllJobs().values()) {
|
for (Job job : appCtx.getAllJobs().values()) {
|
||||||
// getAllJobs only gives you a partial we want a full
|
// getAllJobs only gives you a partial we want a full
|
||||||
|
@ -229,6 +239,7 @@ public class AMWebServices {
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public JobInfo getJob(@Context HttpServletRequest hsr,
|
public JobInfo getJob(@Context HttpServletRequest hsr,
|
||||||
@PathParam("jobid") String jid) {
|
@PathParam("jobid") String jid) {
|
||||||
|
init();
|
||||||
Job job = getJobFromJobIdString(jid, appCtx);
|
Job job = getJobFromJobIdString(jid, appCtx);
|
||||||
return new JobInfo(job, hasAccess(job, hsr));
|
return new JobInfo(job, hasAccess(job, hsr));
|
||||||
}
|
}
|
||||||
|
@ -237,7 +248,7 @@ public class AMWebServices {
|
||||||
@Path("/jobs/{jobid}/jobattempts")
|
@Path("/jobs/{jobid}/jobattempts")
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public AMAttemptsInfo getJobAttempts(@PathParam("jobid") String jid) {
|
public AMAttemptsInfo getJobAttempts(@PathParam("jobid") String jid) {
|
||||||
|
init();
|
||||||
Job job = getJobFromJobIdString(jid, appCtx);
|
Job job = getJobFromJobIdString(jid, appCtx);
|
||||||
AMAttemptsInfo amAttempts = new AMAttemptsInfo();
|
AMAttemptsInfo amAttempts = new AMAttemptsInfo();
|
||||||
for (AMInfo amInfo : job.getAMInfos()) {
|
for (AMInfo amInfo : job.getAMInfos()) {
|
||||||
|
@ -253,6 +264,7 @@ public class AMWebServices {
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public JobCounterInfo getJobCounters(@Context HttpServletRequest hsr,
|
public JobCounterInfo getJobCounters(@Context HttpServletRequest hsr,
|
||||||
@PathParam("jobid") String jid) {
|
@PathParam("jobid") String jid) {
|
||||||
|
init();
|
||||||
Job job = getJobFromJobIdString(jid, appCtx);
|
Job job = getJobFromJobIdString(jid, appCtx);
|
||||||
checkAccess(job, hsr);
|
checkAccess(job, hsr);
|
||||||
return new JobCounterInfo(this.appCtx, job);
|
return new JobCounterInfo(this.appCtx, job);
|
||||||
|
@ -264,6 +276,7 @@ public class AMWebServices {
|
||||||
public ConfInfo getJobConf(@Context HttpServletRequest hsr,
|
public ConfInfo getJobConf(@Context HttpServletRequest hsr,
|
||||||
@PathParam("jobid") String jid) {
|
@PathParam("jobid") String jid) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = getJobFromJobIdString(jid, appCtx);
|
Job job = getJobFromJobIdString(jid, appCtx);
|
||||||
checkAccess(job, hsr);
|
checkAccess(job, hsr);
|
||||||
ConfInfo info;
|
ConfInfo info;
|
||||||
|
@ -282,6 +295,7 @@ public class AMWebServices {
|
||||||
public TasksInfo getJobTasks(@Context HttpServletRequest hsr,
|
public TasksInfo getJobTasks(@Context HttpServletRequest hsr,
|
||||||
@PathParam("jobid") String jid, @QueryParam("type") String type) {
|
@PathParam("jobid") String jid, @QueryParam("type") String type) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = getJobFromJobIdString(jid, appCtx);
|
Job job = getJobFromJobIdString(jid, appCtx);
|
||||||
checkAccess(job, hsr);
|
checkAccess(job, hsr);
|
||||||
TasksInfo allTasks = new TasksInfo();
|
TasksInfo allTasks = new TasksInfo();
|
||||||
|
@ -308,6 +322,7 @@ public class AMWebServices {
|
||||||
public TaskInfo getJobTask(@Context HttpServletRequest hsr,
|
public TaskInfo getJobTask(@Context HttpServletRequest hsr,
|
||||||
@PathParam("jobid") String jid, @PathParam("taskid") String tid) {
|
@PathParam("jobid") String jid, @PathParam("taskid") String tid) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = getJobFromJobIdString(jid, appCtx);
|
Job job = getJobFromJobIdString(jid, appCtx);
|
||||||
checkAccess(job, hsr);
|
checkAccess(job, hsr);
|
||||||
Task task = getTaskFromTaskIdString(tid, job);
|
Task task = getTaskFromTaskIdString(tid, job);
|
||||||
|
@ -321,6 +336,7 @@ public class AMWebServices {
|
||||||
@Context HttpServletRequest hsr, @PathParam("jobid") String jid,
|
@Context HttpServletRequest hsr, @PathParam("jobid") String jid,
|
||||||
@PathParam("taskid") String tid) {
|
@PathParam("taskid") String tid) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = getJobFromJobIdString(jid, appCtx);
|
Job job = getJobFromJobIdString(jid, appCtx);
|
||||||
checkAccess(job, hsr);
|
checkAccess(job, hsr);
|
||||||
Task task = getTaskFromTaskIdString(tid, job);
|
Task task = getTaskFromTaskIdString(tid, job);
|
||||||
|
@ -332,8 +348,9 @@ public class AMWebServices {
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public TaskAttemptsInfo getJobTaskAttempts(@Context HttpServletRequest hsr,
|
public TaskAttemptsInfo getJobTaskAttempts(@Context HttpServletRequest hsr,
|
||||||
@PathParam("jobid") String jid, @PathParam("taskid") String tid) {
|
@PathParam("jobid") String jid, @PathParam("taskid") String tid) {
|
||||||
TaskAttemptsInfo attempts = new TaskAttemptsInfo();
|
|
||||||
|
|
||||||
|
init();
|
||||||
|
TaskAttemptsInfo attempts = new TaskAttemptsInfo();
|
||||||
Job job = getJobFromJobIdString(jid, appCtx);
|
Job job = getJobFromJobIdString(jid, appCtx);
|
||||||
checkAccess(job, hsr);
|
checkAccess(job, hsr);
|
||||||
Task task = getTaskFromTaskIdString(tid, job);
|
Task task = getTaskFromTaskIdString(tid, job);
|
||||||
|
@ -357,6 +374,7 @@ public class AMWebServices {
|
||||||
@PathParam("jobid") String jid, @PathParam("taskid") String tid,
|
@PathParam("jobid") String jid, @PathParam("taskid") String tid,
|
||||||
@PathParam("attemptid") String attId) {
|
@PathParam("attemptid") String attId) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = getJobFromJobIdString(jid, appCtx);
|
Job job = getJobFromJobIdString(jid, appCtx);
|
||||||
checkAccess(job, hsr);
|
checkAccess(job, hsr);
|
||||||
Task task = getTaskFromTaskIdString(tid, job);
|
Task task = getTaskFromTaskIdString(tid, job);
|
||||||
|
@ -375,6 +393,7 @@ public class AMWebServices {
|
||||||
@Context HttpServletRequest hsr, @PathParam("jobid") String jid,
|
@Context HttpServletRequest hsr, @PathParam("jobid") String jid,
|
||||||
@PathParam("taskid") String tid, @PathParam("attemptid") String attId) {
|
@PathParam("taskid") String tid, @PathParam("attemptid") String attId) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = getJobFromJobIdString(jid, appCtx);
|
Job job = getJobFromJobIdString(jid, appCtx);
|
||||||
checkAccess(job, hsr);
|
checkAccess(job, hsr);
|
||||||
Task task = getTaskFromTaskIdString(tid, job);
|
Task task = getTaskFromTaskIdString(tid, job);
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.mapreduce.v2.hs.webapp;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
|
@ -66,6 +67,7 @@ public class HsWebServices {
|
||||||
private final HistoryContext ctx;
|
private final HistoryContext ctx;
|
||||||
private WebApp webapp;
|
private WebApp webapp;
|
||||||
|
|
||||||
|
private @Context HttpServletResponse response;
|
||||||
@Context
|
@Context
|
||||||
UriInfo uriInfo;
|
UriInfo uriInfo;
|
||||||
|
|
||||||
|
@ -76,6 +78,11 @@ public class HsWebServices {
|
||||||
this.webapp = webapp;
|
this.webapp = webapp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
//clear content type
|
||||||
|
response.setContentType(null);
|
||||||
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public HistoryInfo get() {
|
public HistoryInfo get() {
|
||||||
|
@ -86,6 +93,7 @@ public class HsWebServices {
|
||||||
@Path("/info")
|
@Path("/info")
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public HistoryInfo getHistoryInfo() {
|
public HistoryInfo getHistoryInfo() {
|
||||||
|
init();
|
||||||
return new HistoryInfo();
|
return new HistoryInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +110,7 @@ public class HsWebServices {
|
||||||
@QueryParam("finishedTimeEnd") String finishEnd) {
|
@QueryParam("finishedTimeEnd") String finishEnd) {
|
||||||
|
|
||||||
Long countParam = null;
|
Long countParam = null;
|
||||||
|
init();
|
||||||
|
|
||||||
if (count != null && !count.isEmpty()) {
|
if (count != null && !count.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
|
@ -183,6 +192,7 @@ public class HsWebServices {
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public JobInfo getJob(@PathParam("jobid") String jid) {
|
public JobInfo getJob(@PathParam("jobid") String jid) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
||||||
return new JobInfo(job);
|
return new JobInfo(job);
|
||||||
}
|
}
|
||||||
|
@ -192,6 +202,7 @@ public class HsWebServices {
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public AMAttemptsInfo getJobAttempts(@PathParam("jobid") String jid) {
|
public AMAttemptsInfo getJobAttempts(@PathParam("jobid") String jid) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
||||||
AMAttemptsInfo amAttempts = new AMAttemptsInfo();
|
AMAttemptsInfo amAttempts = new AMAttemptsInfo();
|
||||||
for (AMInfo amInfo : job.getAMInfos()) {
|
for (AMInfo amInfo : job.getAMInfos()) {
|
||||||
|
@ -208,6 +219,7 @@ public class HsWebServices {
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public JobCounterInfo getJobCounters(@PathParam("jobid") String jid) {
|
public JobCounterInfo getJobCounters(@PathParam("jobid") String jid) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
||||||
return new JobCounterInfo(this.ctx, job);
|
return new JobCounterInfo(this.ctx, job);
|
||||||
}
|
}
|
||||||
|
@ -217,6 +229,7 @@ public class HsWebServices {
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public ConfInfo getJobConf(@PathParam("jobid") String jid) {
|
public ConfInfo getJobConf(@PathParam("jobid") String jid) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
||||||
ConfInfo info;
|
ConfInfo info;
|
||||||
try {
|
try {
|
||||||
|
@ -234,6 +247,7 @@ public class HsWebServices {
|
||||||
public TasksInfo getJobTasks(@PathParam("jobid") String jid,
|
public TasksInfo getJobTasks(@PathParam("jobid") String jid,
|
||||||
@QueryParam("type") String type) {
|
@QueryParam("type") String type) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
||||||
TasksInfo allTasks = new TasksInfo();
|
TasksInfo allTasks = new TasksInfo();
|
||||||
for (Task task : job.getTasks().values()) {
|
for (Task task : job.getTasks().values()) {
|
||||||
|
@ -259,6 +273,7 @@ public class HsWebServices {
|
||||||
public TaskInfo getJobTask(@PathParam("jobid") String jid,
|
public TaskInfo getJobTask(@PathParam("jobid") String jid,
|
||||||
@PathParam("taskid") String tid) {
|
@PathParam("taskid") String tid) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
||||||
Task task = AMWebServices.getTaskFromTaskIdString(tid, job);
|
Task task = AMWebServices.getTaskFromTaskIdString(tid, job);
|
||||||
return new TaskInfo(task);
|
return new TaskInfo(task);
|
||||||
|
@ -271,6 +286,7 @@ public class HsWebServices {
|
||||||
public JobTaskCounterInfo getSingleTaskCounters(
|
public JobTaskCounterInfo getSingleTaskCounters(
|
||||||
@PathParam("jobid") String jid, @PathParam("taskid") String tid) {
|
@PathParam("jobid") String jid, @PathParam("taskid") String tid) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
||||||
TaskId taskID = MRApps.toTaskID(tid);
|
TaskId taskID = MRApps.toTaskID(tid);
|
||||||
if (taskID == null) {
|
if (taskID == null) {
|
||||||
|
@ -289,6 +305,7 @@ public class HsWebServices {
|
||||||
public TaskAttemptsInfo getJobTaskAttempts(@PathParam("jobid") String jid,
|
public TaskAttemptsInfo getJobTaskAttempts(@PathParam("jobid") String jid,
|
||||||
@PathParam("taskid") String tid) {
|
@PathParam("taskid") String tid) {
|
||||||
|
|
||||||
|
init();
|
||||||
TaskAttemptsInfo attempts = new TaskAttemptsInfo();
|
TaskAttemptsInfo attempts = new TaskAttemptsInfo();
|
||||||
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
||||||
Task task = AMWebServices.getTaskFromTaskIdString(tid, job);
|
Task task = AMWebServices.getTaskFromTaskIdString(tid, job);
|
||||||
|
@ -310,6 +327,7 @@ public class HsWebServices {
|
||||||
public TaskAttemptInfo getJobTaskAttemptId(@PathParam("jobid") String jid,
|
public TaskAttemptInfo getJobTaskAttemptId(@PathParam("jobid") String jid,
|
||||||
@PathParam("taskid") String tid, @PathParam("attemptid") String attId) {
|
@PathParam("taskid") String tid, @PathParam("attemptid") String attId) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
||||||
Task task = AMWebServices.getTaskFromTaskIdString(tid, job);
|
Task task = AMWebServices.getTaskFromTaskIdString(tid, job);
|
||||||
TaskAttempt ta = AMWebServices.getTaskAttemptFromTaskAttemptString(attId,
|
TaskAttempt ta = AMWebServices.getTaskAttemptFromTaskAttemptString(attId,
|
||||||
|
@ -328,6 +346,7 @@ public class HsWebServices {
|
||||||
@PathParam("jobid") String jid, @PathParam("taskid") String tid,
|
@PathParam("jobid") String jid, @PathParam("taskid") String tid,
|
||||||
@PathParam("attemptid") String attId) {
|
@PathParam("attemptid") String attId) {
|
||||||
|
|
||||||
|
init();
|
||||||
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
|
||||||
Task task = AMWebServices.getTaskFromTaskIdString(tid, job);
|
Task task = AMWebServices.getTaskFromTaskIdString(tid, job);
|
||||||
TaskAttempt ta = AMWebServices.getTaskAttemptFromTaskAttemptString(attId,
|
TaskAttempt ta = AMWebServices.getTaskAttemptFromTaskAttemptString(attId,
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.hadoop.yarn.server.nodemanager.webapp;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
|
@ -58,8 +59,11 @@ public class NMWebServices {
|
||||||
private static RecordFactory recordFactory = RecordFactoryProvider
|
private static RecordFactory recordFactory = RecordFactoryProvider
|
||||||
.getRecordFactory(null);
|
.getRecordFactory(null);
|
||||||
|
|
||||||
|
private @javax.ws.rs.core.Context
|
||||||
|
HttpServletResponse response;
|
||||||
|
|
||||||
@javax.ws.rs.core.Context
|
@javax.ws.rs.core.Context
|
||||||
UriInfo uriInfo;
|
UriInfo uriInfo;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NMWebServices(final Context nm, final ResourceView view,
|
public NMWebServices(final Context nm, final ResourceView view,
|
||||||
|
@ -69,6 +73,11 @@ public class NMWebServices {
|
||||||
this.webapp = webapp;
|
this.webapp = webapp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
//clear content type
|
||||||
|
response.setContentType(null);
|
||||||
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public NodeInfo get() {
|
public NodeInfo get() {
|
||||||
|
@ -79,6 +88,7 @@ public class NMWebServices {
|
||||||
@Path("/info")
|
@Path("/info")
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public NodeInfo getNodeInfo() {
|
public NodeInfo getNodeInfo() {
|
||||||
|
init();
|
||||||
return new NodeInfo(this.nmContext, this.rview);
|
return new NodeInfo(this.nmContext, this.rview);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +97,7 @@ public class NMWebServices {
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public AppsInfo getNodeApps(@QueryParam("state") String stateQuery,
|
public AppsInfo getNodeApps(@QueryParam("state") String stateQuery,
|
||||||
@QueryParam("user") String userQuery) {
|
@QueryParam("user") String userQuery) {
|
||||||
|
init();
|
||||||
AppsInfo allApps = new AppsInfo();
|
AppsInfo allApps = new AppsInfo();
|
||||||
for (Entry<ApplicationId, Application> entry : this.nmContext
|
for (Entry<ApplicationId, Application> entry : this.nmContext
|
||||||
.getApplications().entrySet()) {
|
.getApplications().entrySet()) {
|
||||||
|
@ -116,6 +127,7 @@ public class NMWebServices {
|
||||||
@Path("/apps/{appid}")
|
@Path("/apps/{appid}")
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public AppInfo getNodeApp(@PathParam("appid") String appId) {
|
public AppInfo getNodeApp(@PathParam("appid") String appId) {
|
||||||
|
init();
|
||||||
ApplicationId id = ConverterUtils.toApplicationId(recordFactory, appId);
|
ApplicationId id = ConverterUtils.toApplicationId(recordFactory, appId);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new NotFoundException("app with id " + appId + " not found");
|
throw new NotFoundException("app with id " + appId + " not found");
|
||||||
|
@ -132,6 +144,7 @@ public class NMWebServices {
|
||||||
@Path("/containers")
|
@Path("/containers")
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public ContainersInfo getNodeContainers() {
|
public ContainersInfo getNodeContainers() {
|
||||||
|
init();
|
||||||
ContainersInfo allContainers = new ContainersInfo();
|
ContainersInfo allContainers = new ContainersInfo();
|
||||||
for (Entry<ContainerId, Container> entry : this.nmContext.getContainers()
|
for (Entry<ContainerId, Container> entry : this.nmContext.getContainers()
|
||||||
.entrySet()) {
|
.entrySet()) {
|
||||||
|
@ -151,6 +164,7 @@ public class NMWebServices {
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public ContainerInfo getNodeContainer(@PathParam("containerid") String id) {
|
public ContainerInfo getNodeContainer(@PathParam("containerid") String id) {
|
||||||
ContainerId containerId = null;
|
ContainerId containerId = null;
|
||||||
|
init();
|
||||||
try {
|
try {
|
||||||
containerId = ConverterUtils.toContainerId(id);
|
containerId = ConverterUtils.toContainerId(id);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Collection;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
|
@ -77,6 +78,8 @@ public class RMWebServices {
|
||||||
.getRecordFactory(null);
|
.getRecordFactory(null);
|
||||||
private final ApplicationACLsManager aclsManager;
|
private final ApplicationACLsManager aclsManager;
|
||||||
|
|
||||||
|
private @Context HttpServletResponse response;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RMWebServices(final ResourceManager rm,
|
public RMWebServices(final ResourceManager rm,
|
||||||
final ApplicationACLsManager aclsManager) {
|
final ApplicationACLsManager aclsManager) {
|
||||||
|
@ -100,6 +103,11 @@ public class RMWebServices {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
//clear content type
|
||||||
|
response.setContentType(null);
|
||||||
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public ClusterInfo get() {
|
public ClusterInfo get() {
|
||||||
|
@ -110,6 +118,7 @@ public class RMWebServices {
|
||||||
@Path("/info")
|
@Path("/info")
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public ClusterInfo getClusterInfo() {
|
public ClusterInfo getClusterInfo() {
|
||||||
|
init();
|
||||||
return new ClusterInfo(this.rm);
|
return new ClusterInfo(this.rm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,6 +126,7 @@ public class RMWebServices {
|
||||||
@Path("/metrics")
|
@Path("/metrics")
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public ClusterMetricsInfo getClusterMetricsInfo() {
|
public ClusterMetricsInfo getClusterMetricsInfo() {
|
||||||
|
init();
|
||||||
return new ClusterMetricsInfo(this.rm, this.rm.getRMContext());
|
return new ClusterMetricsInfo(this.rm, this.rm.getRMContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +134,7 @@ public class RMWebServices {
|
||||||
@Path("/scheduler")
|
@Path("/scheduler")
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public SchedulerTypeInfo getSchedulerInfo() {
|
public SchedulerTypeInfo getSchedulerInfo() {
|
||||||
|
init();
|
||||||
ResourceScheduler rs = rm.getResourceScheduler();
|
ResourceScheduler rs = rm.getResourceScheduler();
|
||||||
SchedulerInfo sinfo;
|
SchedulerInfo sinfo;
|
||||||
if (rs instanceof CapacityScheduler) {
|
if (rs instanceof CapacityScheduler) {
|
||||||
|
@ -143,6 +154,7 @@ public class RMWebServices {
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public NodesInfo getNodes(@QueryParam("state") String filterState,
|
public NodesInfo getNodes(@QueryParam("state") String filterState,
|
||||||
@QueryParam("healthy") String healthState) {
|
@QueryParam("healthy") String healthState) {
|
||||||
|
init();
|
||||||
ResourceScheduler sched = this.rm.getResourceScheduler();
|
ResourceScheduler sched = this.rm.getResourceScheduler();
|
||||||
if (sched == null) {
|
if (sched == null) {
|
||||||
throw new NotFoundException("Null ResourceScheduler instance");
|
throw new NotFoundException("Null ResourceScheduler instance");
|
||||||
|
@ -197,6 +209,7 @@ public class RMWebServices {
|
||||||
@Path("/nodes/{nodeId}")
|
@Path("/nodes/{nodeId}")
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public NodeInfo getNode(@PathParam("nodeId") String nodeId) {
|
public NodeInfo getNode(@PathParam("nodeId") String nodeId) {
|
||||||
|
init();
|
||||||
if (nodeId == null || nodeId.isEmpty()) {
|
if (nodeId == null || nodeId.isEmpty()) {
|
||||||
throw new NotFoundException("nodeId, " + nodeId + ", is empty or null");
|
throw new NotFoundException("nodeId, " + nodeId + ", is empty or null");
|
||||||
}
|
}
|
||||||
|
@ -246,6 +259,7 @@ public class RMWebServices {
|
||||||
long fBegin = 0;
|
long fBegin = 0;
|
||||||
long fEnd = Long.MAX_VALUE;
|
long fEnd = Long.MAX_VALUE;
|
||||||
|
|
||||||
|
init();
|
||||||
if (count != null && !count.isEmpty()) {
|
if (count != null && !count.isEmpty()) {
|
||||||
checkCount = true;
|
checkCount = true;
|
||||||
countNum = Long.parseLong(count);
|
countNum = Long.parseLong(count);
|
||||||
|
@ -355,6 +369,7 @@ public class RMWebServices {
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public AppInfo getApp(@Context HttpServletRequest hsr,
|
public AppInfo getApp(@Context HttpServletRequest hsr,
|
||||||
@PathParam("appid") String appId) {
|
@PathParam("appid") String appId) {
|
||||||
|
init();
|
||||||
if (appId == null || appId.isEmpty()) {
|
if (appId == null || appId.isEmpty()) {
|
||||||
throw new NotFoundException("appId, " + appId + ", is empty or null");
|
throw new NotFoundException("appId, " + appId + ", is empty or null");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue