private void createSegmentations() throws JAXBException, IOException { result = metaClient.createSegmentation("seg1.xml"); if (result.getStatus().equals(APIResult.Status.FAILED)) { System.err.println("Creating segmentation from : " + "seg1.xml" + " failed, reason:" + result.getMessage()); retCode = 1; } }
public static APIResult partial(int actual, int expected) { return new APIResult(Status.PARTIAL, actual + " out of " + expected); }
public static APIResult partial(Exception e) { String cause = extractCause(e); return new APIResult(Status.PARTIAL, cause); }
/** * Checks that Response status is SUCCEEDED * @param response Response */ public static void assertSucceededResult(Response response) { Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); APIResult result = response.readEntity(APIResult.class); Assert.assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED); }
private APIResult translate(Response response) { if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) { return response.readEntity(APIResult.class); } else { APIResult result = response.readEntity(APIResult.class); throw new LensBriefErrorException(new IdBriefErrorTemplate(null, null, new BriefError(response.getStatus(), result.getMessage()))); } }
public APIResult delete(LensSessionHandle sessionid, String entityName, Boolean cascade) throws LensException { log.info("Drop {} {} cascade: {}", name(), entityName, cascade); checkSessionId(sessionid); doDelete(sessionid, entityName, cascade); return success(); }
/** * Drop the partitions in the storage of a fact; can specified filter as well * * @param sessionid The sessionid in which user is working * @param factName The fact table name * @param storage The storage name * @param filter The filter for partitions, string representation of the filter for ex: x < "xxx" and y > * "yyy" * @return {@link APIResult} with state {@link Status#SUCCEEDED}, if drop was successful. {@link APIResult} with state * {@link Status#FAILED}, if drop has failed */ @DELETE @Path("/facts/{factName}/storages/{storage}/partitions") public APIResult dropPartitionsOfFactStorageByFilter(@QueryParam("sessionid") LensSessionHandle sessionid, @PathParam("factName") String factName, @PathParam("storage") String storage, @QueryParam("filter") String filter, @QueryParam("updatePeriod") String updatePeriod) throws LensException { checkSessionId(sessionid); try { getSvc().dropPartitionFromStorageByFilter(sessionid, factName, storage, filter, updatePeriod); } catch (LensException exc) { log.warn("Got exception while dropping partition.", exc); return partial(processLensException(exc)); } return success(); }
public static APIResult successOrPartialOrFailure(int actual, int expected) { return successOrPartialOrFailure(actual, expected, null); }
private APIResult failureAPIResult(Exception e) { log.error("Failed", e); return APIResult.failure(e); } }
public boolean setDatabase(String database) { log.debug("Set the database to {}", database); APIResult result = mc.setDatabase(database); return result.getStatus() == APIResult.Status.SUCCEEDED; }
/** * Adds the jar. * * @param path the path * @return the string */ @CliCommand(value = "add jar", help = "Adds jar resource to the session") public String addJar( @CliOption(key = {"", "path"}, mandatory = true, help = "<path-to-jar-on-server-side>") @NonNull String path) { APIResult result = getClient().addJarResource(path); return result.getMessage(); }
/** * Clears idle sessions. response will contain how many sessions were cleared. * @throws LensException */ @DELETE @Path("sessions") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN }) public APIResult clearIdleSessions() throws LensException { int before = getSessionInfo().size(); sessionService.cleanupIdleSessions(); int after = getSessionInfo().size(); return APIResult.success("cleared " + (after - before) + " idle sessions"); } }
public static APIResult failure(Exception e) { String cause = extractCause(e); return new APIResult(Status.FAILED, cause); }
/** * Drop the partitions in the storage of a dimension table; can specified filter as well * * @param sessionid The sessionid in which user is working * @param dimTableName The dimension table name * @param storage The storage name * @param filter The filter for partitions, string representation of the filter for ex: x < 'xxx' and y > * 'yyy' * @return {@link APIResult} with state {@link Status#SUCCEEDED}, if drop was successful. {@link APIResult} with state * {@link Status#FAILED}, if drop has failed */ @DELETE @Path("/dimtables/{dimTableName}/storages/{storage}/partitions") public APIResult dropPartitionsOfDimStorageByFilter(@QueryParam("sessionid") LensSessionHandle sessionid, @PathParam("dimTableName") String dimTableName, @PathParam("storage") String storage, @QueryParam("filter") String filter) throws LensException { checkSessionId(sessionid); try { getSvc().dropPartitionFromStorageByFilter(sessionid, dimTableName, storage, filter); } catch (LensException exc) { log.error("Error dropping partition on storage of dimension table {}:{}", dimTableName, storage, exc); return partial(processLensException(exc)); } return success(); }
public static APIResult successOrPartialOrFailure(int actual, int expected) { return successOrPartialOrFailure(actual, expected, null); }
private APIResult failureAPIResult(Exception e) { log.error("Failed", e); return APIResult.failure(e); } }
private void createCube(String cubeSpec) { result = metaClient.createCube(cubeSpec); if (result.getStatus().equals(APIResult.Status.FAILED)) { System.err.println("Creating cube from:" + cubeSpec + " failed, reason:" + result.getMessage()); retCode = 1; } }
public boolean setDatabase(String database) { log.debug("Set the database to {}", database); APIResult result = mc.setDatabase(database); return result.getStatus() == APIResult.Status.SUCCEEDED; }
/** * Removes the file. * * @param path the path * @return the stringadd */ @CliCommand(value = "remove file", help = "removes a file resource from session") public String removeFile( @CliOption(key = {"", "path"}, mandatory = true, help = "<path-to-file-on-server-side>") @NonNull String path) { APIResult result = getClient().removeFileResource(path); return result.getMessage(); }