Package joptsimple

Examples of joptsimple.OptionParser


   * the command-line arguments specified, and it processes these.
   *
   * @see #start()
   */
  public Tornado(String[] args) {
    OptionParser parser = new OptionParser("c:");
    commandLineOptions = parser.parse(args);
    RequestHandler = new HashMap<String, RequestHandlerFactory>();
  }
View Full Code Here


        return output.toString();
    }

    @SuppressWarnings("unchecked")
    public static void main(String[] args) throws IOException {
        OptionParser parser = new OptionParser();
        parser.accepts("k", "key size").withRequiredArg().ofType(Integer.class);
        parser.accepts("v", "value size").withRequiredArg().ofType(Integer.class);
        parser.accepts("p", "prefix").withRequiredArg();

        OptionSet options = parser.parse(args);
        List<String> nonOptions = (List<String>) options.nonOptionArguments();

        if(nonOptions.size() != 3) {
            printUsage(System.err, parser);
        }
View Full Code Here

    private final int numThreads;
    private final boolean doReads;
    private final boolean doWrites;

    public static void main(String[] args) throws Exception {
        OptionParser parser = new OptionParser();
        parser.accepts("help", "print usage information");
        parser.acceptsAll(asList("r", "reads"), "Enable reads.");
        parser.acceptsAll(asList("w", "writes"), "Enable writes.");
        parser.acceptsAll(asList("d", "deletes"), "Enable deletes.");
        parser.accepts("table", "Table name").withRequiredArg();
        parser.accepts("db", "Database name").withRequiredArg();
        parser.acceptsAll(asList("u", "user"), "DB username.").withRequiredArg();
        parser.acceptsAll(asList("P", "password"), "DB password").withRequiredArg();
        parser.acceptsAll(asList("p", "port"), "DB port").withRequiredArg();
        parser.acceptsAll(asList("h", "host"), "DB host").withRequiredArg();
        parser.accepts("requests").withRequiredArg().ofType(Integer.class);
        parser.accepts("request-file").withRequiredArg();
        parser.accepts("threads").withRequiredArg().ofType(Integer.class);
        OptionSet options = parser.parse(args);

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

        Set<String> missing = CmdUtils.missing(options, "table", "requests", "db");
        if(missing.size() > 0)
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public static void main(String[] args) throws Exception {

        OptionParser parser = new OptionParser();
        parser.accepts(CONNECTION_TIMEOUT, "Connection timeout (ms)")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts(ROUTING_TIMEOUT, "Routing timeout (ms)")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts(SOCKET_TIMEOUT, "Socket timeout (ms)")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts(MAX_CONNECTIONS, "Max connections per node")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts(MAX_CONNECTIONS_TOTAL, "Max total connections")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts(MAX_THREADS, "Max threads").withRequiredArg().ofType(Integer.class);
        parser.accepts(SELECTORS, "Number of NIO selectors")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts(SOCKET_BUFFER_SIZE, "Socket buffer size")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts(REQS, "Requests per session").withRequiredArg().ofType(Integer.class);
        parser.accepts(CONNECTIONS, "Total connections to make")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts("help");

        OptionSet options = parser.parse(args);
        List<String> rest = (List<String>) options.nonOptionArguments();
        if(rest.size() < 2 || options.has("help")) {
            parser.printHelpOn(System.err);
            System.err.println("Usage: ClientConnectionStressTest <options> url store-name");
            System.exit(0);
        }

        String url = rest.get(0);
View Full Code Here

    private static final String ALL_METADATA = "all";

    @SuppressWarnings("unchecked")
    public static void main(String[] args) throws Exception {
        OptionParser parser = new OptionParser();
        // This is a generic argument that should be eventually supported by all
        // RW operations.
        // If you omit this argument the operation will be executed in a "batch"
        // mode which is useful for scripting
        // Otherwise you will be presented with a summary of changes and with a
        // Y/N prompt
        parser.accepts("auto", "[OPTIONAL] enable auto/batch mode");
        parser.accepts("help", "print help information");
        parser.accepts("url", "[REQUIRED] bootstrap URL")
              .withRequiredArg()
              .describedAs("bootstrap-url")
              .ofType(String.class);
        parser.accepts("node", "node id")
              .withRequiredArg()
              .describedAs("node-id")
              .ofType(Integer.class);
        parser.accepts("delete-partitions", "Delete partitions")
              .withRequiredArg()
              .describedAs("partition-ids")
              .withValuesSeparatedBy(',')
              .ofType(Integer.class);
        parser.accepts("restore",
                       "Restore from replication [ Optional parallelism param - Default - 5 ]")
              .withOptionalArg()
              .describedAs("parallelism")
              .ofType(Integer.class);
        parser.accepts("ascii", "Fetch keys as ASCII");
        parser.accepts("fetch-keys", "Fetch keys")
              .withOptionalArg()
              .describedAs("partition-ids")
              .withValuesSeparatedBy(',')
              .ofType(Integer.class);
        parser.accepts("fetch-entries", "Fetch full entries")
              .withOptionalArg()
              .describedAs("partition-ids")
              .withValuesSeparatedBy(',')
              .ofType(Integer.class);
        parser.accepts("outdir", "Output directory")
              .withRequiredArg()
              .describedAs("output-directory")
              .ofType(String.class);
        parser.accepts("nodes", "list of nodes")
              .withRequiredArg()
              .describedAs("nodes")
              .withValuesSeparatedBy(',')
              .ofType(Integer.class);
        parser.accepts("stores", "Store names")
              .withRequiredArg()
              .describedAs("store-names")
              .withValuesSeparatedBy(',')
              .ofType(String.class);
        parser.accepts("store", "Store name for querying keys")
              .withRequiredArg()
              .describedAs("store-name")
              .ofType(String.class);
        parser.accepts("add-stores", "Add stores in this stores.xml")
              .withRequiredArg()
              .describedAs("stores.xml containing just the new stores")
              .ofType(String.class);
        parser.accepts("delete-store", "Delete store")
              .withRequiredArg()
              .describedAs("store-name")
              .ofType(String.class);
        parser.accepts("update-entries", "Insert or update entries")
              .withRequiredArg()
              .describedAs("input-directory")
              .ofType(String.class);
        parser.accepts("get-metadata",
                       "retreive metadata information " + MetadataStore.METADATA_KEYS)
              .withOptionalArg()
              .describedAs("metadata-key")
              .ofType(String.class);
        parser.accepts("check-metadata",
                       "retreive metadata information from all nodes and checks if they are consistent across [ "
                               + MetadataStore.CLUSTER_KEY + " | " + MetadataStore.STORES_KEY
                               + " | " + MetadataStore.REBALANCING_SOURCE_CLUSTER_XML + " | "
                               + MetadataStore.SERVER_STATE_KEY + " ]")
              .withRequiredArg()
              .describedAs("metadata-key")
              .ofType(String.class);
        parser.accepts("ro-metadata",
                       "retrieve version information [current | max | storage-format]")
              .withRequiredArg()
              .describedAs("type")
              .ofType(String.class);
        parser.accepts("truncate", "truncate a store")
              .withRequiredArg()
              .describedAs("store-name")
              .ofType(String.class);
        parser.accepts("set-metadata",
                       "Forceful setting of metadata [ " + MetadataStore.CLUSTER_KEY + " | "
                               + MetadataStore.STORES_KEY + " | " + MetadataStore.SERVER_STATE_KEY
                               + " | " + MetadataStore.REBALANCING_SOURCE_CLUSTER_XML + " | "
                               + MetadataStore.REBALANCING_STEAL_INFO + " ]")
              .withRequiredArg()
              .describedAs("metadata-key")
              .ofType(String.class);
        parser.accepts("set-metadata-value",
                       "The value for the set-metadata [ " + MetadataStore.CLUSTER_KEY + " | "
                               + MetadataStore.STORES_KEY + ", "
                               + MetadataStore.REBALANCING_SOURCE_CLUSTER_XML + ", "
                               + MetadataStore.REBALANCING_STEAL_INFO
                               + " ] - xml file location, [ " + MetadataStore.SERVER_STATE_KEY
                               + " ] - " + MetadataStore.VoldemortState.NORMAL_SERVER + ","
                               + MetadataStore.VoldemortState.REBALANCING_MASTER_SERVER + ","
                               + MetadataStore.VoldemortState.OFFLINE_SERVER)
              .withRequiredArg()
              .describedAs("metadata-value")
              .ofType(String.class);
        parser.accepts("update-store-defs",
                       "Update the ["
                               + MetadataStore.STORES_KEY
                               + "] with the new value for only the specified stores in update-value.");
        parser.accepts("update-store-value",
                       "The value for update-store-defs ] - xml file location")
              .withRequiredArg()
              .describedAs("stores-xml-value")
              .ofType(String.class);
        parser.accepts("set-metadata-pair",
                       "Atomic setting of metadata pair [ " + MetadataStore.CLUSTER_KEY + " & "
                               + MetadataStore.STORES_KEY + " ]")
              .withRequiredArg()
              .describedAs("metadata-keys-pair")
              .withValuesSeparatedBy(',')
              .ofType(String.class);
        parser.accepts("set-metadata-value-pair",
                       "The value for the set-metadata pair [ " + MetadataStore.CLUSTER_KEY + " & "
                               + MetadataStore.STORES_KEY + " ]")
              .withRequiredArg()
              .describedAs("metadata-value-pair")
              .withValuesSeparatedBy(',')
              .ofType(String.class);
        parser.accepts("clear-rebalancing-metadata", "Remove the metadata related to rebalancing");
        parser.accepts("async",
                       "a) Get a list of async job ids [get] b) Stop async job ids [stop] ")
              .withRequiredArg()
              .describedAs("op-type")
              .ofType(String.class);
        parser.accepts("async-id", "Comma separated list of async ids to stop")
              .withOptionalArg()
              .describedAs("job-ids")
              .withValuesSeparatedBy(',')
              .ofType(Integer.class);
        parser.accepts("repair-job", "Clean after rebalancing is done");
        parser.accepts("prune-job", "Prune versioned put data, after rebalancing");
        parser.accepts("purge-slops",
                       "Purge the slop stores selectively, based on nodeId or zoneId");
        parser.accepts("native-backup", "Perform a native backup")
              .withRequiredArg()
              .describedAs("store-name")
              .ofType(String.class);
        parser.accepts("backup-dir")
              .withRequiredArg()
              .describedAs("backup-directory")
              .ofType(String.class);
        parser.accepts("backup-timeout")
              .withRequiredArg()
              .describedAs("minutes to wait for backup completion, default 30 mins")
              .ofType(Integer.class);
        parser.accepts("backup-verify",
                       "If provided, backup will also verify checksum (with extra overhead)");
        parser.accepts("backup-incremental",
                       "Perform an incremental backup for point-in-time recovery."
                               + " By default backup has latest consistent snapshot.");
        parser.accepts("zone", "zone id")
              .withRequiredArg()
              .describedAs("zone-id")
              .ofType(Integer.class);
        parser.accepts("rollback", "rollback a store")
              .withRequiredArg()
              .describedAs("store-name")
              .ofType(String.class);
        parser.accepts("version", "Push version of store to rollback to")
              .withRequiredArg()
              .describedAs("version")
              .ofType(Long.class);
        parser.accepts("verify-metadata-version",
                       "Verify the version of Metadata on all the cluster nodes");
        parser.accepts("synchronize-metadata-version",
                       "Synchronize the metadata versions across all the nodes.");
        parser.accepts("reserve-memory", "Memory in MB to reserve for the store")
              .withRequiredArg()
              .describedAs("size-in-mb")
              .ofType(Long.class);
        parser.accepts("query-key", "Get values of a key on specific node")
              .withRequiredArg()
              .describedAs("query-key")
              .ofType(String.class);
        parser.accepts("query-key-format", "Format of the query key. Can be one of [hex|readable]")
              .withRequiredArg()
              .describedAs("key-format")
              .ofType(String.class);
        parser.accepts("show-routing-plan", "Routing plan of the specified keys")
              .withRequiredArg()
              .describedAs("keys-to-be-routed")
              .withValuesSeparatedBy(',')
              .ofType(String.class);
        parser.accepts("mirror-from-url", "Cluster url to mirror data from")
              .withRequiredArg()
              .describedAs("mirror-cluster-bootstrap-url")
              .ofType(String.class);
        parser.accepts("mirror-node", "Node id in the mirror cluster to mirror from")
              .withRequiredArg()
              .describedAs("id-of-mirror-node")
              .ofType(Integer.class);
        parser.accepts("fetch-orphaned", "Fetch any orphaned keys/entries in the node");
        parser.accepts("set-quota", "Enforce some quota on the servers")
              .withRequiredArg()
              .describedAs("quota-type")
              .ofType(String.class);
        parser.accepts("quota-value", "Value of the quota enforced on the servers")
              .withRequiredArg()
              .describedAs("quota-value")
              .ofType(String.class);
        parser.accepts("unset-quota", "Remove some quota already enforced on the servers")
              .withRequiredArg()
              .describedAs("quota-type")
              .ofType(String.class);
        // TODO add a way to retrieve all quotas for a given store.
        parser.accepts("get-quota", "Retrieve some quota already enforced on the servers")
              .withRequiredArg()
              .describedAs("quota-type")
              .ofType(String.class);

        OptionSet options = parser.parse(args);

        if(options.has("help")) {
            printHelp(System.out, parser);
            System.exit(0);
        }
View Full Code Here

        }
    }

    @SuppressWarnings("unchecked")
    public static void main(String[] args) throws Exception {
        OptionParser parser = new OptionParser();

        parser.accepts("native", "use native admin client");
        parser.accepts("f", "execute fetch operation");
        parser.accepts("fu", "fetch and update").withRequiredArg().ofType(Integer.class);
        parser.accepts("n", "node id")
              .withRequiredArg()
              .ofType(Integer.class)
              .withValuesSeparatedBy(',');
        parser.accepts("p", "partition id")
              .withRequiredArg()
              .ofType(Integer.class)
              .withValuesSeparatedBy(',');
        OptionSet options = parser.parse(args);

        List<String> nonOptions = (List<String>) options.nonOptionArguments();

        if(args.length < 2) {
            System.out.println(usageStr);
View Full Code Here

*/
public class StorageEnginePerformanceTest {

    public static void main(String[] args) throws Exception {
        try {
            OptionParser parser = new OptionParser();
            parser.accepts("help", "print usage information");
            parser.accepts("requests", "[REQUIRED] number of requests to execute")
                  .withRequiredArg()
                  .ofType(Integer.class);
            parser.accepts("num-values", "[REQUIRED] number of values in the store")
                  .withRequiredArg()
                  .ofType(Integer.class);
            parser.accepts("data-dir", "Data directory for storage data")
                  .withRequiredArg()
                  .describedAs("directory");
            parser.accepts("threads", "number of threads").withRequiredArg().ofType(Integer.class);
            parser.accepts("storage-configuration-class",
                           "[REQUIRED] class of the storage engine configuration to use [e.g. voldemort.store.bdb.BdbStorageConfiguration]")
                  .withRequiredArg()
                  .describedAs("class_name");
            parser.accepts("props", "Properties file with configuration for the engine")
                  .withRequiredArg()
                  .describedAs("config.properties");
            parser.accepts("value-size", "The size of the values in the store")
                  .withRequiredArg()
                  .describedAs("size")
                  .ofType(Integer.class);
            parser.accepts("cache-width", "Percentage of requests to save as possible re-requests")
                  .withRequiredArg()
                  .describedAs("width")
                  .ofType(Integer.class);
            parser.accepts("cache-hit-ratio",
                           "Percentage of requests coming from the last cache-width requests")
                  .withRequiredArg()
                  .describedAs("ratio")
                  .ofType(Double.class);
            parser.accepts("clean-up", "Delete data directory when done.");
            OptionSet options = parser.parse(args);

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

            CmdUtils.croakIfMissing(parser, options, "requests");

View Full Code Here

     *
     * @param args See usage for more information
     * @throws Exception In case of I/O or Voldemort-specific errors
     */
    public static void main(String[] args) throws Exception {
        OptionParser parser = new OptionParser();
        parser.accepts("help", "print usage information");
        parser.accepts("node", "[REQUIRED] node id")
              .withRequiredArg()
              .ofType(Integer.class)
              .describedAs("node id");
        parser.accepts("store-name", "[REQUIRED] store name")
              .withRequiredArg()
              .describedAs("store name");
        parser.accepts("url", "[REQUIRED] bootstrap URL")
              .withRequiredArg()
              .describedAs("bootstrap-url");
        parser.accepts("input", "[REQUIRED] input request file")
              .withRequiredArg()
              .describedAs("input-file");
        parser.accepts("output", "[REQUIRED] output file")
              .withRequiredArg()
              .describedAs("output-file");
        parser.accepts("string-keys");

        OptionSet options = parser.parse(args);

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

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

        int nodeId = (Integer) options.valueOf("node");
        String storeName = (String) options.valueOf("store-name");
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public static void main(String[] args) throws Exception {

        OptionParser parser = new OptionParser();
        parser.accepts("client-zone-id", "client zone id for zone routing")
              .withRequiredArg()
              .describedAs("zone-id")
              .ofType(Integer.class);
        OptionSet options = parser.parse(args);

        List<String> nonOptions = (List<String>) options.nonOptionArguments();
        if(nonOptions.size() < 2 || nonOptions.size() > 3) {
            System.err.println("Usage: java VoldemortClientShell store_name bootstrap_url [command_file] [options]");
            parser.printHelpOn(System.err);
            System.exit(-1);
        }

        String storeName = nonOptions.get(0);
        String bootstrapUrl = nonOptions.get(1);
View Full Code Here

    protected FailureDetectorPerformanceTest(String[] args) {
        // We instantiate this way up here so we can use the defaults.
        this.failureDetectorConfig = new FailureDetectorConfig();

        OptionParser parser = new OptionParser();
        parser.accepts("async-scan-interval",
                       "Time interval (in milliseconds) at which the AsyncRecoveryFailureDetector checks for recovered nodes. Default: "
                               + failureDetectorConfig.getAsyncRecoveryInterval())
              .withRequiredArg()
              .ofType(Long.class);
        parser.accepts("bannage-period",
                       "Time period (in milliseconds) for which a failed node is marked unavailable for the BannagePeriodFailureDetector. Default: "
                               + failureDetectorConfig.getBannagePeriod())
              .withRequiredArg()
              .ofType(Long.class);
        parser.accepts("threshold-interval",
                       "Time interval (in milliseconds) for which a node is marked unavailable by the ThresholdFailureDetector for having fallen under the threshold for failures for the period, after which it is considered available. Default: "
                               + failureDetectorConfig.getThresholdInterval())
              .withRequiredArg()
              .ofType(Long.class);
        parser.accepts("help", "This help");

        OptionSet options = parser.parse(args);

        if(options.has("help"))
            printUsage(parser);

        Long asyncScanInterval = CmdUtils.valueOf(options,
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.