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; } }
private void createStorage(String fileName) throws JAXBException, IOException { result = metaClient.createNewStorage(fileName); if (result.getStatus().equals(APIResult.Status.FAILED)) { System.err.println("Creating storage from:" + fileName + " failed, reason:" + result.getMessage()); retCode = 1; } }
private void createDimTable(String dimTableSpec) { result = metaClient.createDimensionTable(dimTableSpec); if (result.getStatus().equals(APIResult.Status.FAILED)) { System.err.println("Creating dim table from: " + dimTableSpec + " failed, reason:" + result.getMessage()); retCode = 1; } }
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; } }
private void createDimension(String dimensionSpec) { result = metaClient.createDimension(dimensionSpec); if (result.getStatus().equals(APIResult.Status.FAILED)) { System.err.println("Creating dimension from:" + dimensionSpec + " failed, reason:" + result.getMessage()); retCode = 1; } }
private void createFact(String factSpec) { result = metaClient.createFactTable(factSpec); if (result.getStatus().equals(APIResult.Status.FAILED)) { System.err.println("Creating fact table from: " + factSpec + " failed, reason:" + result.getMessage()); retCode = 1; } }
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()))); } }
/** * 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(); }
/** * 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(); }
/** * Adds the file. * * @param path the path * @return the string */ @CliCommand(value = "add file", help = "Adds a file resource to session") public String addFile( @CliOption(key = {"", "path"}, mandatory = true, help = "<path-to-file-on-server-side>") @NonNull String path) { APIResult result = getClient().addFileResource(path); return result.getMessage(); }
/** * Removes the jar. * * @param path the path * @return the string */ @CliCommand(value = "remove jar", help = "Removes a jar resource from session") public String removeJar( @CliOption(key = {"", "path"}, mandatory = true, help = "<path-to-jar-on-server-side>") @NonNull String path) { APIResult result = getClient().removeJarResource(path); return result.getMessage(); }
/** * Removes the jar. * * @param path the path * @return the string */ @CliCommand(value = "remove jar", help = "Removes a jar resource from session") public String removeJar( @CliOption(key = {"", "path"}, mandatory = true, help = "<path-to-jar-on-server-side>") @NonNull String path) { APIResult result = getClient().removeJarResource(path); return result.getMessage(); }
/** * Adds the file. * * @param path the path * @return the string */ @CliCommand(value = "add file", help = "Adds a file resource to session") public String addFile( @CliOption(key = {"", "path"}, mandatory = true, help = "<path-to-file-on-server-side>") @NonNull String path) { APIResult result = getClient().addFileResource(path); return result.getMessage(); }
/** * 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(); }
/** * 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(); }
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()))); } }
/** * Close the connection. */ @Override public synchronized void close() { if (closed) { log.warn("Session already closed. Ignoring the attempt to close again."); return; } WebTarget target = getSessionWebTarget(); Response response = target.queryParam("sessionid", this.sessionHandle).request().delete(); if (response == null) { // Should never come here, just fool-proofing throw new LensClientException("Null response from server while closing connection."); } switch(response.getStatus()){ case 410: log.warn("Session is already gone. Ignoring the attempt to close again."); break; case 200: APIResult apiResult = response.readEntity(APIResult.class); if (apiResult.getStatus() != APIResult.Status.SUCCEEDED) { throw new LensClientException("Error closing lens connection: " + apiResult.getMessage()); } break; default: throw new LensClientException("Couldn't close session, error code: " + response.getStatus()); } closed = true; }
/** * Sets the param. * * @param keyval the keyval * @return the string */ @CliCommand(value = "set", help = "Assign <value> to session parameter specified with <key> on lens server") public String setParam(@CliOption(key = {""}, mandatory = true, help = "<key>=<value>") String keyval) { String[] pair = keyval.split("="); if (pair.length != 2) { return "Error: Pass parameter as <key>=<value>"; } if (pair[0].startsWith(LensCliConfigConstants.LENS_CLI_PREFIX) || pair[0].startsWith(LensClientConfig.CLIENT_PFX)) { getClient().getConf().set(pair[0], pair[1]); return "Client side Set " + pair[0] + "=" + pair[1]; } else { APIResult result = getClient().setConnectionParam(pair[0], pair[1]); return result.getMessage(); } }
/** * Sets the param. * * @param keyval the keyval * @return the string */ @CliCommand(value = "set", help = "Assign <value> to session parameter specified with <key> on lens server") public String setParam(@CliOption(key = {""}, mandatory = true, help = "<key>=<value>") String keyval) { String[] pair = keyval.split("="); if (pair.length != 2) { return "Error: Pass parameter as <key>=<value>"; } if (pair[0].startsWith(LensCliConfigConstants.LENS_CLI_PREFIX) || pair[0].startsWith(LensClientConfig.CLIENT_PFX)) { getClient().getConf().set(pair[0], pair[1]); return "Client side Set " + pair[0] + "=" + pair[1]; } else { APIResult result = getClient().setConnectionParam(pair[0], pair[1]); return result.getMessage(); } }
@Test(dataProvider = "mediaTypeData") public void testCreateDatabase(MediaType mediaType) throws Exception { final String newDb = dbPFX + "new_db" + mediaType.getSubtype(); WebTarget dbTarget = target().path("metastore").path("databases"); APIResult result = dbTarget.queryParam("sessionid", lensSessionId).request(mediaType) .post(getEntityForString(newDb, mediaType), APIResult.class); assertNotNull(result); assertSuccess(result); // Create again Response response = dbTarget.queryParam("sessionid", lensSessionId).queryParam("ignoreIfExisting", false) .request(mediaType).post(getEntityForString(newDb, mediaType)); assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); result = response.readEntity(APIResult.class); assertEquals(result.getStatus(), Status.FAILED); log.info(">> Result message " + result.getMessage()); // Drop dbTarget.path(newDb).queryParam("sessionid", lensSessionId).request().delete(); }