Examples of JCommander


Examples of com.beust.jcommander.JCommander

  @Parameters(commandDescription = "List the existing FATE transactions")
  static class PrintOpts {}

  public static void main(String[] args) throws Exception {
    Help opts = new Help();
    JCommander jc = new JCommander(opts);
    jc.setProgramName(Admin.class.getName());
    jc.addCommand("fail", new FailOpts());
    jc.addCommand("delete", new DeleteOpts());
    jc.addCommand("print", new PrintOpts());
    jc.parse(args);
    if (opts.help || jc.getParsedCommand() == null) {
      jc.usage();
      System.exit(-1);
    }

    AdminUtil<Master> admin = new AdminUtil<Master>();

    Instance instance = HdfsZooInstance.getInstance();
    String path = ZooUtil.getRoot(instance) + Constants.ZFATE;
    String masterPath = ZooUtil.getRoot(instance) + Constants.ZMASTER_LOCK;
    IZooReaderWriter zk = ZooReaderWriter.getRetryingInstance();
    ZooStore<Master> zs = new ZooStore<Master>(path, zk);

    if (jc.getParsedCommand().equals("fail")) {
      if (!admin.prepFail(zs, zk, masterPath, args[1])) {
        System.exit(1);
      }
    } else if (jc.getParsedCommand().equals("delete")) {
      if (!admin.prepDelete(zs, zk, masterPath, args[1])) {
        System.exit(1);
      }
      admin.deleteLocks(zs, zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS, args[1]);
    } else if (jc.getParsedCommand().equals("print")) {
      admin.print(new ReadOnlyStore<Master>(zs), zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS);
    }
  }
View Full Code Here

Examples of com.beust.jcommander.JCommander

    Opts opts = new Opts();
    opts.parseArgs(ZooZap.class.getName(), args);
   
    if (!opts.zapMaster && !opts.zapTservers && !opts.zapTracers)
    {
        new JCommander(opts).usage();
        return;
    }
   
    String iid = opts.getInstance().getInstanceID();
    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
View Full Code Here

Examples of com.beust.jcommander.JCommander

public class Help {
  @Parameter(names={"-h", "-?", "--help", "-help"}, help=true)
  public boolean help = false;
 
  public void parseArgs(String programName, String[] args, Object ... others) {
    JCommander commander = new JCommander();
    commander.addObject(this);
    for (Object other : others)
      commander.addObject(other);
    commander.setProgramName(programName);
    try {
      commander.parse(args);
    } catch (ParameterException ex) {
      commander.usage();
      exitWithError(ex.getMessage(), 1);
    }
    if (help) {
      commander.usage();
      exit(0);
    }
  }
View Full Code Here

Examples of com.beust.jcommander.JCommander

   
    Matcher rowMatcher = null;
    KeyExtent ke = null;
    Text row = null;
    if (opts.files.isEmpty()) {
      new JCommander(opts).usage();
      return;
    }
    if (opts.row != null)
      row = new Text(opts.row);
    if (opts.extent != null) {
View Full Code Here

Examples of com.beust.jcommander.JCommander

   
  }
 
  static void printHelpAndExit(String message) {
    System.out.println(message);
    new JCommander(new Opts()).usage();
    System.exit(1);
  }
View Full Code Here

Examples of com.beust.jcommander.JCommander

        }
        return taskNames;
    }

    public static JCommander parseArgs(Object jcArgs, String[] cliArgs) {
        JCommander jc = new JCommander(jcArgs);
        try {
            if (Sets.newHashSet(cliArgs).contains("-help")) {
                Parameters parametersAnnotation = jcArgs.getClass().getAnnotation(Parameters.class);
                jc.addCommand(parametersAnnotation.commandNames()[0], jcArgs);
                jc.usage(parametersAnnotation.commandNames()[0]);
                System.exit(0);
            }
            jc.parse(cliArgs);
        } catch (Exception e) {
            JCommander.getConsole().println("Cannot parse arguments: " + e.getClass() + " -> " + e.getMessage());
            jc.usage();
            System.exit(1);
        }
        return jc;
    }
View Full Code Here

Examples of com.beust.jcommander.JCommander

   *
   * @return A configuration instance of the server.
   */
  public static IOSServerConfiguration create(String[] args) {
    IOSServerConfiguration res = new IOSServerConfiguration();
    new JCommander(res).parse(args);
    return res;
  }
View Full Code Here

Examples of com.beust.jcommander.JCommander

    this.options = options;
  }

  public IOSServer(String[] args) {
    IOSServerConfiguration options = new IOSServerConfiguration();
    new JCommander(options, args);
    this.options = options;
  }
View Full Code Here

Examples of com.beust.jcommander.JCommander

   
  }
 
  static void printHelpAndExit(String message) {
    System.out.println(message);
    new JCommander(new Opts()).usage();
    System.exit(1);
  }
View Full Code Here

Examples of com.beust.jcommander.JCommander

  public static void main(String[] args) {
    boolean everything;

    AdminOpts opts = new AdminOpts();
    JCommander cl = new JCommander(opts);
    cl.setProgramName(Admin.class.getName());
    StopCommand stopOpts = new StopCommand();
    cl.addCommand("stop", stopOpts);
    StopMasterCommand stopMasterOpts = new StopMasterCommand();
    cl.addCommand("stopMaster", stopMasterOpts);
    StopAllCommand stopAllOpts = new StopAllCommand();
    cl.addCommand("stopAll", stopAllOpts);
    cl.parse(args);
   
    if (opts.help || cl.getParsedCommand() == null) {
      cl.usage();
      return;
    }
    Instance instance = opts.getInstance();
     
    try {
      String principal;
      AuthenticationToken token;
      if (opts.getToken() == null) {
        principal = SecurityConstants.getSystemPrincipal();
        token = SecurityConstants.getSystemToken();
      } else {
        principal = opts.principal;
        token = opts.getToken();
      }

      if (cl.getParsedCommand().equals("stop")) {
        stopTabletServer(instance, CredentialHelper.create(principal, token, instance.getInstanceID()), stopOpts.args, opts.force);
      } else {
        everything = cl.getParsedCommand().equals("stopAll");

        if (everything)
          flushAll(instance, principal, token);

        stopServer(instance, CredentialHelper.create(principal, token, instance.getInstanceID()), everything);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.