org.apache.lens.server.query
Class QueryServiceResource

java.lang.Object
  extended by org.apache.lens.server.query.QueryServiceResource

@Path(value="/queryapi")
public class QueryServiceResource
extends Object

queryapi resource

This provides api for all things query.


Field Summary
static org.apache.log4j.Logger LOG
          The Constant LOG.
 
Constructor Summary
QueryServiceResource()
          Instantiates a new query service resource.
 
Method Summary
 APIResult cancelAllQueries(LensSessionHandle sessionid, String state, String user, String queryName, long fromDate, long toDate)
          Cancel all the queries in query server; can be filtered with state and user.
 APIResult cancelQuery(LensSessionHandle sessionid, String queryHandle)
          Cancel the query specified by the handle.
 APIResult closeResultSet(LensSessionHandle sessionid, String queryHandle)
          Close the result set once fetching is done.
 APIResult destroyPrepared(LensSessionHandle sessionid, String prepareHandle)
          Destroy the prepared query specified by handle.
 APIResult destroyPreparedQueries(LensSessionHandle sessionid, String user, String queryName, long fromDate, long toDate)
          Destroy all the prepared queries; Can be filtered with user.
 QuerySubmitResult executePrepared(LensSessionHandle sessionid, String prepareHandle, String operation, LensConf conf, Long timeoutmillis, String queryName)
          Submit prepared query for execution.
 List<QueryPrepareHandle> getAllPreparedQueries(LensSessionHandle sessionid, String user, String queryName, long fromDate, long toDate)
          Get all prepared queries in the query server; can be filtered with user.
 List<QueryHandle> getAllQueries(LensSessionHandle sessionid, String state, String queryName, String user, long fromDate, long toDate)
          Get all the queries in the query server; can be filtered with state and queryName.
 javax.ws.rs.core.Response getHttpResultSet(LensSessionHandle sessionid, String queryHandle)
          Get the http endpoint for result set.
 String getMessage()
          API to know if Query service is up and running
 LensPreparedQuery getPreparedQuery(LensSessionHandle sessionid, String prepareHandle)
          Get a prepared query specified by handle.
 QueryResult getResultSet(LensSessionHandle sessionid, String queryHandle, long startIndex, int fetchSize)
          Fetch the result set.
 QueryResultSetMetadata getResultSetMetadata(LensSessionHandle sessionid, String queryHandle)
          Get resultset metadata of the query.
 LensQuery getStatus(LensSessionHandle sessionid, String queryHandle)
          Get lens query and its current status.
 QuerySubmitResult prepareQuery(LensSessionHandle sessionid, String query, String operation, LensConf conf, String queryName)
          Prepare a query or 'explain and prepare' the query.
 QuerySubmitResult query(LensSessionHandle sessionid, String query, String operation, LensConf conf, Long timeoutmillis, String queryName)
          Submit the query for explain or execute or execute with a timeout.
 APIResult updateConf(LensSessionHandle sessionid, String queryHandle, LensConf conf)
          Modify query configuration if it is not running yet.
 APIResult updatePreparedConf(LensSessionHandle sessionid, String prepareHandle, LensConf conf)
          Modify prepared query's configuration.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
The Constant LOG.

Constructor Detail

QueryServiceResource

public QueryServiceResource()
                     throws LensException
Instantiates a new query service resource.

Throws:
LensException - the lens exception
Method Detail

getMessage

@GET
@Produces(value="text/plain")
public String getMessage()
API to know if Query service is up and running

Returns:
Simple text saying it up

getAllQueries

@GET
@Path(value="queries")
@Produces(value={"application/json","application/xml","text/plain"})
public List<QueryHandle> getAllQueries(@QueryParam(value="sessionid")
                                                         LensSessionHandle sessionid,
                                                         @DefaultValue(value="")@QueryParam(value="state")
                                                         String state,
                                                         @DefaultValue(value="")@QueryParam(value="queryName")
                                                         String queryName,
                                                         @DefaultValue(value="")@QueryParam(value="user")
                                                         String user,
                                                         @DefaultValue(value="-1")@QueryParam(value="fromDate")
                                                         long fromDate,
                                                         @DefaultValue(value="-1")@QueryParam(value="toDate")
                                                         long toDate)
