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