private int help(String[] argv) { if (argv.length == 1) { // only -help printUsage(out); return 0; } else if (argv.length != 2) { printUsage(errOut, "-help"); return -1; } String cmd = argv[1]; if (!cmd.startsWith("-")) { cmd = "-" + cmd; } UsageInfo usageInfo = USAGE.get(cmd); if (usageInfo == null) { errOut.println(cmd + ": Unknown command"); printUsage(errOut); return -1; } if (usageInfo.args == null) { out.println(cmd + ": " + usageInfo.help); } else { out.println(cmd + " [" + usageInfo.args + "]: " + usageInfo.help); } return 0; }
private CommandLine parseOpts(String cmdName, Options opts, String[] argv) { try { // Strip off the first arg, since that's just the command name argv = Arrays.copyOfRange(argv, 1, argv.length); return new GnuParser().parse(opts, argv); } catch (ParseException pe) { errOut.println(cmdName.substring(1) + ": incorrect arguments"); printUsage(errOut, cmdName); return null; } }
private int getServiceState(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("getServiceState: incorrect number of arguments"); printUsage(errOut, "-getServiceState"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); out.println(proto.getServiceStatus().getState()); return 0; }
protected int runCmd(String[] argv) throws Exception { if (argv.length < 1) { printUsage(errOut); return -1; printUsage(errOut); return -1; printUsage(errOut); return -1;
private int checkHealth(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("checkHealth: incorrect number of arguments"); printUsage(errOut, "-checkHealth"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); try { HAServiceProtocolHelper.monitorHealth(proto, createReqInfo()); } catch (HealthCheckFailedException e) { errOut.println("Health check failed: " + e.getLocalizedMessage()); return -1; } return 0; }
if(proto.getServiceStatus().getState() == HAServiceState.ACTIVE) { errOut.println("transitionToActive: Node " + targetId +" is already active"); printUsage(errOut, "-transitionToActive"); return true; printUsage(errOut, "-transitionToActive"); return true;
private int transitionToStandby(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("transitionToStandby: incorrect number of arguments"); printUsage(errOut, "-transitionToStandby"); return -1; } HAServiceTarget target = resolveTarget(argv[0]); if (!checkManualStateManagementOK(target)) { return -1; } HAServiceProtocol proto = target.getProxy( getConf(), 0); HAServiceProtocolHelper.transitionToStandby(proto, createReqInfo()); return 0; } /**
private int transitionToActive(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("transitionToActive: incorrect number of arguments"); printUsage(errOut, "-transitionToActive"); return -1; } /* returns true if other target node is active or some exception occurred and forceActive was not set */ if(!cmd.hasOption(FORCEACTIVE)) { if(isOtherTargetNodeActive(argv[0], cmd.hasOption(FORCEACTIVE))) { return -1; } } HAServiceTarget target = resolveTarget(argv[0]); if (!checkManualStateManagementOK(target)) { return -1; } HAServiceProtocol proto = target.getProxy( getConf(), 0); HAServiceProtocolHelper.transitionToActive(proto, createReqInfo()); return 0; }
printUsage(errOut, "-failover"); return -1;
private CommandLine parseOpts(String cmdName, Options opts, String[] argv) { try { // Strip off the first arg, since that's just the command name argv = Arrays.copyOfRange(argv, 1, argv.length); return new GnuParser().parse(opts, argv); } catch (ParseException pe) { errOut.println(cmdName.substring(1) + ": incorrect arguments"); printUsage(errOut, cmdName); return null; } }
private CommandLine parseOpts(String cmdName, Options opts, String[] argv) { try { // Strip off the first arg, since that's just the command name argv = Arrays.copyOfRange(argv, 1, argv.length); return new GnuParser().parse(opts, argv); } catch (ParseException pe) { errOut.println(cmdName.substring(1) + ": incorrect arguments"); printUsage(errOut, cmdName); return null; } }
private CommandLine parseOpts(String cmdName, Options opts, String[] argv) { try { // Strip off the first arg, since that's just the command name argv = Arrays.copyOfRange(argv, 1, argv.length); return new GnuParser().parse(opts, argv); } catch (ParseException pe) { errOut.println(cmdName.substring(1) + ": incorrect arguments"); printUsage(errOut, cmdName); return null; } }
private CommandLine parseOpts(String cmdName, Options opts, String[] argv) { try { // Strip off the first arg, since that's just the command name argv = Arrays.copyOfRange(argv, 1, argv.length); return new GnuParser().parse(opts, argv); } catch (ParseException pe) { errOut.println(cmdName.substring(1) + ": incorrect arguments"); printUsage(errOut, cmdName); return null; } }
private int getServiceState(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("getServiceState: incorrect number of arguments"); printUsage(errOut, "-getServiceState"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); out.println(proto.getServiceStatus().getState()); return 0; }
private int getServiceState(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("getServiceState: incorrect number of arguments"); printUsage(errOut, "-getServiceState"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); out.println(proto.getServiceStatus().getState()); return 0; }
private int getServiceState(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("getServiceState: incorrect number of arguments"); printUsage(errOut, "-getServiceState"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); out.println(proto.getServiceStatus().getState()); return 0; }
private int checkHealth(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("checkHealth: incorrect number of arguments"); printUsage(errOut, "-checkHealth"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); try { HAServiceProtocolHelper.monitorHealth(proto, createReqInfo()); } catch (HealthCheckFailedException e) { errOut.println("Health check failed: " + e.getLocalizedMessage()); return -1; } return 0; }
private int getServiceState(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("getServiceState: incorrect number of arguments"); printUsage(errOut, "-getServiceState"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); out.println(proto.getServiceStatus().getState()); return 0; }
private int checkHealth(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("checkHealth: incorrect number of arguments"); printUsage(errOut, "-checkHealth"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); try { HAServiceProtocolHelper.monitorHealth(proto, createReqInfo()); } catch (HealthCheckFailedException e) { errOut.println("Health check failed: " + e.getLocalizedMessage()); return -1; } return 0; }
private int transitionToStandby(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("transitionToStandby: incorrect number of arguments"); printUsage(errOut, "-transitionToStandby"); return -1; } HAServiceTarget target = resolveTarget(argv[0]); if (!checkManualStateManagementOK(target)) { return -1; } HAServiceProtocol proto = target.getProxy( getConf(), 0); HAServiceProtocolHelper.transitionToStandby(proto, createReqInfo()); return 0; } /**