Index: hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java =================================================================== --- hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java (revision 1521302) +++ hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java (working copy) @@ -681,49 +681,113 @@ /** * Return the status of the jobid. + * @deprecated use GET jobs/{jobid} instead. */ + @Deprecated @GET @Path("queue/{jobid}") @Produces({MediaType.APPLICATION_JSON}) public QueueStatusBean showQueueId(@PathParam("jobid") String jobid) - throws NotAuthorizedException, BadParam, IOException, InterruptedException { - - verifyUser(); - verifyParam(jobid, ":jobid"); - - StatusDelegator d = new StatusDelegator(appConf); - return d.run(getDoAsUser(), jobid); + throws NotAuthorizedException, BadParam, IOException, InterruptedException { + return showJobId(jobid); } /** * Kill a job in the queue. + * @deprecated use DELETE jobs/{jobid} instead. */ + @Deprecated @DELETE @Path("queue/{jobid}") @Produces({MediaType.APPLICATION_JSON}) public QueueStatusBean deleteQueueId(@PathParam("jobid") String jobid) - throws NotAuthorizedException, BadParam, IOException, InterruptedException { - - verifyUser(); - verifyParam(jobid, ":jobid"); - - DeleteDelegator d = new DeleteDelegator(appConf); - return d.run(getDoAsUser(), jobid); + throws NotAuthorizedException, BadParam, IOException, InterruptedException { + return deleteJobId(jobid); } /** * Return all the known job ids for this user. + * @deprecated use GET jobs instead. */ + @Deprecated @GET @Path("queue") @Produces({MediaType.APPLICATION_JSON}) public List showQueueList(@QueryParam("showall") boolean showall) - throws NotAuthorizedException, BadParam, IOException, InterruptedException { + throws NotAuthorizedException, BadParam, IOException, InterruptedException { + verifyUser(); + + ListDelegator d = new ListDelegator(appConf); + return d.run(getDoAsUser(), showall); + } + + /** + * Return the status of the jobid. + */ + @GET + @Path("jobs/{jobid}") + @Produces({MediaType.APPLICATION_JSON}) + public QueueStatusBean showJobId(@PathParam("jobid") String jobid) + throws NotAuthorizedException, BadParam, IOException, InterruptedException { + + verifyUser(); + verifyParam(jobid, ":jobid"); + + StatusDelegator d = new StatusDelegator(appConf); + return d.run(getDoAsUser(), jobid); + } + + /** + * Kill a job in the queue. + */ + @DELETE + @Path("jobs/{jobid}") + @Produces({MediaType.APPLICATION_JSON}) + public QueueStatusBean deleteJobId(@PathParam("jobid") String jobid) + throws NotAuthorizedException, BadParam, IOException, InterruptedException { + + verifyUser(); + verifyParam(jobid, ":jobid"); + + DeleteDelegator d = new DeleteDelegator(appConf); + return d.run(getDoAsUser(), jobid); + } + + /** + * Return all the known job ids for this user. + */ + @GET + @Path("jobs") + @Produces({MediaType.APPLICATION_JSON}) + public List showJobList(@QueryParam("fields") String fields, + @QueryParam("showall") boolean showall) + throws NotAuthorizedException, BadParam, IOException, InterruptedException { + verifyUser(); - ListDelegator d = new ListDelegator(appConf); - return d.run(getDoAsUser(), showall); + boolean showDetails = false; + if (fields!=null && !fields.equals("*")) { + throw new BadParam("fields value other than * is not supported"); + } + if (fields!=null && fields.equals("*")) { + showDetails = true; + } + + ListDelegator ld = new ListDelegator(appConf); + List list = ld.run(getDoAsUser(), showall); + List detailList = new ArrayList(); + for (String job : list) { + JobItemBean jobItem = new JobItemBean(); + jobItem.id = job; + if (showDetails) { + StatusDelegator sd = new StatusDelegator(appConf); + QueueStatusBean statusBean = sd.run(getDoAsUser(), job); + jobItem.detail = statusBean; + } + detailList.add(jobItem); + } + return detailList; } /** Index: hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/JobItemBean.java =================================================================== --- hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/JobItemBean.java (revision 0) +++ hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/JobItemBean.java (revision 0) @@ -0,0 +1,20 @@ +package org.apache.hive.hcatalog.templeton; + +public class JobItemBean { + public String id; + public QueueStatusBean detail; + + public JobItemBean() { + } + + /** + * Create a new JobItemBean + * + * @param id job id + * @param detail job detail + */ + public JobItemBean(String id, QueueStatusBean detail) { + this.id = id; + this.detail = detail; + } +} Index: hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Main.java =================================================================== --- hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Main.java (revision 1521302) +++ hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Main.java (working copy) @@ -176,6 +176,8 @@ FilterMapping.REQUEST); root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/queue/*", FilterMapping.REQUEST); + root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/jobs/*", + FilterMapping.REQUEST); root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/mapreduce/*", FilterMapping.REQUEST); root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/status/*",