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.
|
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 exceptionpublic String getMessage()
public List<QueryHandle> getAllQueries(LensSessionHandle sessionid, String states, String queryName, String user, String driver, String fromDate, 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
public LensAPIResult<QuerySubmitResult> query(LensSessionHandle sessionid, String query, String operation, LensConf conf, Long timeoutmillis, 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_TIMEOUT
conf
- 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
public APIResult cancelAllQueries(LensSessionHandle sessionid, String state, String user, String queryName, String driver, String fromDate, 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
public List<QueryPrepareHandle> getAllPreparedQueries(LensSessionHandle sessionid, String user, String queryName, String fromDate, 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
public LensAPIResult<QuerySubmitResult> prepareQuery(LensSessionHandle sessionid, String query, String operation, LensConf conf, 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.PREPARE
conf
- 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
public APIResult destroyPreparedQueries(LensSessionHandle sessionid, String user, String queryName, String fromDate, 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
public LensPreparedQuery getPreparedQuery(LensSessionHandle sessionid, String prepareHandle) throws LensException
sessionid
- The user session handleprepareHandle
- The prepare handleLensPreparedQuery
LensException
public APIResult destroyPrepared(LensSessionHandle sessionid, 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
public LensQuery getStatus(LensSessionHandle sessionid, String queryHandle) throws LensException
sessionid
- The user session handlequeryHandle
- The query handleLensQuery
LensException
public APIResult cancelQuery(LensSessionHandle sessionid, 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
public APIResult updateConf(LensSessionHandle sessionid, 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
public APIResult updatePreparedConf(LensSessionHandle sessionid, 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
public QuerySubmitResult executePrepared(LensSessionHandle sessionid, String prepareHandle, String operation, LensConf conf, Long timeoutmillis, 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_TIMEOUT
conf
- 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
public QueryResultSetMetadata getResultSetMetadata(LensSessionHandle sessionid, String queryHandle) throws LensException
sessionid
- The user session handlequeryHandle
- The query handleQueryResultSetMetadata
LensException
public QueryResult getResultSet(LensSessionHandle sessionid, String queryHandle, long startIndex, int fetchSize) throws LensException
sessionid
- The user session handlequeryHandle
- The query handlestartIndex
- start index of the resultfetchSize
- fetch sizeQueryResult
LensException
public javax.ws.rs.core.Response getHttpResultSet(LensSessionHandle sessionid, String queryHandle) throws LensException
sessionid
- The user session handlequeryHandle
- The query handleLensException
public APIResult closeResultSet(LensSessionHandle sessionid, 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.LensException
Copyright © 2014–2016 Apache Software Foundation. All rights reserved.