Package joptsimple

Examples of joptsimple.OptionSet


            String storeConfigAvro = null;
            String storeConfigPath = null;
            Boolean confirm = false;

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

            // check required options and/or conflicting options
            CoordinatorAdminUtils.checkRequired(options, CoordinatorAdminUtils.OPT_URL);
            CoordinatorAdminUtils.checkRequired(options, OPT_DEFINITION, OPT_FILE);

            // load parameters
            urls = (List<String>) options.valuesOf(CoordinatorAdminUtils.OPT_URL);
            if(options.has(OPT_DEFINITION)) {
                storeConfigAvro = (String) options.valueOf(OPT_DEFINITION);
            }
            if(options.has(OPT_FILE)) {
                storeConfigPath = (String) options.valueOf(OPT_FILE);
                File storeConfigFile = new File(storeConfigPath);
                if(!storeConfigFile.exists()) {
                    throw new VoldemortException("cannot find config file: '" + storeConfigPath
                                                 + "'.");
                }
                storeConfigAvro = Joiner.on(" ")
                                        .join(IOUtils.readLines(new FileReader(storeConfigFile)))
                                        .trim();
            }
            if(options.has(CoordinatorAdminUtils.OPT_CONFIRM)) {
                confirm = true;
            }

            if(!CoordinatorAdminUtils.askConfirm(confirm, "put store config to coordinators")) {
                return;
View Full Code Here


            List<String> urls = null;
            List<String> storeNames = null;
            Boolean confirm = false;

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

            // check required options and/or conflicting options
            CoordinatorAdminUtils.checkRequired(options, CoordinatorAdminUtils.OPT_URL);
            CoordinatorAdminUtils.checkRequired(options, CoordinatorAdminUtils.OPT_STORE);

            // load parameters
            urls = (List<String>) options.valuesOf(CoordinatorAdminUtils.OPT_URL);
            storeNames = (List<String>) options.valuesOf(CoordinatorAdminUtils.OPT_STORE);

            if(options.has(CoordinatorAdminUtils.OPT_CONFIRM)) {
                confirm = true;
            }

            if(!CoordinatorAdminUtils.askConfirm(confirm, "delete store config on coordinators")) {
                return;
View Full Code Here

            Boolean allStores = false;
            String url = null;
            Boolean confirm = false;

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

            // check required options and/or conflicting options
            AdminParserUtils.checkRequired(options, AdminParserUtils.OPT_PARTITION);
            AdminParserUtils.checkRequired(options, AdminParserUtils.OPT_NODE);
            AdminParserUtils.checkRequired(options, AdminParserUtils.OPT_URL);
            AdminParserUtils.checkRequired(options,
                                           AdminParserUtils.OPT_STORE,
                                           AdminParserUtils.OPT_ALL_STORES);

            // load parameters
            partIds = (List<Integer>) options.valuesOf(AdminParserUtils.OPT_PARTITION);
            nodeId = (Integer) options.valueOf(AdminParserUtils.OPT_NODE);
            if(options.has(AdminParserUtils.OPT_STORE)) {
                storeNames = (List<String>) options.valuesOf(AdminParserUtils.OPT_STORE);
                allStores = false;
            } else {
                allStores = true;
            }
            url = (String) options.valueOf(AdminParserUtils.OPT_URL);
            if(options.has(AdminParserUtils.OPT_CONFIRM)) {
                confirm = true;
            }

            // print summary
            System.out.println("Remove contents of partitions");
View Full Code Here

            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;
            }

            // check required options and/or conflicting options
            AdminParserUtils.checkRequired(options, AdminParserUtils.OPT_STORE);
            AdminParserUtils.checkRequired(options, AdminParserUtils.OPT_URL);
            AdminParserUtils.checkOptional(options,
                                           AdminParserUtils.OPT_NODE,
                                           AdminParserUtils.OPT_ALL_NODES);

            // load parameters
            storeNames = (List<String>) options.valuesOf(AdminParserUtils.OPT_STORE);
            url = (String) options.valueOf(AdminParserUtils.OPT_URL);
            if(options.has(AdminParserUtils.OPT_NODE)) {
                nodeIds = (List<Integer>) options.valuesOf(AdminParserUtils.OPT_NODE);
                allNodes = false;
            }
            if(options.has(AdminParserUtils.OPT_CONFIRM)) {
                confirm = true;
            }

            // print summary
            System.out.println("Remove contents of stores");
View Full Code Here

        }
    }

    public static void main(String[] argv) throws Exception {
        OptionParser parser = getParser();
        OptionSet options = parser.parse(argv);
        validateOptions(options);

        ZoneShrinkageCLI cli = new ZoneShrinkageCLI((String) options.valueOf("url"),
                                                    (Integer) options.valueOf("drop-zoneid"));
        try {
            cli.executeShrink(options.has("real-run"));
        } catch(Exception e) {
            e.printStackTrace();
            logAbort();
        }
    }
