Exemplo n.º 1
0
 /**
  * Execute prepared query.
  *
  * @param phandle the phandle
  * @param async the asynch
  * @param queryName the query name
  * @return the string
  */
 @CliCommand(
     value = "prepQuery execute",
     help =
         "Execute prepared query with handle <prepare_handle>."
             + " If <async> is supplied and is true, query is run in async manner and query handle is returned immediately."
             + " Optionally, <query-name> 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 = "<async>")
         boolean async,
     @CliOption(
             key = {"name"},
             mandatory = false,
             help = "<query-name>")
         String queryName) {
   if (async) {
     QueryHandle handle =
         getClient().executePrepared(QueryPrepareHandle.fromString(phandle), queryName);
     return handle.getHandleId().toString();
   } else {
     try {
       LensClient.LensClientResultSetWithStats result =
           getClient().getResultsFromPrepared(QueryPrepareHandle.fromString(phandle), queryName);
       return formatResultSet(result);
     } catch (Throwable t) {
       return t.getMessage();
     }
   }
 }