Пример #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();
     }
   }
 }
Пример #2
0
 /**
  * Gets the prepared status.
  *
  * @param ph the ph
  * @return the prepared status
  */
 @CliCommand(value = "prepQuery details", help = "Get prepared query with handle <prepare_handle>")
 public String getPreparedStatus(
     @CliOption(
             key = {"", "prepare_handle"},
             mandatory = true,
             help = "<prepare_handle>")
         String ph) {
   LensPreparedQuery prepared = getClient().getPreparedQuery(QueryPrepareHandle.fromString(ph));
   if (prepared != null) {
     StringBuilder sb =
         new StringBuilder()
             .append("User query:")
             .append(prepared.getUserQuery())
             .append("\n")
             .append("Prepare handle:")
             .append(prepared.getPrepareHandle())
             .append("\n")
             .append("User:"******"\n")
             .append("Prepared at:")
             .append(prepared.getPreparedTime())
             .append("\n")
             .append("Selected driver :")
             .append(prepared.getSelectedDriverName())
             .append("\n")
             .append("Driver query:")
             .append(prepared.getDriverQuery())
             .append("\n");
     if (prepared.getConf() != null) {
       sb.append("Conf:").append(prepared.getConf().getProperties()).append("\n");
     }
     return sb.toString();
   } else {
     return "No such handle";
   }
 }