View Full Code Here

    }


    @SuppressWarnings("unchecked")
    public static void main(String[] args) throws Exception {
        OptionSet options = getParser().parse(args);

        /* validate options */
        if (options.hasArgument("help")) {
            printUsage();
            return;
        }
        if (!options.hasArgument("urls") || !options.hasArgument("partitions")
                || !options.hasArgument("store") || !options.hasArgument("bad-key-file")) {
            printUsage();
            return;
        }

        List<String> urls = (List<String>) options.valuesOf("urls");
        String storeName = (String) options.valueOf("store");
        List<Integer> partitionIds = (List<Integer>) options.valuesOf("partitions");
        String badKeyFile = (String) options.valueOf("bad-key-file");

        ComparisonType comparisonType = ComparisonType.VERSION;
        if (options.hasArgument(ComparisonTypeArgument)) {
            String comparisonArgument = (String) options.valueOf(ComparisonTypeArgument);
            comparisonArgument = comparisonArgument.toUpperCase();
            comparisonType = ComparisonType.valueOf(comparisonArgument) ;
        }

        BufferedWriter badKeyWriter = null;
View Full Code Here

        printUsage();
        Utils.croak("\n" + errMessage);
    }

    private static OptionSet getValidOptions(String[] args) {
        OptionSet options = null;
        try {
            options = parser.parse(args);
        } catch(OptionException oe) {
            printUsageAndDie("Exception when parsing arguments : " + oe.getMessage());
        }

        if(options.has("help")) {
            printUsage();
            System.exit(0);
        }

        Set<String> missing = CmdUtils.missing(options, "cluster", "stores");
View Full Code Here

        return options;
    }

    public static void main(String[] args) throws Exception {
        setupParser();
        OptionSet options = getValidOptions(args);

        String clusterXML = (String) options.valueOf("cluster");
        String storesXML = (String) options.valueOf("stores");

        Cluster currentCluster = new ClusterMapper().readCluster(new File(clusterXML));
        List<StoreDefinition> storeDefs = new StoreDefinitionsMapper().readStoreList(new File(storesXML));

        PartitionBalance partitionBalance = new PartitionBalance(currentCluster, storeDefs);
View Full Code Here

        printUsage();
        Utils.croak("\n" + errMessage);
    }

    private static OptionSet getValidOptions(String[] args) {
        OptionSet options = null;
        try {
            options = parser.parse(args);
        } catch(OptionException oe) {
            printUsageAndDie("Exception when parsing arguments : " + oe.getMessage());
        }

        if(options.has("help")) {
            printUsage();
            System.exit(0);
        }

        Set<String> missing = CmdUtils.missing(options, "current-cluster", "current-stores");
        if(missing.size() > 0) {
            printUsageAndDie("Missing required arguments: " + Joiner.on(", ").join(missing));
        }
        if(options.has("final-stores") && !options.has("interim-cluster")) {
            printUsageAndDie("final-stores specified, but interim-cluster not specified.");
        }

        return options;
    }
