private int handleCommand(CommandLine commandLine, String[] atlasServerUri, AtlasClient atlasClient) { int cmdStatus = PROGRAM_ERROR_STATUS; if (commandLine.hasOption(STATUS.getOpt())) { try { System.out.println(atlasClient.getAdminStatus()); cmdStatus = 0; } catch (AtlasServiceException e) { System.err.println("Could not retrieve status of the server at " + Arrays.toString(atlasServerUri)); printStandardHttpErrorDetails(e); } } else if (commandLine.hasOption(STATS.getOpt())) { try { AtlasMetrics atlasMetrics = atlasClient.getAtlasMetrics(); String json = AtlasType.toJson(atlasMetrics); System.out.println(json); cmdStatus = 0; } catch (AtlasServiceException e) { System.err.println("Could not retrieve metrics of the server at " + Arrays.toString(atlasServerUri)); printStandardHttpErrorDetails(e); } } else { System.err.println("Unsupported option. Refer to usage for valid options."); printUsage(INVALID_OPTIONS_STATUS); } return cmdStatus; }
private int handleCommand(CommandLine commandLine, String[] atlasServerUri) throws AtlasException { AtlasClient atlasClient; String[] providedUserPassword = getUserPassword(commandLine); int cmdStatus = PROGRAM_ERROR_STATUS; if (commandLine.hasOption(STATUS.getOpt())) { atlasClient = initAtlasClient(atlasServerUri, providedUserPassword); // Status is open API, no auth needed try { System.out.println(atlasClient.getAdminStatus()); cmdStatus = 0; } catch (AtlasServiceException e) { System.err.println("Could not retrieve status of the server at " + Arrays.toString(atlasServerUri)); printStandardHttpErrorDetails(e); } } else if (commandLine.hasOption(STATS.getOpt())) { atlasClient = initAtlasClient(atlasServerUri, providedUserPassword); // Stats/metrics is open API, no auth needed try { AtlasMetrics atlasMetrics = atlasClient.getAtlasMetrics(); String json = AtlasType.toJson(atlasMetrics); System.out.println(json); cmdStatus = 0; } catch (AtlasServiceException e) { System.err.println("Could not retrieve metrics of the server at " + Arrays.toString(atlasServerUri)); printStandardHttpErrorDetails(e); } } else { System.err.println("Unsupported option. Refer to usage for valid options."); printUsage(); } return cmdStatus; }
private int handleCommand(CommandLine commandLine, String[] atlasServerUri) throws AtlasException { AtlasClient atlasClient; String[] providedUserPassword = getUserPassword(commandLine); int cmdStatus = PROGRAM_ERROR_STATUS; if (commandLine.hasOption(STATUS.getOpt())) { atlasClient = initAtlasClient(atlasServerUri, providedUserPassword); // Status is open API, no auth needed try { System.out.println(atlasClient.getAdminStatus()); cmdStatus = 0; } catch (AtlasServiceException e) { System.err.println("Could not retrieve status of the server at " + Arrays.toString(atlasServerUri)); printStandardHttpErrorDetails(e); } } else if (commandLine.hasOption(STATS.getOpt())) { atlasClient = initAtlasClient(atlasServerUri, providedUserPassword); // Stats/metrics is open API, no auth needed try { AtlasMetrics atlasMetrics = atlasClient.getAtlasMetrics(); String json = AtlasType.toJson(atlasMetrics); System.out.println(json); cmdStatus = 0; } catch (AtlasServiceException e) { System.err.println("Could not retrieve metrics of the server at " + Arrays.toString(atlasServerUri)); printStandardHttpErrorDetails(e); } } else { System.err.println("Unsupported option. Refer to usage for valid options."); printUsage(); } return cmdStatus; }