public static APIResult success(String message) { return new APIResult(Status.SUCCEEDED, message); }
public static APIResult partial(int actual, int expected) { return new APIResult(Status.PARTIAL, actual + " out of " + expected); }
public static APIResult partial(int actual, int expected) { return new APIResult(Status.PARTIAL, actual + " out of " + expected); }
public static APIResult success(String message) { return new APIResult(Status.SUCCEEDED, message); }
public static APIResult failure(Exception e) { String cause = extractCause(e); return new APIResult(Status.FAILED, cause); }
public static APIResult failure(Exception e) { String cause = extractCause(e); return new APIResult(Status.FAILED, cause); }
public static APIResult partial(Exception e) { String cause = extractCause(e); return new APIResult(Status.PARTIAL, cause); }
public static APIResult partial(Exception e) { String cause = extractCause(e); return new APIResult(Status.PARTIAL, cause); }
/** * Close a Lens server session. * * @param sessionid Session handle object of the session to be closed * @return APIResult object indicating if the operation was successful (check result.getStatus()) */ @DELETE @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) public APIResult closeSession(@QueryParam("sessionid") LensSessionHandle sessionid) { try { sessionService.closeSession(sessionid); } catch (LensException e) { log.error("Got an exception while closing {} session: ", sessionid, e); return new APIResult(Status.FAILED, e.getMessage()); } return new APIResult(Status.SUCCEEDED, "Close session with id" + sessionid + "succeeded"); }
/** * Destroy the prepared query specified by handle. * * @param sessionid The user session handle * @param prepareHandle The prepare handle * @return APIResult with state {@link org.apache.lens.api.APIResult.Status#SUCCEEDED} in case of successful * destroy. APIResult with state {@link org.apache.lens.api.APIResult.Status#FAILED} in case of * destroy failure. */ @DELETE @Path("preparedqueries/{prepareHandle}") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) public APIResult destroyPrepared(@QueryParam("sessionid") LensSessionHandle sessionid, @PathParam("prepareHandle") String prepareHandle) throws LensException { validateSessionId(sessionid); boolean ret = queryServer.destroyPrepared(sessionid, getPrepareHandle(prepareHandle)); if (ret) { return new APIResult(Status.SUCCEEDED, "Destroy on the query " + prepareHandle + " is successful"); } else { return new APIResult(Status.FAILED, "Destroy on the query " + prepareHandle + " failed"); } }
/** * Cancel the query specified by the handle. * * @param sessionid The user session handle * @param queryHandle The query handle * @return APIResult with state {@link org.apache.lens.api.APIResult.Status#SUCCEEDED} in case of successful * cancellation. APIResult with state {@link org.apache.lens.api.APIResult.Status#FAILED} in case of * cancellation failure. */ @DELETE @Path("queries/{queryHandle}") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) public APIResult cancelQuery(@QueryParam("sessionid") LensSessionHandle sessionid, @PathParam("queryHandle") String queryHandle) throws LensException { validateSessionId(sessionid); boolean ret = queryServer.cancelQuery(sessionid, getQueryHandle(queryHandle)); if (ret) { return new APIResult(Status.SUCCEEDED, "Cancel on the query " + queryHandle + " is successful"); } else { return new APIResult(Status.FAILED, "Cancel on the query " + queryHandle + " failed"); } }
/** * Close the result set once fetching is done. * * @param sessionid The user session handle * @param queryHandle The query handle * @return APIResult with state {@link org.apache.lens.api.APIResult.Status#SUCCEEDED} in case of successful * close. APIResult with state {@link org.apache.lens.api.APIResult.Status#FAILED} in case of close failure. */ @DELETE @Path("queries/{queryHandle}/resultset") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) public APIResult closeResultSet(@QueryParam("sessionid") LensSessionHandle sessionid, @PathParam("queryHandle") String queryHandle) throws LensException { validateSessionId(sessionid); queryServer.closeResultSet(sessionid, getQueryHandle(queryHandle)); return new APIResult(Status.SUCCEEDED, "Close on the result set for query " + queryHandle + " is successful"); } }
return new APIResult(Status.SUCCEEDED, "Destroy all prepared " + "queries " + msgString + " is successful"); } else { assert (failed); if (numDestroyed == 0) { return new APIResult(Status.FAILED, "Destroy all prepared " + "queries " + msgString + " has failed"); } else { return new APIResult(Status.PARTIAL, "Destroy all prepared " + "queries " + msgString + " is partial");
+ (StringUtils.isBlank(user) ? "" : " for user " + user); if (handles != null && numCancelled == handles.size()) { return new APIResult(Status.SUCCEEDED, "Cancel all queries " + msgString + " is successful"); } else { assert (failed); if (numCancelled == 0) { return new APIResult(Status.FAILED, "Cancel on the query " + msgString + " has failed"); } else { return new APIResult(Status.PARTIAL, "Cancel on the query " + msgString + " is partial");
/** * Modify query configuration if it is not running yet. * * @param sessionid The user session handle * @param queryHandle The query handle * @param conf The new configuration, will be on top of old one * @return APIResult with state {@link org.apache.lens.api.APIResult.Status#SUCCEEDED} in case of successful * update. APIResult with state {@link org.apache.lens.api.APIResult.Status#FAILED} in case of udpate failure. */ @PUT @Path("queries/{queryHandle}") @Consumes({MediaType.MULTIPART_FORM_DATA}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) public APIResult updateConf(@FormDataParam("sessionid") LensSessionHandle sessionid, @PathParam("queryHandle") String queryHandle, @FormDataParam("conf") LensConf conf) throws LensException { validateSessionId(sessionid); boolean ret = queryServer.updateQueryConf(sessionid, getQueryHandle(queryHandle), conf); if (ret) { return new APIResult(Status.SUCCEEDED, "Update on the query conf for " + queryHandle + " is successful"); } else { return new APIResult(Status.FAILED, "Update on the query conf for " + queryHandle + " failed"); } }
/** * Modify prepared query's configuration. This would be picked up for subsequent runs of the prepared queries. The * query wont be re-prepared with new configuration. * * @param sessionid The user session handle * @param prepareHandle The prepare handle * @param conf The new configuration, will be on top of old one * @return APIResult with state {@link org.apache.lens.api.APIResult.Status#SUCCEEDED} in case of successful * update. APIResult with state {@link org.apache.lens.api.APIResult.Status#FAILED} in case of udpate failure. */ @PUT @Path("preparedqueries/{prepareHandle}") @Consumes({MediaType.MULTIPART_FORM_DATA}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) public APIResult updatePreparedConf(@FormDataParam("sessionid") LensSessionHandle sessionid, @PathParam("prepareHandle") String prepareHandle, @FormDataParam("conf") LensConf conf) throws LensException { validateSessionId(sessionid); boolean ret = queryServer.updateQueryConf(sessionid, getPrepareHandle(prepareHandle), conf); if (ret) { return new APIResult(Status.SUCCEEDED, "Update on the query conf for " + prepareHandle + " is successful"); } else { return new APIResult(Status.FAILED, "Update on the query conf for " + prepareHandle + " failed"); } }
/** * Set value for a parameter specified by key * <p></p> * The parameters can be a hive variable or a configuration. To set key as a hive variable, the key should be prefixed * with 'hivevar:'. To set key as configuration parameter, the key should be prefixed with 'hiveconf:' If no prefix is * attached, the parameter is set as configuration. * * @param sessionid session handle object * @param key parameter key * @param value parameter value * @return APIResult object indicating if set operation was successful */ @PUT @Path("params") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) public APIResult setParam(@FormDataParam("sessionid") LensSessionHandle sessionid, @FormDataParam("key") String key, @FormDataParam("value") String value) { sessionService.setSessionParameter(sessionid, key, value); return new APIResult(Status.SUCCEEDED, "Set param succeeded"); }