Package joptsimple

Examples of joptsimple.OptionParser


                getParser().printHelpOn(System.err);
            System.exit(exitStatus);
        }
    }
    public static void main(String[] argv) throws Exception {
        OptionParser parser = getParser();
        OptionSet options = parser.parse(argv);
        validateOptions(options);

        // bdb_folder output_folder
        String storeBdbFolderPath = (String) options.valueOf("bdb");
        String outputFolderPath = (String) options.valueOf("output");
View Full Code Here


    private final static Logger logger = Logger.getLogger(RebalancePlanCLI.class);

    private static OptionParser parser;

    private static void setupParser() {
        parser = new OptionParser();
        parser.accepts("help", "Print usage information");
        parser.accepts("current-cluster", "Path to current cluster xml")
              .withRequiredArg()
              .describedAs("cluster.xml");
        parser.accepts("final-cluster", "Path to final cluster xml")
View Full Code Here

     * Return args parser
     *
     * @return program parser
     * */
    private static OptionParser getParser() {
        OptionParser parser = new OptionParser();
        parser.accepts("help", "print help information");
        parser.accepts("url", "[REQUIRED] bootstrap URL")
              .withRequiredArg()
              .describedAs("bootstrap-url")
              .ofType(String.class);
        parser.accepts("in-dir",
                       "[REQUIRED] Directory in which to find the input key files (named \"{storeName}.kvs\", generated by KeyFetcherCLI.")
              .withRequiredArg()
              .describedAs("inputDirectory")
              .ofType(String.class);
        parser.accepts("out-dir",
                       "[REQUIRED] Directory in which to output the key files (named \"{storeName}.kvs\".")
              .withRequiredArg()
              .describedAs("outputDirectory")
              .ofType(String.class);
        parser.accepts("store-names",
                       "Store names to sample. Comma delimited list or singleton. [Default: ALL]")
              .withRequiredArg()
              .describedAs("storeNames")
              .withValuesSeparatedBy(',')
              .ofType(String.class);
        parser.accepts("parallelism",
                       "Number of key-versions to sample in parallel. [Default: "
                               + DEFAULT_KEY_PARALLELISM + " ]")
              .withRequiredArg()
              .describedAs("storeParallelism")
              .ofType(Integer.class);
        parser.accepts("progress-period-ops",
                       "Number of operations between progress info is displayed. [Default: "
                               + DEFAULT_PROGRESS_PERIOD_OPS + " ]")
              .withRequiredArg()
              .describedAs("progressPeriodOps")
              .ofType(Integer.class);
        parser.accepts("output-batch-size",
                       "Number of keys fetched and written out in sorted order at once. [Default: "
                               + DEFAULT_OUTPUT_BATCH_SIZE + " ]")
              .withRequiredArg()
              .describedAs("outputBatchSize")
              .ofType(Integer.class);
        parser.accepts("details",
                       "print details of each key-version: partition ID, node ID, & hostname");
        return parser;
    }
View Full Code Here

    // In the future, this tool could be expanded with the following options:
    // - fetch value in addition to version
    // - choose between printing human readable data (.toString()) or computer
    // readable data (ByteUtils.toHexString(byte[])).
    public static void main(String[] args) throws Exception {
        OptionParser parser = null;
        OptionSet options = null;
        try {
            parser = getParser();
            options = parser.parse(args);
        } catch(OptionException oe) {
            parser.printHelpOn(System.out);
            printUsageAndDie("Exception when parsing arguments : " + oe.getMessage());
            return;
        }

        /* validate options */
        if(options.has("help")) {
            parser.printHelpOn(System.out);
            printUsage();
            return;
        }
        if(!options.hasArgument("url") || !options.hasArgument("in-dir")
           || !options.hasArgument("out-dir")) {
            parser.printHelpOn(System.out);
            printUsageAndDie("Missing a required argument.");
            return;
        }

        String url = (String) options.valueOf("url");
View Full Code Here

     *
     * @param args see USAGE for details
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        OptionParser parser = new OptionParser();
        parser.accepts("help", "print usage information");
        parser.accepts("cluster", "[REQUIRED] path to cluster xml config file")
              .withRequiredArg()
              .describedAs("cluster.xml");
        parser.accepts("stores", "[REQUIRED] path to stores xml config file")
              .withRequiredArg()
              .describedAs("stores.xml");
        parser.accepts("name", "[REQUIRED] store name").withRequiredArg().describedAs("store name");
        parser.accepts("buffer", "[REQUIRED] number of key/value pairs to buffer in memory")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts("input", "[REQUIRED] input file to read from")
              .withRequiredArg()
              .describedAs("input-file");
        parser.accepts("output", "[REQUIRED] directory to output stores to")
              .withRequiredArg()
              .describedAs("output directory");
        parser.accepts("threads", "number of threads").withRequiredArg().ofType(Integer.class);
        parser.accepts("chunks",
                       "number of chunks [per node, per partition, per partition + replica]")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts("io-buffer-size", "size of i/o buffers in bytes")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts("temp-dir", "temporary directory for sorted file pieces")
              .withRequiredArg()
              .describedAs("temp dir");
        parser.accepts("gzip", "compress intermediate chunk files");
        parser.accepts("format",
                       "read-only store format [" + ReadOnlyStorageFormat.READONLY_V0.getCode()
                               + "," + ReadOnlyStorageFormat.READONLY_V1.getCode() + ","
                               + ReadOnlyStorageFormat.READONLY_V2.getCode() + "]")
              .withRequiredArg()
              .ofType(String.class);
        OptionSet options = parser.parse(args);

        if(options.has("help")) {
            parser.printHelpOn(System.out);
            System.exit(0);
        }

        Set<String> missing = CmdUtils.missing(options,
                                               "cluster",
                                               "stores",
                                               "name",
                                               "buffer",
                                               "input",
                                               "output");
        if(missing.size() > 0) {
            System.err.println("Missing required arguments: " + Joiner.on(", ").join(missing));
            parser.printHelpOn(System.err);
            System.exit(1);
        }

        String clusterFile = (String) options.valueOf("cluster");
        String storeDefFile = (String) options.valueOf("stores");
View Full Code Here

     * @param args
     * @return A struct containing validated options.
     * @throws IOException
     */
    private static ConsistencyFixCLI.Options parseArgs(String[] args) {
        OptionParser parser = new OptionParser();
        parser.accepts("help", "print help information");
        parser.accepts("url", "The bootstrap url.")
              .withRequiredArg()
              .describedAs("bootstrapUrl")
              .ofType(String.class);
        parser.accepts("store", "The store name.")
              .withRequiredArg()
              .describedAs("storeName")
              .ofType(String.class);
        parser.accepts("bad-key-file-in",
                       "Name of bad-key-file-in. " + "Each key must be in hexadecimal format. "
                               + "Each key must be on a separate line in the file. ")
              .withRequiredArg()
              .describedAs("badKeyFileIn")
              .ofType(String.class);
        parser.accepts("orphan-format",
                       "Indicates format of bad-key-file-in is of 'orphan' key-values.");
        parser.accepts("dry-run",
                       "Indicates to go through all of the read actions until the point of issuing repair puts. Then, do a 'no-op'.");
        parser.accepts("parse-only",
                       "Indicates to only parse the input file. Does not perform any key queries or repair puts. "
                               + "Does bootstrap though so bootstrapUrl and storeName must be specified.");
        parser.accepts("bad-key-file-out",
                       "Name of bad-key-file-out. "
                               + "Keys that are not mae consistent are output to this file.")
              .withRequiredArg()
              .describedAs("badKeyFileOut")
              .ofType(String.class);
        parser.accepts("parallelism",
                       "Number of consistency fix messages outstanding in parallel. ")
              .withRequiredArg()
              .describedAs("parallelism [Default value: " + Options.defaultParallelism + "]")
              .ofType(Integer.class);
        parser.accepts("progress-period-ops",
                       "Number of operations between 'info' progress messages. ")
              .withRequiredArg()
              .describedAs("period (in operations) between outputting progress [Default value: "
                           + Options.defaultProgressPeriodOps + "]")
              .ofType(Long.class);
        parser.accepts("per-server-qps-limit",
                       "Number of operations that the consistency fixer will issue to any individual server in one second. ")
              .withRequiredArg()
              .describedAs("perServerQPSLimit [Default value: " + Options.defaultPerServerQPSLimit
                           + "]")
              .ofType(Long.class);

        OptionSet optionSet = parser.parse(args);

        if(optionSet.hasArgument("help")) {
            try {
                parser.printHelpOn(System.out);
            } catch(IOException e) {
                e.printStackTrace();
            }
            printUsage();
            System.exit(0);
View Full Code Here

         * Initializes parser
         *
         * @return OptionParser object with all available options
         */
        protected static OptionParser getParser() {
            OptionParser parser = new OptionParser();
            // help options
            AdminParserUtils.acceptsHelp(parser);
            // required options
            AdminParserUtils.acceptsStoreMultiple(parser);
            AdminParserUtils.acceptsUrl(parser);
View Full Code Here

         *
         */
        @SuppressWarnings("unchecked")
        public static void executeCommand(String[] args) throws IOException {

            OptionParser parser = getParser();

            // declare parameters
            List<String> storeNames = null;
            String url = null;
            List<Integer> nodeIds = null;
            Boolean allNodes = true;
            Boolean confirm = false;

            // parse command-line input
            OptionSet options = parser.parse(args);
            if(options.has(AdminParserUtils.OPT_HELP)) {
                printHelp(System.out);
                return;
            }

View Full Code Here

         * Initializes parser
         *
         * @return OptionParser object with all available options
         */
        protected static OptionParser getParser() {
            OptionParser parser = new OptionParser();
            // help options
            CoordinatorAdminUtils.acceptsHelp(parser);
            // required options
            CoordinatorAdminUtils.acceptsUrlMultiple(parser);
            CoordinatorAdminUtils.acceptsStoreMultiple(parser);
            parser.accepts(OPT_VERBOSE, "print store client config without folding same ones");
            return parser;
        }
View Full Code Here

         *
         */
        @SuppressWarnings("unchecked")
        public static void executeCommand(String[] args) throws IOException {

            OptionParser parser = getParser();

            // declare parameters
            List<String> storeNames = null;
            List<String> urls = null;
            Boolean verbose = false;

            // parse command-line input
            OptionSet options = parser.parse(args);
            if(options.has(CoordinatorAdminUtils.OPT_HELP)) {
                printHelp(System.out);
                return;
            }

View Full Code Here

TOP

Related Classes of joptsimple.OptionParser

Copyright © 2018 www.massapicom. 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.