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 1523516) +++ hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java (working copy) @@ -681,14 +681,57 @@ /** * 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 { + 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 { + 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 { + 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); @@ -699,9 +742,9 @@ * Kill a job in the queue. */ @DELETE - @Path("queue/{jobid}") + @Path("jobs/{jobid}") @Produces({MediaType.APPLICATION_JSON}) - public QueueStatusBean deleteQueueId(@PathParam("jobid") String jobid) + public QueueStatusBean deleteJobId(@PathParam("jobid") String jobid) throws NotAuthorizedException, BadParam, IOException, InterruptedException { verifyUser(); @@ -715,15 +758,36 @@ * Return all the known job ids for this user. */ @GET - @Path("queue") + @Path("jobs") @Produces({MediaType.APPLICATION_JSON}) - public List showQueueList(@QueryParam("showall") boolean showall) + 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,38 @@ +/** + * 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.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 1523516) +++ 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/*",