Get all the queries in the query server; can be filtered with state and queryName. This will by default only return queries submitted by the user that has started the session. To get queries of all users, set the searchAllUsers parameter to false.

Parameters:
sessionid - The sessionid in which queryName is working
state - If any state is passed, all the queries in that state will be returned, otherwise all queries will be returned. Possible states are
queryName - If any queryName is passed, all the queries containing the queryName will be returned, otherwise all the queries will be returned
user - Returns queries submitted by this user. If set to "all", returns queries of all users. By default, returns queries of the current user.
fromDate - from date to search queries in a time range, the range is inclusive(submitTime >= fromDate)
toDate - to date to search queries in a time range, the range is inclusive(toDate >= submitTime)
Returns:
List of QueryHandle objects

query

@POST
@Path(value="queries")
@Consumes(value="multipart/form-data")
@Produces(value={"application/json","application/xml","text/plain"})
public QuerySubmitResult query(LensSessionHandle sessionid,
                                                           String query,
                                                           String operation,
                                                           LensConf conf,
                                                           @DefaultValue(value="30000")
                                                           Long timeoutmillis,
                                                           @DefaultValue(value="")
                                                           String queryName)
Submit the query for explain or execute or execute with a timeout.

Parameters:
sessionid - The session in which user is submitting the query. Any configuration set in the session will be picked up.
query - The query to run
operation - The operation on the query. Supported operations are values: , , and
conf - The configuration for the query
timeoutmillis - The timeout for the query, honored only in case of value operation
queryName - human readable query name set by user (optional parameter)
Returns:
QueryHandle in case of operation. QueryPlan in case of operation. QueryHandleWithResultSet in case operation. EstimateResult in case of operation.

cancelAllQueries

@DELETE
@Path(value="queries")
@Produces(value={"application/json","application/xml","text/plain"})
public APIResult cancelAllQueries(@QueryParam(value="sessionid")
                                                       LensSessionHandle sessionid,
                                                       @DefaultValue(value="")@QueryParam(value="state")
                                                       String state,
                                                       @DefaultValue(value="")@QueryParam(value="user")
                                                       String user,
                                                       @DefaultValue(value="")@QueryParam(value="queryName")
                                                       String queryName,
                                                       @DefaultValue(value="-1")@QueryParam(value="fromDate")
                                                       long fromDate,
                                                       @DefaultValue(value="-1")@QueryParam(value="toDate")
                                                       long toDate)
Cancel all the queries in query server; can be filtered with state and user.

Parameters:
sessionid - The session in which cancel is issued
state - If any state is passed, all the queries in that state will be cancelled, otherwise all queries will be cancelled. Possible states are The queries in , , cannot be cancelled
user - If any user is passed, all the queries submitted by the user will be cancelled, otherwise all the queries will be cancelled
queryName - Cancel queries matching the query name
fromDate - the from date, inclusive(submitTime>=fromDate)
toDate - the to date, inclusive(toDate>=submitTime)
Returns:
APIResult with state in case of successful cancellation. APIResult with state in case of cancellation failure. APIResult with state in case of partial cancellation.

getAllPreparedQueries

@GET
@Path(value="preparedqueries")
@Produces(value={"application/json","application/xml","text/plain"})
public List<QueryPrepareHandle> getAllPreparedQueries(@QueryParam(value="sessionid")
                                                                        LensSessionHandle sessionid,
                                                                        @DefaultValue(value="")@QueryParam(value="user")
                                                                        String user,
                                                                        @DefaultValue(value="")@QueryParam(value="queryName")
                                                                        String queryName,
                                                                        @DefaultValue(value="-1")@QueryParam(value="fromDate")
                                                                        long fromDate,
                                                                        @DefaultValue(value="-1")@QueryParam(value="toDate")
                                                                        long toDate)
Get all prepared queries in the query server; can be filtered with user.

Parameters:
sessionid - The sessionid in which user is working
user - returns queries of the user. If set to "all", returns queries of all users. By default returns the queries of the current user.
queryName - returns queries matching the query name
fromDate - start time for filtering prepared queries by preparation time
toDate - end time for filtering prepared queries by preparation time
Returns:
List of QueryPrepareHandle objects

prepareQuery

