@Component @UserDocumentation(title="Commands for Query Management", description="This section provides commands for query life cycle - submit, check status,\n fetch results, kill or list all the queries. Also provides commands for\n prepare a query, destroy a prepared query and list all prepared queries.\n\n Please note that, character <<<\">>> is used as delimiter by the Spring Shell\n framework, which is used to build lens cli. So queries which require <<<\">>>,\n should be prefixed with another double quote. For example\n <<>>,\n will be parsed as << >>") public class LensQueryCommands extends BaseLensCommand
DATE_FMT, DATE_PARSER| Constructor and Description |
|---|
LensQueryCommands() |
| Modifier and Type | Method and Description |
|---|---|
String |
destroyPreparedQuery(String ph)
Destroy prepared query.
|
String |
executePreparedQuery(String phandle,
boolean async,
String queryName)
Execute prepared query.
|
String |
executeQuery(String sql,
boolean async,
String queryName)
Execute query.
|
String |
explainAndPrepare(String sql,
String queryName)
Explain and prepare.
|
String |
explainQuery(String sql,
File path)
Explain query.
|
String |
getAllPreparedQueries(String queryName,
String userName,
long fromDate,
long toDate)
Gets the all prepared queries.
|
String |
getAllQueries(String state,
String queryName,
String user,
long fromDate,
long toDate)
Gets the all queries.
|
String |
getDetails(String qh)
Gets the query details.
|
String |
getPreparedStatus(String ph)
Gets the prepared status.
|
String |
getQueryResults(String qh,
File path,
boolean async)
Gets the query results.
|
String |
getStatus(String qh)
Gets the status.
|
String |
killQuery(String qh)
Kill query.
|
String |
prepare(String sql,
String queryName)
Prepare.
|
afterReturningInvocation, afterThrowingInvocation, beforeInvocation, formatDate, formatJson, getClient, getClientWrapper, getValidPath, removePrefixBeforeURI, setClient@CliCommand(value="query execute",
help="Execute query . If is true, The query is launched in async manner and query handle is returned. It\'s by default false. can also be provided, though not required")
public String executeQuery(@CliOption(key={"","query"},mandatory=true,help="")
String sql,
@CliOption(key="async",mandatory=false,unspecifiedDefaultValue="false",specifiedDefaultValue="true",help="")
boolean async,
@CliOption(key="name",mandatory=false,help="")
String queryName)
sql - the sqlasync - the asynchqueryName - the query name@CliCommand(value="query status",
help="Fetch status of executed query having query handle ")
public String getStatus(@CliOption(key={"","query_handle"},mandatory=true,help="")
String qh)
qh - the qh@CliCommand(value="query details",
help="Get query details of query with handle ")
public String getDetails(@CliOption(key={"","query_handle"},mandatory=true,help="")
String qh)
qh - the qh@CliCommand(value="query explain",
help="Explain execution plan of query . Can optionally save the plan to a file by providing ")
public String explainQuery(@CliOption(key={"","query"},mandatory=true,help="")
String sql,
@CliOption(key="save_location",mandatory=false,help="")
File path)
throws IOException,
LensAPIException
sql - the sqllocation - the locationLensAPIExceptionUnsupportedEncodingException - the unsupported encoding exceptionIOException@CliCommand(value="query list",
help="Get all queries. Various filter options can be provided(optionally), as can be seen from the command syntax")
public String getAllQueries(@CliOption(key="state",mandatory=false,help="")
String state,
@CliOption(key="name",mandatory=false,help="")
String queryName,
@CliOption(key="user",mandatory=false,help="")
String user,
@CliOption(key="fromDate",mandatory=false,unspecifiedDefaultValue="-1",help="")
long fromDate,
@CliOption(key="toDate",mandatory=false,unspecifiedDefaultValue="9223372036854775807",help="")
long toDate)
state - the statequeryName - the query nameuser - the userfromDate - the from datetoDate - the to date@CliCommand(value="query kill",
help="Kill query with handle ")
public String killQuery(@CliOption(key={"","query_handle"},mandatory=true,help="")
String qh)
qh - the qh@CliCommand(value="query results",
help="get results of query with query handle . If async is false then wait till the query execution is completed, it\'s by default true. Can optionally save the results to a file by providing .")
public String getQueryResults(@CliOption(key={"","query_handle"},mandatory=true,help="")
String qh,
@CliOption(key="save_location",mandatory=false,help="")
File path,
@CliOption(key="async",mandatory=false,unspecifiedDefaultValue="true",help="")
boolean async)
qh - the qh@CliCommand(value="prepQuery list",
help="Get all prepared queries. Various filters can be provided(optionally) as can be seen from command syntax")
public String getAllPreparedQueries(@CliOption(key="name",mandatory=false,help="")
String queryName,
@CliOption(key="user",mandatory=false,help="")
String userName,
@CliOption(key="fromDate",mandatory=false,unspecifiedDefaultValue="-1",help="")
long fromDate,
@CliOption(key="toDate",mandatory=false,unspecifiedDefaultValue="9223372036854775807",help="")
long toDate)
userName - the user namequeryName - the query namefromDate - the from datetoDate - the to date@CliCommand(value="prepQuery details",
help="Get prepared query with handle ")
public String getPreparedStatus(@CliOption(key={"","prepare_handle"},mandatory=true,help="")
String ph)
ph - the ph@CliCommand(value="prepQuery destroy",
help="Destroy prepared query with handle ")
public String destroyPreparedQuery(@CliOption(key={"","prepare_handle"},mandatory=true,help="")
String ph)
ph - the ph@CliCommand(value="prepQuery execute",
help="Execute prepared query with handle . If is supplied and is true, query is run in async manner and query handle is returned immediately. Optionally, can be provided, though not required.")
public String executePreparedQuery(@CliOption(key={"","prepare_handle"},mandatory=true,help="Prepare handle to execute")
String phandle,
@CliOption(key="async",mandatory=false,unspecifiedDefaultValue="false",specifiedDefaultValue="true",help="")
boolean async,
@CliOption(key="name",mandatory=false,help="")
String queryName)
phandle - the phandleasync - the asynchqueryName - the query name@CliCommand(value="prepQuery prepare",
help="Prepapre query and return prepare handle. Can optionaly provide ")
public String prepare(@CliOption(key={"","query"},mandatory=true,help="")
String sql,
@CliOption(key="name",mandatory=false,help="")
String queryName)
throws UnsupportedEncodingException,
LensAPIException
sql - the sqlqueryName - the query nameUnsupportedEncodingException - the unsupported encoding exceptionLensAPIException@CliCommand(value="prepQuery explain",
help="Explain and prepare query . Can optionally provide ")
public String explainAndPrepare(@CliOption(key={"","query"},mandatory=true,help="")
String sql,
@CliOption(key="name",mandatory=false,help="")
String queryName)
throws UnsupportedEncodingException,
LensAPIException
sql - the sqlqueryName - the query nameUnsupportedEncodingException - the unsupported encoding exceptionLensAPIExceptionCopyright © 2014–2015 Apache Software Foundation. All rights reserved.