Examples of OptionSet


Examples of ch.ethz.inf.vs.californium.coap.OptionSet

          Request request = exchange.getRequest();
          int num = block2.getNum() + 1;
          int szx = block2.getSzx();
          boolean m = false;
          Request block = new Request(request.getCode());
          block.setOptions(new OptionSet(request.getOptions()));
          block.setDestination(request.getDestination());
          block.setDestinationPort(request.getDestinationPort());
         
          block.setType(request.getType()); // NON could make sense over SMS or similar transports
          block.getOptions().setBlock2(szx, m, num);
View Full Code Here

Examples of joptsimple.OptionSet

              .withRequiredArg()
              .describedAs("version");
        parser.accepts("test-gz", "Path to gzip containing data. Works with --build only")
              .withRequiredArg()
              .describedAs("path");
        OptionSet options = parser.parse(args);

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

        CmdUtils.croakIfMissing(parser, options, "requests", "store-dir");

        final int numThreads = CmdUtils.valueOf(options, "threads", 10);
        final int numRequests = (Integer) options.valueOf("requests");
        final int internalSortSize = CmdUtils.valueOf(options, "internal-sort-size", 500000);
        int numValues = numRequests;
        final String inputFile = (String) options.valueOf("request-file");
        final String searcherClass = CmdUtils.valueOf(options,
                                                      "search-strategy",
                                                      BinarySearchStrategy.class.getName()).trim();
        final boolean gzipIntermediate = options.has("gzip");
        final SearchStrategy searcher = (SearchStrategy) ReflectUtils.callConstructor(ReflectUtils.loadClass(searcherClass));
        final File workingDir = new File(CmdUtils.valueOf(options,
                                                          "working-dir",
                                                          System.getProperty("java.io.tmpdir")));
        String storeDir = (String) options.valueOf("store-dir");
        ReadOnlyStorageFormat format = ReadOnlyStorageFormat.fromCode(CmdUtils.valueOf(options,
                                                                                       "version",
                                                                                       ReadOnlyStorageFormat.READONLY_V2.toString()));
        Cluster cluster = null;
        int nodeId = 0;

        SerializerDefinition sdef = new SerializerDefinition("json", "'string'");
        StoreDefinition storeDef = new StoreDefinitionBuilder().setName("test")
                                                               .setKeySerializer(sdef)
                                                               .setValueSerializer(sdef)
                                                               .setRequiredReads(1)
                                                               .setReplicationFactor(1)
                                                               .setRequiredWrites(1)
                                                               .setType("read-only")
                                                               .setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY)
                                                               .setRoutingPolicy(RoutingTier.CLIENT)
                                                               .build();

        if(options.has("build")) {
            CmdUtils.croakIfMissing(parser, options, "num-values", "value-size");
            numValues = (Integer) options.valueOf("num-values");
            int numChunks = 1;
            if(options.has("num-chunks"))
                numChunks = (Integer) options.valueOf("num-chunks");
            int valueSize = (Integer) options.valueOf("value-size");

            // generate test data
            File temp = null;
            if(options.has("test-gz")) {
                temp = new File((String) options.valueOf("test-gz"));
            } else {
                temp = File.createTempFile("json-data", ".txt.gz", workingDir);
                temp.deleteOnExit();
                System.out.println("Generating test data in " + temp);
                OutputStream outputStream = new GZIPOutputStream(new FileOutputStream(temp));
                Writer writer = new BufferedWriter(new OutputStreamWriter(outputStream),
                                                   10 * 1024 * 1024);
                String value = TestUtils.randomLetters(valueSize);
                for(int i = 0; i < numValues; i++) {
                    writer.write("\"");
                    writer.write(Integer.toString(i));
                    writer.write("\" \"");
                    writer.write(value);
                    writer.write("\"");
                    writer.write("\n");
                }
                writer.close();
                writer = null;
            }

            System.out.println("Building store.");
            InputStream inputStream = new GZIPInputStream(new FileInputStream(temp));
            Reader r = new BufferedReader(new InputStreamReader(inputStream), 1 * 1024 * 1024);
            File output = TestUtils.createTempDir(workingDir);
            File tempDir = TestUtils.createTempDir(workingDir);

            cluster = ServerTestUtils.getLocalCluster(1);
            nodeId = 0;

            JsonStoreBuilder builder = new JsonStoreBuilder(new JsonReader(r),
                                                            cluster,
                                                            storeDef,
                                                            new ConsistentRoutingStrategy(cluster,
                                                                                          1),
                                                            output,
                                                            tempDir,
                                                            internalSortSize,
                                                            2,
                                                            numChunks,
                                                            64 * 1024,
                                                            gzipIntermediate);
            builder.build(format);

            // copy to store dir
            File dir = new File(storeDir);
            Utils.rm(dir);
            dir.mkdirs();
            System.out.println("Moving store data from " + output + " to " + dir);
            boolean copyWorked = new File(output, "node-0").renameTo(new File(dir, "version-0"));
            if(!copyWorked)
                Utils.croak("Copy of data from " + output + " to " + dir + " failed.");
        } else {
            CmdUtils.croakIfMissing(parser, options, "cluster-xml", "node-id");

            String clusterXmlPath = (String) options.valueOf("cluster-xml");
            nodeId = (Integer) options.valueOf("node-id");

            File clusterXml = new File(clusterXmlPath);
            if(!clusterXml.exists()) {
                Utils.croak("Cluster.xml does not exist");
            }
View Full Code Here

Examples of joptsimple.OptionSet

              .withRequiredArg();
        parser.accepts("hostuserid", "User ID on remote host").withRequiredArg();
        parser.accepts("voldemortroot", "Voldemort's root directory on remote host")
              .withRequiredArg();

        OptionSet options = parse(args);
        File hostNamesFile = getRequiredInputFile(options, "hostnames");
        List<HostNamePair> hostNamePairs = getHostNamesPairsFromFile(hostNamesFile);
        List<String> hostNames = new ArrayList<String>();

        for(HostNamePair hostNamePair: hostNamePairs)
View Full Code Here

Examples of joptsimple.OptionSet

                       "Region type; options are " + RegionInfo.REGIONURL_AP_SOUTHEAST + ", "
                               + RegionInfo.REGIONURL_EU_WEST + ", " + RegionInfo.REGIONURL_US_WEST
                               + ", " + RegionInfo.REGIONURL_US_EAST + " (default) ")
              .withRequiredArg();

        OptionSet options = parse(args);
        String accessId = getAccessId(options);
        String secretKey = getSecretKey(options);
        String ami = getRequiredString(options, "ami");
        String keypairId = getRequiredString(options, "keypairid");
        String regionUrl = getRegionUrl(options);
