@Path(value="/queryapi") public class QueryServiceResource extends Object
| Constructor and Description |
|---|
QueryServiceResource()
Instantiates a new query service resource.
|
| Modifier and Type | Method and Description |
|---|---|
APIResult |
cancelAllQueries(LensSessionHandle sessionid,
String state,
String user,
String queryName,
String driver,
String fromDate,
String 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,
String fromDate,
String 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,
String fromDate,
String toDate)
Get all prepared queries in the query server; can be filtered with user.
|
List<QueryHandle> |
getAllQueries(LensSessionHandle sessionid,
String states,
String queryName,
String user,
String driver,
String fromDate,
String toDate)
Get all the queries in the query server; can be filtered with state and queryName.
|
List<LensQuery> |
getAllQueryDetails(LensSessionHandle sessionid,
String states,
String queryName,
String user,
String driver,
String fromDate,
String 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.
|
LensAPIResult<QuerySubmitResult> |
prepareQuery(LensSessionHandle sessionid,
String query,
String operation,
LensConf conf,
String queryName)
Prepare a query or 'explain and prepare' the query.
|
LensAPIResult<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.
|
public QueryServiceResource()
throws LensException
LensException - the lens exception@GET @Produces(value="text/plain") public String getMessage()
@GET
@Path(value="queries")
@Produces(value={"application/xml","application/json","text/plain"})
public List<QueryHandle> getAllQueries(@QueryParam(value="sessionid")
LensSessionHandle sessionid,
@QueryParam(value="state")
String states,
@QueryParam(value="queryName")
String queryName,
@QueryParam(value="user")
String user,
@QueryParam(value="driver")
String driver,
@QueryParam(value="fromDate")
String fromDate,
@QueryParam(value="toDate")
String toDate)
throws LensException
sessionid - The sessionid in which queryName is workingstates - If any state is passed, all the queries in that state will be returned, otherwise all queries will
be returned. Possible states are {link QueryStatus.Status#values()}. Multiple states can be
passed as comma separated stringqueryName - If any queryName is passed, all the queries containing the queryName will be returned, otherwise
all the queries will be returneduser - Returns queries submitted by this user. If set to "all", returns queries of all users. By default,
returns queries of the current user.driver - Get queries submitted on a specific driver.fromDate - from date to search queries in a time range, the range is inclusive(submitTime >= fromDate)
from date can be a long value indicating timestamp, or it can be in a format acceptable in
time_range_in function. Notably: yyyy[-MM[-dd[-HH-[mm...]]]], or now based relative formattoDate - to date to search queries in a time range, the range is inclusive(toDate > submitTime)
possible formats it can take is same as fromDateQueryHandle objectsLensException@GET
@Path(value="queries/detail")
@Produces(value={"application/xml","application/json","text/plain"})
public List<LensQuery> getAllQueryDetails(@QueryParam(value="sessionid")
LensSessionHandle sessionid,
@QueryParam(value="state")
String states,
@QueryParam(value="queryName")
String queryName,
@QueryParam(value="user")
String user,
@QueryParam(value="driver")
String driver,
@QueryParam(value="fromDate")
String fromDate,
@QueryParam(value="toDate")
String toDate)
throws LensException
sessionid - The sessionid in which queryName is workingstates - If any state is passed, all the queries in that state will be returned, otherwise all queries will
be returned. Possible states are {link QueryStatus.Status#values()}. Multiple states can be
passed as comma separated stringqueryName - If any queryName is passed, all the queries containing the queryName will be returned, otherwise
all the queries will be returneduser - Returns queries submitted by this user. If set to "all", returns queries of all users. By default,
returns queries of the current user.driver - Get queries submitted on a specific driver.fromDate - from date to search queries in a time range, the range is inclusive(submitTime >= fromDate)
from date can be a long value indicating timestamp, or it can be in a format acceptable in
time_range_in function. Notably: yyyy[-MM[-dd[-HH-[mm...]]]], or now based relative formattoDate - to date to search queries in a time range, the range is inclusive(toDate > submitTime)
possible formats it can take is same as fromDateLensQuery objectsLensException@POST
@Path(value="queries")
@Consumes(value="multipart/form-data")
@Produces(value={"application/xml","application/json","text/plain"})
public LensAPIResult<QuerySubmitResult> query(LensSessionHandle sessionid,
String query,
String operation,
LensConf conf,
@DefaultValue(value="30000")
Long timeoutmillis,
@DefaultValue(value="")
String queryName)
throws LensException
sessionid - The session in which user is submitting the query. Any configuration set in the session will
be picked up.query - The query to runoperation - The operation on the query. Supported operations are values:
SubmitOp.ESTIMATE,
SubmitOp.EXPLAIN,
SubmitOp.EXECUTE and
SubmitOp.EXECUTE_WITH_TIMEOUTconf - The configuration for the querytimeoutmillis - The timeout for the query. If the query does not finish within the specified
timeout, it is automatically cancelled unless user specified otherwise
by setting configuration lens.query.cancel.on.timeout = false.
SubmitOp.EXECUTE_WITH_TIMEOUT operationqueryName - human readable query name set by user (optional parameter)LensAPIResult with DATA as QueryHandle in case of
SubmitOp.EXECUTE operation.
QueryPlan in case of SubmitOp.EXPLAIN operation.
QueryHandleWithResultSet in case SubmitOp.EXECUTE_WITH_TIMEOUT
operation. QueryCostTO in case of
SubmitOp.ESTIMATE operation.LensException@DELETE
@Path(value="queries")
@Produces(value={"application/xml","application/json","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="") @QueryParam(value="driver")
String driver,
@QueryParam(value="fromDate")
String fromDate,
@QueryParam(value="toDate")
String toDate)
throws LensException
sessionid - The session in which cancel is issuedstate - If any state is passed, all the queries in that state will be cancelled, otherwise all queries
will be cancelled. Possible states are
QueryStatus.Status.values()
The queries in QueryStatus.Status.FAILED,
QueryStatus.Status.CLOSED,
QueryStatus.Status.SUCCESSFUL cannot be cancelleduser - If any user is passed, all the queries submitted by the user will be cancelled, otherwise all the
queries will be cancelleddriver - Get queries submitted on a specific driver.queryName - Cancel queries matching the query namefromDate - the from date, inclusive(submitTime>=fromDate)toDate - the to date, inclusive(toDate>=submitTime)APIResult.Status.SUCCEEDED in case of successful
cancellation. APIResult with state APIResult.Status.FAILED
in case of cancellation failure. APIResult with state
APIResult.Status.PARTIAL in case of partial cancellation.LensException@GET
@Path(value="preparedqueries")
@Produces(value={"application/xml","application/json","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,
@QueryParam(value="fromDate")
String fromDate,
@QueryParam(value="toDate")
String toDate)
throws LensException
sessionid - The sessionid in which user is workinguser - 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 namefromDate - start time for filtering prepared queries by preparation timetoDate - end time for filtering prepared queries by preparation timeLensException@POST
@Path(value="preparedqueries")
@Consumes(value="multipart/form-data")
@Produces(value={"application/xml","application/json","text/plain"})
public LensAPIResult<QuerySubmitResult> prepareQuery(LensSessionHandle sessionid,
String query,
@DefaultValue(value="")
String operation,
LensConf conf,
@DefaultValue(value="")
String queryName)
throws LensException
sessionid - The session in which user is preparing the query. Any configuration set in the session will be
picked up.query - The query to prepareoperation - The operation on the query. Supported operations are
SubmitOp.EXPLAIN_AND_PREPARE or
SubmitOp.PREPAREconf - The configuration for preparing the queryqueryName - human readable query name set by user (optional parameter)QueryPrepareHandle incase of {link org.apache.lens.api.query.SubmitOp#PREPARE} operation.
QueryPlan incase of SubmitOp.EXPLAIN_AND_PREPARE
and the query plan will contain the prepare handle as well.LensException@DELETE
@Path(value="preparedqueries")
@Produces(value={"application/xml","application/json","text/plain"})
public APIResult destroyPreparedQueries(@QueryParam(value="sessionid")
LensSessionHandle sessionid,
@DefaultValue(value="") @QueryParam(value="user")
String user,
@DefaultValue(value="") @QueryParam(value="queryName")
String queryName,
@QueryParam(value="fromDate")
String fromDate,
@QueryParam(value="toDate")
String toDate)
throws LensException
sessionid - The session in which cancel is issueduser - 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 namefromDate - the from datetoDate - the to dateAPIResult.Status.SUCCEEDED in case of successful
destroy. APIResult with state APIResult.Status.FAILED in case of destroy
failure. APIResult with state APIResult.Status.PARTIAL in case of
partial destroy.LensException@GET
@Path(value="preparedqueries/{prepareHandle}")
@Produces(value={"application/xml","application/json","text/plain"})
public LensPreparedQuery getPreparedQuery(@QueryParam(value="sessionid")
LensSessionHandle sessionid,
@PathParam(value="prepareHandle")
String prepareHandle)
throws LensException
sessionid - The user session handleprepareHandle - The prepare handleLensPreparedQueryLensException@DELETE
@Path(value="preparedqueries/{prepareHandle}")
@Produces(value={"application/xml","application/json","text/plain"})
public APIResult destroyPrepared(@QueryParam(value="sessionid")
LensSessionHandle sessionid,
@PathParam(value="prepareHandle")
String prepareHandle)
throws LensException
sessionid - The user session handleprepareHandle - The prepare handleAPIResult.Status.SUCCEEDED in case of successful
destroy. APIResult with state APIResult.Status.FAILED in case of
destroy failure.LensException@GET
@Path(value="queries/{queryHandle}")
@Produces(value={"application/xml","application/json","text/plain"})
public LensQuery getStatus(@QueryParam(value="sessionid")
LensSessionHandle sessionid,
@PathParam(value="queryHandle")
String queryHandle)
throws LensException
sessionid - The user session handlequeryHandle - The query handleLensQueryLensException@DELETE
@Path(value="queries/{queryHandle}")
@Produces(value={"application/xml","application/json","text/plain"})
public APIResult cancelQuery(@QueryParam(value="sessionid")
LensSessionHandle sessionid,
@PathParam(value="queryHandle")
String queryHandle)
throws LensException
sessionid - The user session handlequeryHandle - The query handleAPIResult.Status.SUCCEEDED in case of successful
cancellation. APIResult with state APIResult.Status.FAILED in case of
cancellation failure.LensException@PUT
@Path(value="queries/{queryHandle}")
@Consumes(value="multipart/form-data")
@Produces(value={"application/xml","application/json","text/plain"})
public APIResult updateConf(LensSessionHandle sessionid,
@PathParam(value="queryHandle")
String queryHandle,
LensConf conf)
throws LensException
sessionid - The user session handlequeryHandle - The query handleconf - The new configuration, will be on top of old oneAPIResult.Status.SUCCEEDED in case of successful
update. APIResult with state APIResult.Status.FAILED in case of udpate failure.LensException@PUT
@Path(value="preparedqueries/{prepareHandle}")
@Consumes(value="multipart/form-data")
@Produces(value={"application/xml","application/json","text/plain"})
public APIResult updatePreparedConf(LensSessionHandle sessionid,
@PathParam(value="prepareHandle")
String prepareHandle,
LensConf conf)
throws LensException
sessionid - The user session handleprepareHandle - The prepare handleconf - The new configuration, will be on top of old oneAPIResult.Status.SUCCEEDED in case of successful
update. APIResult with state APIResult.Status.FAILED in case of udpate failure.LensException@POST
@Path(value="preparedqueries/{prepareHandle}")
@Consumes(value="multipart/form-data")
@Produces(value={"application/xml","application/json","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)
throws LensException
sessionid - The session in which user is submitting the query. Any configuration set in the session will
be picked up.prepareHandle - The Query to runoperation - The operation on the query. Supported operations are
SubmitOp.EXECUTE and SubmitOp.EXECUTE_WITH_TIMEOUTconf - The configuration for the execution of querytimeoutmillis - The timeout for the query, honored only in case of
SubmitOp.EXECUTE_WITH_TIMEOUT operationqueryName - human readable query name set by user (optional parameter)QueryHandle in case of {link org.apache.lens.api.query.SubmitOp#EXECUTE} operation.
QueryHandleWithResultSet in case SubmitOp.EXECUTE_WITH_TIMEOUT operation.LensException@GET
@Path(value="queries/{queryHandle}/resultsetmetadata")
@Produces(value={"application/xml","application/json","text/plain"})
public QueryResultSetMetadata getResultSetMetadata(@QueryParam(value="sessionid")
LensSessionHandle sessionid,
@PathParam(value="queryHandle")
String queryHandle)
throws LensException
sessionid - The user session handlequeryHandle - The query handleQueryResultSetMetadataLensException@GET
@Path(value="queries/{queryHandle}/resultset")
@Produces(value={"application/xml","application/json","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)
throws LensException
sessionid - The user session handlequeryHandle - The query handlestartIndex - start index of the resultfetchSize - fetch sizeQueryResultLensException@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)
throws LensException
sessionid - The user session handlequeryHandle - The query handleLensException@DELETE
@Path(value="queries/{queryHandle}/resultset")
@Produces(value={"application/xml","application/json","text/plain"})
public APIResult closeResultSet(@QueryParam(value="sessionid")
LensSessionHandle sessionid,
@PathParam(value="queryHandle")
String queryHandle)
throws LensException
sessionid - The user session handlequeryHandle - The query handleAPIResult.Status.SUCCEEDED in case of successful
close. APIResult with state APIResult.Status.FAILED in case of close failure.LensExceptionCopyright © 2014–2018 Apache Software Foundation. All rights reserved.