@POST
@Path(value="preparedqueries")
@Consumes(value="multipart/form-data")
@Produces(value={"application/json","application/xml","text/plain"})
public QuerySubmitResult prepareQuery(LensSessionHandle sessionid,
                                                                  String query,
                                                                  @DefaultValue(value="")
                                                                  String operation,
                                                                  LensConf conf,
                                                                  @DefaultValue(value="")
                                                                  String queryName)
Prepare a query or 'explain and prepare' the query.

Parameters:
sessionid - The session in which user is preparing the query. Any configuration set in the session will be picked up.
query - The query to prepare
operation - The operation on the query. Supported operations are or
conf - The configuration for preparing the query
queryName - human readable query name set by user (optional parameter)
Returns:
QueryPrepareHandle incase of operation. QueryPlan incase of and the query plan will contain the prepare handle as well.

destroyPreparedQueries

@DELETE
@Path(value="preparedqueries")
@Produces(value={"application/json","application/xml","text/plain"})
public APIResult destroyPreparedQueries(@QueryParam(value="sessionid")
                                                             LensSessionHandle sessionid,
                                                             @DefaultValue(value="")@QueryParam(value="user")
                                                             String user,
                                                             @DefaultValue(value="")@QueryParam(value="queryName")
                                                             String queryName,
                                                             @DefaultValue(value="-1")@QueryParam(value="fromDate")
                                                             long fromDate,
                                                             @DefaultValue(value="-1")@QueryParam(value="toDate")
                                                             long toDate)
Destroy all the prepared queries; Can be filtered with user.

Parameters:
sessionid - The session in which cancel is issued
user - destroys queries of the user. If set to "all", destroys queries of all users. By default destroys the queries of the current user.
queryName - destroys queries matching the query name
fromDate - the from date
toDate - the to date
Returns:
APIResult with state in case of successful destroy. APIResult with state in case of destroy failure. APIResult with state in case of partial destroy.

getPreparedQuery

@GET
@Path(value="preparedqueries/{prepareHandle}")
@Produces(value={"application/json","application/xml","text/plain"})
public LensPreparedQuery getPreparedQuery(@QueryParam(value="sessionid")
                                                            LensSessionHandle sessionid,
                                                            @PathParam(value="prepareHandle")
                                                            String prepareHandle)
Get a prepared query specified by handle.

Parameters:
sessionid - The user session handle
prepareHandle - The prepare handle
Returns:
LensPreparedQuery

destroyPrepared

@DELETE
@Path(value="preparedqueries/{prepareHandle}")
@Produces(value={"application/json","application/xml","text/plain"})
public APIResult destroyPrepared(@QueryParam(value="sessionid")
                                                      LensSessionHandle sessionid,
                                                      @PathParam(value="prepareHandle")
                                                      String prepareHandle)
Destroy the prepared query specified by handle.

Parameters:
sessionid - The user session handle
prepareHandle - The prepare handle
Returns:
APIResult with state APIResult.Status.SUCCEEDED in case of successful destroy. APIResult with state APIResult.Status.FAILED in case of destroy failure.

getStatus

@GET
@Path(value="queries/{queryHandle}")
@Produces(value={"application/json","application/xml","text/plain"})
public LensQuery getStatus(@QueryParam(value="sessionid")
                                             LensSessionHandle sessionid,
                                             @PathParam(value="queryHandle")
                                             String queryHandle)
Get lens query and its current status.

Parameters:
sessionid - The user session handle
queryHandle - The query handle
Returns:
LensQuery

cancelQuery

@DELETE
@Path(value="queries/{queryHandle}")
@Produces(value={"application/json","application/xml","text/plain"})
public APIResult cancelQuery(@QueryParam(value="sessionid")
                                                  LensSessionHandle sessionid,
                                                  @PathParam(value="queryHandle")
                                                  String queryHandle)
Cancel the query specified by the handle.

Parameters:
sessionid - The user session handle
queryHandle - The query handle
Returns:
APIResult with state in case of successful cancellation. APIResult with state in case of cancellation failure.

updateConf

@PUT
@Path(value="queries/{queryHandle}")
@Consumes(value="multipart/form-data")
@Produces(value={"application/json","application/xml","text/plain"})
public APIResult updateConf(LensSessionHandle sessionid,
                                                       @PathParam(value="queryHandle")
                                                       String queryHandle,
                                                       LensConf conf)
Modify query configuration if it is not running yet.