View Full Code Here

Examples of joptsimple.OptionSet

                       "Type of routed store, either \"" + THREAD_POOL_ROUTED_STORE + "\" or \""
                               + PIPELINE_ROUTED_STORE + "\"  Default = "
                               + DEFAULT_ROUTED_STORE_TYPE).withRequiredArg();
        parser.accepts("help", "This help");

        OptionSet options = parser.parse(args);

        if(options.has("help")) {
            printUsage(System.out, parser);
        }

        final int numKeys = CmdUtils.valueOf(options, "num-keys", DEFAULT_NUM_KEYS);
        int maxConnectionsPerNode = CmdUtils.valueOf(options,
View Full Code Here

Examples of joptsimple.OptionSet

        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)
            Utils.croak("Missing required arguments: " + Joiner.on(", ").join(missing));

        String host = CmdUtils.valueOf(options, "host", "localhost");
        String table = (String) options.valueOf("table");
        int port = CmdUtils.valueOf(options, "port", 3306);
        String database = (String) options.valueOf("db");
        String jdbcUrl = "jdbc:mysql://" + host + ":" + port + "/" + database;
        String user = CmdUtils.valueOf(options, "user", "root");
        String password = CmdUtils.valueOf(options, "password", "");
        String requestFile = (String) options.valueOf("request-file");
        int numRequests = (Integer) options.valueOf("requests");
        int numThreads = CmdUtils.valueOf(options, "threads", 10);
        boolean doReads = false;
        boolean doWrites = false;
        if(options.has("reads") || options.has("writes")) {
            doReads = options.has("reads");
            doWrites = options.has("writes");
        } else {
            doReads = true;
            doWrites = true;
        }
        MysqlBench bench = new MysqlBench(table,
View Full Code Here

Examples of joptsimple.OptionSet

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

        String url = nonOptions.get(0);
        String storeName = nonOptions.get(1);

        int requests = Integer.parseInt(nonOptions.get(2));
        int keySize = CmdUtils.valueOf(options, "k", 128);
        int valueSize = CmdUtils.valueOf(options, "v", 256);
        int workers = CmdUtils.valueOf(options, "threads", MAX_WORKERS);
        String postfix = (String) (options.has("p") ? options.valueOf("p") : null);
        RemoteDataGenerator rdg = new RemoteDataGenerator(url, storeName, workers);
        rdg.generateData(requests, keySize, valueSize, postfix);
    }