View Full Code Here

        return options;
    }

    public static void main(String[] args) throws Exception {
        setupParser();
        OptionSet options = getValidOptions(args);

        // Required args
        String currentClusterXML = (String) options.valueOf("current-cluster");
        String currentStoresXML = (String) options.valueOf("current-stores");
        String interimClusterXML = new String(currentClusterXML);
        if(options.has("interim-cluster")) {
            interimClusterXML = (String) options.valueOf("interim-cluster");
        }
        String finalStoresXML = new String(currentStoresXML);
        if(options.has("final-stores")) {
            finalStoresXML = (String) options.valueOf("final-stores");
        }

        Cluster currentCluster = new ClusterMapper().readCluster(new File(currentClusterXML));
        List<StoreDefinition> currentStoreDefs = new StoreDefinitionsMapper().readStoreList(new File(currentStoresXML));
        RebalanceUtils.validateClusterStores(currentCluster, currentStoreDefs);

        Cluster interimCluster = new ClusterMapper().readCluster(new File(interimClusterXML));
        List<StoreDefinition> finalStoreDefs = new StoreDefinitionsMapper().readStoreList(new File(finalStoresXML));
        RebalanceUtils.validateClusterStores(interimCluster, finalStoreDefs);

        RebalanceUtils.validateCurrentInterimCluster(currentCluster, interimCluster);

        // Optional administrivia args
        int attempts = CmdUtils.valueOf(options,
                                        "attempts",
                                        Repartitioner.DEFAULT_REPARTITION_ATTEMPTS);
        String outputDir = null;
        if(options.has("output-dir")) {
            outputDir = (String) options.valueOf("output-dir");
        }

        // Optional repartitioning args
        boolean disableNodeBalancing = options.has("disable-node-balancing");
        boolean disableZoneBalancing = options.has("disable-zone-balancing");
        boolean enableRandomSwaps = options.has("enable-random-swaps");
        int randomSwapAttempts = CmdUtils.valueOf(options,
                                                  "random-swap-attempts",
                                                  Repartitioner.DEFAULT_RANDOM_SWAP_ATTEMPTS);
        int randomSwapSuccesses = CmdUtils.valueOf(options,
                                                   "random-swap-successes",
                                                   Repartitioner.DEFAULT_RANDOM_SWAP_SUCCESSES);
        List<Integer> randomSwapZoneIds = CmdUtils.valuesOf(options,
                                                            "random-swap-zoneids",
                                                            Repartitioner.DEFAULT_RANDOM_SWAP_ZONE_IDS);
        boolean enableGreedySwaps = options.has("enable-greedy-swaps");
        int greedySwapAttempts = CmdUtils.valueOf(options,
                                                  "greedy-swap-attempts",
                                                  Repartitioner.DEFAULT_GREEDY_SWAP_ATTEMPTS);
        int greedyMaxPartitionsPerNode = CmdUtils.valueOf(options,
                                                          "greedy-max-partitions-per-node",
                                                          Repartitioner.DEFAULT_GREEDY_MAX_PARTITIONS_PER_NODE);
        int greedyMaxPartitionsPerZone = CmdUtils.valueOf(options,
                                                          "greedy-max-partitions-per-zone",
                                                          Repartitioner.DEFAULT_GREEDY_MAX_PARTITIONS_PER_ZONE);
        List<Integer> greedySwapZoneIds = CmdUtils.valuesOf(options,
                                                            "greedy-swap-zoneids",
                                                            Repartitioner.DEFAULT_GREEDY_SWAP_ZONE_IDS);
        int maxContiguousPartitionsPerZone = CmdUtils.valueOf(options,
                                                              "max-contiguous-partitions",
                                                              Repartitioner.DEFAULT_MAX_CONTIGUOUS_PARTITIONS);

        // Sanity check optional repartitioning args
        if(disableNodeBalancing && !enableRandomSwaps && !enableGreedySwaps
           && maxContiguousPartitionsPerZone == 0) {
            printUsageAndDie("Did not enable any forms for repartitioning.");
        }
        if((options.has("random-swap-attempts") || options.has("random-swap-successes"))
           && !enableRandomSwaps) {
            printUsageAndDie("Provided arguments for generate random swaps but did not enable the feature");
        }
        if((options.has("greedy-swap-attempts") || options.has("greedy-max-partitions-per-node") || options.has("greedy-max-partitions-per-zone"))
           && !enableGreedySwaps) {
            printUsageAndDie("Provided arguments for generate greedy swaps but did not enable the feature");
        }

        Repartitioner.repartition(currentCluster,
View Full Code Here

TOP

Related Classes of joptsimple.OptionSet

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.