Parameters:
sessionid - The user session handle
queryHandle - The query handle
conf - The new configuration, will be on top of old one
Returns:
APIResult with state in case of successful update. APIResult with state in case of udpate failure.

updatePreparedConf

@PUT
@Path(value="preparedqueries/{prepareHandle}")
@Consumes(value="multipart/form-data")
@Produces(value={"application/json","application/xml","text/plain"})
public APIResult updatePreparedConf(LensSessionHandle sessionid,
                                                               @PathParam(value="prepareHandle")
                                                               String prepareHandle,
                                                               LensConf conf)
Modify prepared query's configuration. This would be picked up for subsequent runs of the prepared queries. The query wont be re-prepared with new configuration.

Parameters:
sessionid - The user session handle
prepareHandle - The prepare handle
conf - The new configuration, will be on top of old one
Returns:
APIResult with state in case of successful update. APIResult with state in case of udpate failure.

executePrepared

@POST
@Path(value="preparedqueries/{prepareHandle}")
@Consumes(value="multipart/form-data")
@Produces(value={"application/json","application/xml","text/plain"})
public QuerySubmitResult executePrepared(LensSessionHandle sessionid,
                                                                     @PathParam(value="prepareHandle")
                                                                     String prepareHandle,
                                                                     @DefaultValue(value="EXECUTE")
                                                                     String operation,
                                                                     LensConf conf,
                                                                     @DefaultValue(value="30000")
                                                                     Long timeoutmillis,
                                                                     @DefaultValue(value="")
                                                                     String queryName)
Submit prepared query for execution.

Parameters:
sessionid - The session in which user is submitting the query. Any configuration set in the session will be picked up.
prepareHandle - The Query to run
operation - The operation on the query. Supported operations are and
conf - The configuration for the execution of query
timeoutmillis - The timeout for the query, honored only in case of operation
queryName - human readable query name set by user (optional parameter)
Returns:
QueryHandle in case of operation. QueryHandleWithResultSet in case operation.

getResultSetMetadata

@GET
@Path(value="queries/{queryHandle}/resultsetmetadata")
@Produces(value={"application/json","application/xml","text/plain"})
public QueryResultSetMetadata getResultSetMetadata(@QueryParam(value="sessionid")
                                                                     LensSessionHandle sessionid,
                                                                     @PathParam(value="queryHandle")
                                                                     String queryHandle)
Get resultset metadata of the query.

Parameters:
sessionid - The user session handle
queryHandle - The query handle
Returns:
QueryResultSetMetadata

getResultSet

@GET
@Path(value="queries/{queryHandle}/resultset")
@Produces(value={"application/json","application/xml","text/plain"})
public QueryResult getResultSet(@QueryParam(value="sessionid")
                                                  LensSessionHandle sessionid,
                                                  @PathParam(value="queryHandle")
                                                  String queryHandle,
                                                  @QueryParam(value="fromindex")
                                                  long startIndex,
                                                  @QueryParam(value="fetchsize")
                                                  int fetchSize)
Fetch the result set.

Parameters:
sessionid - The user session handle
queryHandle - The query handle
startIndex - start index of the result
fetchSize - fetch size
Returns:
QueryResult

getHttpResultSet

@GET
@Path(value="queries/{queryHandle}/httpresultset")
@Produces(value="application/octet-stream")
public javax.ws.rs.core.Response getHttpResultSet(@QueryParam(value="sessionid")
                                                                    LensSessionHandle sessionid,
                                                                    @PathParam(value="queryHandle")
                                                                    String queryHandle)
Get the http endpoint for result set.

Parameters:
sessionid - The user session handle
queryHandle - The query handle
Returns:
Response with result as octet stream

closeResultSet

@DELETE
@Path(value="queries/{queryHandle}/resultset")
@Produces(value={"application/json","application/xml","text/plain"})
public APIResult closeResultSet(@QueryParam(value="sessionid")
                                                     LensSessionHandle sessionid,
                                                     @PathParam(value="queryHandle")
                                                     String queryHandle)
Close the result set once fetching is done.

Parameters:
sessionid - The user session handle
queryHandle - The query handle
Returns:
APIResult with state in case of successful close. APIResult with state in case of close failure.


Copyright © 2014–2015 Apache Software Foundation. All rights reserved.