View Full Code Here

Examples of joptsimple.OptionSet

        System.exit(1);
    }

    protected OptionSet parse(String[] args) {
        try {
            OptionSet options = parser.parse(args);

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

            setLogging(options);
            return options;
        } catch(OptionException e) {
View Full Code Here

Examples of joptsimple.OptionSet

              .withRequiredArg();
        parser.accepts("useinternal", "Use internal host name; defaults to true")
              .withRequiredArg()
              .ofType(Boolean.class);

        OptionSet options = parse(args);
        File hostNamesFile = getRequiredInputFile(options, "hostnames");

        List<HostNamePair> hostNamePairs = getHostNamesPairsFromFile(hostNamesFile);
        final List<String> externalHostNames = new ArrayList<String>();
        final List<String> internalHostNames = new ArrayList<String>();
View Full Code Here

Examples of joptsimple.OptionSet

        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);
        String storeName = rest.get(1);
        Integer connsTotal = CmdUtils.valueOf(options, CONNECTIONS, 100);
        Integer reqs = CmdUtils.valueOf(options, REQS, 1000);

        ClientConfig config = new ClientConfig();
        if(options.has(CONNECTION_TIMEOUT))
            config.setConnectionTimeout((Integer) options.valueOf(CONNECTION_TIMEOUT),
                                        TimeUnit.MILLISECONDS);
        if(options.has(ROUTING_TIMEOUT))
            config.setTimeoutConfig(new TimeoutConfig(TimeUnit.MILLISECONDS.toMillis((Integer) options.valueOf(ROUTING_TIMEOUT)),
                                                      false));

        if(options.has(SOCKET_TIMEOUT))
            config.setSocketTimeout((Integer) options.valueOf(SOCKET_TIMEOUT),
                                    TimeUnit.MILLISECONDS);
        if(options.has(MAX_CONNECTIONS))
            config.setMaxConnectionsPerNode((Integer) options.valueOf(MAX_CONNECTIONS));
        if(options.has(MAX_THREADS))
            config.setMaxThreads((Integer) options.valueOf(MAX_THREADS));
        if(options.has(SELECTORS))
            config.setSelectors((Integer) options.valueOf(SELECTORS));
        if(options.has(SOCKET_BUFFER_SIZE))
            config.setSocketBufferSize((Integer) options.valueOf(SOCKET_BUFFER_SIZE));
        config.setBootstrapUrls(url);

        ClientConnectionStressTest test = new ClientConnectionStressTest(config,
                                                                         storeName,
                                                                         config.getMaxThreads(),
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.