Example usage for com.google.common.net HostAndPort getPort

List of usage examples for com.google.common.net HostAndPort getPort

Introduction

In this page you can find the example usage for com.google.common.net HostAndPort getPort.

Prototype

public int getPort() 

Source Link

Document

Get the current port number, failing if no port is defined.

Usage

From source file:io.codis.nedis.bench.NedisBench.java

public static void main(String[] args) throws InterruptedException {
    Args parsedArgs = new Args();
    CmdLineParser parser = new CmdLineParser(parsedArgs);
    try {//w w w  . ja va 2 s . c  om
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        parser.printUsage(System.err);
        return;
    }

    AtomicBoolean stop = new AtomicBoolean(false);
    AtomicLong reqCount = new AtomicLong(0);
    ExecutorService executor = Executors.newFixedThreadPool(parsedArgs.threads,
            new ThreadFactoryBuilder().setDaemon(true).build());
    HostAndPort hap = HostAndPort.fromString(parsedArgs.redisAddr);
    NedisClient client = NedisUtils.newPooledClient(NedisClientPoolBuilder.create()
            .maxPooledConns(parsedArgs.conns).remoteAddress(hap.getHostText(), hap.getPort()).build());
    for (int i = 0; i < parsedArgs.threads; i++) {
        executor.execute(new Worker(stop, reqCount, client, parsedArgs.pipeline));
    }
    long duration = TimeUnit.MINUTES.toNanos(parsedArgs.minutes);
    long startTime = System.nanoTime();
    long prevTime = -1L;
    long prevReqCount = -1L;
    for (;;) {
        long currentTime = System.nanoTime();
        if (currentTime - startTime >= duration) {
            stop.set(true);
            executor.shutdown();
            if (!executor.awaitTermination(1, TimeUnit.MINUTES)) {
                throw new RuntimeException("Can not terminate workers");
            }
            System.out.println(String.format("Test run %d minutes, qps: %.2f", parsedArgs.minutes,
                    (double) reqCount.get() / (currentTime - startTime) * TimeUnit.SECONDS.toNanos(1)));
            client.close().sync();
            return;
        }
        long currentReqCount = reqCount.get();
        if (prevTime > 0) {
            System.out.println(String.format("qps: %.2f", (double) (currentReqCount - prevReqCount)
                    / (currentTime - prevTime) * TimeUnit.SECONDS.toNanos(1)));
        }
        prevTime = currentTime;
        prevReqCount = currentReqCount;
        Thread.sleep(5000);
    }
}

From source file:io.codis.nedis.bench.JedisBench.java

public static void main(String[] args) throws InterruptedException {
    Args parsedArgs = new Args();
    CmdLineParser parser = new CmdLineParser(parsedArgs);
    try {/*from   w  ww. j av  a2  s.c o  m*/
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        parser.printUsage(System.err);
        return;
    }

    AtomicBoolean stop = new AtomicBoolean(false);
    AtomicLong reqCount = new AtomicLong(0);
    ExecutorService executor = Executors.newFixedThreadPool(parsedArgs.threads,
            new ThreadFactoryBuilder().setDaemon(true).build());
    HostAndPort hap = HostAndPort.fromString(parsedArgs.redisAddr);
    JedisPoolConfig config = new JedisPoolConfig();
    config.setMaxTotal(parsedArgs.conns);
    config.setMaxIdle(parsedArgs.conns);
    JedisPool pool = new JedisPool(config, hap.getHostText(), hap.getPort());
    for (int i = 0; i < parsedArgs.threads; i++) {
        executor.execute(new Worker(stop, reqCount, pool, parsedArgs.pipeline));
    }
    long duration = TimeUnit.MINUTES.toNanos(parsedArgs.minutes);
    long startTime = System.nanoTime();
    long prevTime = -1L;
    long prevReqCount = -1L;
    for (;;) {
        long currentTime = System.nanoTime();
        if (currentTime - startTime >= duration) {
            stop.set(true);
            executor.shutdown();
            if (!executor.awaitTermination(1, TimeUnit.MINUTES)) {
                throw new RuntimeException("Can not terminate workers");
            }
            System.out.println(String.format("Test run %d minutes, qps: %.2f", parsedArgs.minutes,
                    (double) reqCount.get() / (currentTime - startTime) * TimeUnit.SECONDS.toNanos(1)));
            pool.close();
            return;
        }
        long currentReqCount = reqCount.get();
        if (prevTime > 0) {
            System.out.println(String.format("qps: %.2f", (double) (currentReqCount - prevReqCount)
                    / (currentTime - prevTime) * TimeUnit.SECONDS.toNanos(1)));
        }
        prevTime = currentTime;
        prevReqCount = currentReqCount;
        Thread.sleep(5000);
    }
}

From source file:com.torodb.stampede.Main.java

public static void main(String[] args) throws Exception {
    try {//from ww  w.j a v  a2 s.com
        Console console = JCommander.getConsole();

        ResourceBundle cliBundle = PropertyResourceBundle.getBundle("CliMessages");
        final CliConfig cliConfig = new CliConfig();
        JCommander jCommander = new JCommander(cliConfig, cliBundle, args);
        jCommander.setColumnSize(Integer.MAX_VALUE);

        if (cliConfig.isVersion()) {
            BuildProperties buildProperties = new DefaultBuildProperties();
            console.println(buildProperties.getFullVersion());
            System.exit(0);
        }

        if (cliConfig.isHelp()) {
            jCommander.usage();
            System.exit(0);
        }

        if (cliConfig.isHelpParam()) {
            console.println(cliBundle.getString("cli.help-param-header"));
            ConfigUtils.printParamDescriptionFromConfigSchema(Config.class, cliBundle, console, 0);
            System.exit(0);
        }

        cliConfig.addParams();

        final Config config = CliConfigUtils.readConfig(cliConfig);

        if (cliConfig.isPrintConfig()) {
            ConfigUtils.printYamlConfig(config, console);

            System.exit(0);
        }

        if (cliConfig.isPrintXmlConfig()) {
            ConfigUtils.printXmlConfig(config, console);

            System.exit(0);
        }

        if (cliConfig.isPrintParam()) {
            JsonNode jsonNode = ConfigUtils.getParam(config, cliConfig.getPrintParamPath());

            if (jsonNode != null) {
                console.print(jsonNode.asText());
            }

            System.exit(0);
        }

        configureLogger(cliConfig, config);

        config.getBackend().getBackendImplementation().accept(new BackendImplementationVisitor() {
            @Override
            public void visit(AbstractDerby value) {
                parseToropassFile(value);
            }

            @Override
            public void visit(AbstractPostgres value) {
                parseToropassFile(value);
            }

            public void parseToropassFile(BackendPasswordConfig value) {
                try {
                    ConfigUtils.parseToropassFile(value);
                } catch (Exception ex) {
                    throw new SystemException(ex);
                }
            }
        });
        AbstractReplication replication = config.getReplication();
        if (replication.getAuth().getUser() != null) {
            HostAndPort syncSource = HostAndPort.fromString(replication.getSyncSource()).withDefaultPort(27017);
            ConfigUtils.parseMongopassFile(new MongoPasswordConfig() {

                @Override
                public void setPassword(String password) {
                    replication.getAuth().setPassword(password);
                }

                @Override
                public String getUser() {
                    return replication.getAuth().getUser();
                }

                @Override
                public Integer getPort() {
                    return syncSource.getPort();
                }

                @Override
                public String getPassword() {
                    return replication.getAuth().getPassword();
                }

                @Override
                public String getMongopassFile() {
                    return config.getReplication().getMongopassFile();
                }

                @Override
                public String getHost() {
                    return syncSource.getHostText();
                }

                @Override
                public String getDatabase() {
                    return replication.getAuth().getSource();
                }
            });
        }

        if (config.getBackend().isLike(AbstractPostgres.class)) {
            AbstractPostgres postgres = config.getBackend().as(AbstractPostgres.class);

            if (cliConfig.isAskForPassword()) {
                console.print("Type database user " + postgres.getUser() + "'s password:");
                postgres.setPassword(readPwd());
            }

            if (postgres.getPassword() == null) {
                throw new SystemException("No password provided for database user " + postgres.getUser()
                        + ".\n\n" + "Please add following line to file " + postgres.getToropassFile() + ":\n"
                        + postgres.getHost() + ":" + postgres.getPort() + ":" + postgres.getDatabase() + ":"
                        + postgres.getUser() + ":<password>\n" + "Replace <password> for database user "
                        + postgres.getUser() + "'s password");
            }
        }

        try {
            Clock clock = Clock.systemDefaultZone();

            Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
                @Override
                @SuppressFBWarnings(value = "DM_EXIT", justification = "Since is really hard to stop cleanly all threads when an OOME is thrown we must "
                        + "exit to avoid no more action is performed that could lead to an unespected "
                        + "state")
                public void uncaughtException(Thread t, Throwable e) {
                    if (e instanceof OutOfMemoryError) {
                        try {
                            LOGGER.error("Fatal out of memory: " + e.getLocalizedMessage(), e);
                        } finally {
                            System.exit(1);
                        }
                    }
                }
            });

            Service stampedeService = StampedeBootstrap.createStampedeService(config, clock);

            stampedeService.startAsync();
            stampedeService.awaitTerminated();

            Runtime.getRuntime().addShutdownHook(new Thread(() -> {
                stampedeService.stopAsync();
                stampedeService.awaitTerminated();
            }));
        } catch (CreationException ex) {
            ex.getErrorMessages().stream().forEach(m -> {
                if (m.getCause() != null) {
                    LOGGER.error(m.getCause().getMessage());
                } else {
                    LOGGER.error(m.getMessage());
                }
            });
            LogManager.shutdown();
            System.exit(1);
        }
    } catch (Throwable ex) {
        LOGGER.debug("Fatal error on initialization", ex);
        Throwable rootCause = Throwables.getRootCause(ex);
        String causeMessage = rootCause.getMessage();
        LogManager.shutdown();
        JCommander.getConsole().println("Fatal error while ToroDB was starting: " + causeMessage);
        System.exit(1);
    }
}

From source file:com.torodb.standalone.Main.java

public static void main(String[] args) throws Exception {
    Console console = JCommander.getConsole();

    ResourceBundle cliBundle = PropertyResourceBundle.getBundle("CliMessages");
    final CliConfig cliConfig = new CliConfig();
    JCommander jCommander = new JCommander(cliConfig, cliBundle, args);
    jCommander.setColumnSize(Integer.MAX_VALUE);

    if (cliConfig.isHelp()) {
        jCommander.usage();/* w  ww  . j a v a  2  s.c  o  m*/
        System.exit(0);
    }

    if (cliConfig.isHelpParam()) {
        console.println(cliBundle.getString("help-param-header"));
        ResourceBundle configBundle = PropertyResourceBundle.getBundle("ConfigMessages");
        ConfigUtils.printParamDescriptionFromConfigSchema(Config.class, configBundle, console, 0);
        System.exit(0);
    }

    final Config config = CliConfigUtils.readConfig(cliConfig);

    if (cliConfig.isPrintConfig()) {
        ConfigUtils.printYamlConfig(config, console);

        System.exit(0);
    }

    if (cliConfig.isPrintXmlConfig()) {
        ConfigUtils.printXmlConfig(config, console);

        System.exit(0);
    }

    configureLogger(cliConfig, config);

    config.getBackend().getBackendImplementation().accept(new BackendImplementationVisitor() {
        @Override
        public void visit(AbstractDerby value) {
            parseToropassFile(value);
        }

        @Override
        public void visit(AbstractPostgres value) {
            parseToropassFile(value);
        }

        public void parseToropassFile(BackendPasswordConfig value) {
            try {
                ConfigUtils.parseToropassFile(value);
            } catch (Exception ex) {
                throw new SystemException(ex);
            }
        }
    });
    if (config.getProtocol().getMongo().getReplication() != null) {
        for (AbstractReplication replication : config.getProtocol().getMongo().getReplication()) {
            if (replication.getAuth().getUser() != null) {
                HostAndPort syncSource = HostAndPort.fromString(replication.getSyncSource())
                        .withDefaultPort(27017);
                ConfigUtils.parseMongopassFile(new MongoPasswordConfig() {

                    @Override
                    public void setPassword(String password) {
                        replication.getAuth().setPassword(password);
                    }

                    @Override
                    public String getUser() {
                        return replication.getAuth().getUser();
                    }

                    @Override
                    public Integer getPort() {
                        return syncSource.getPort();
                    }

                    @Override
                    public String getPassword() {
                        return replication.getAuth().getPassword();
                    }

                    @Override
                    public String getMongopassFile() {
                        return config.getProtocol().getMongo().getMongopassFile();
                    }

                    @Override
                    public String getHost() {
                        return syncSource.getHostText();
                    }

                    @Override
                    public String getDatabase() {
                        return replication.getAuth().getSource();
                    }
                });
            }
        }
    }

    if (config.getBackend().isLike(AbstractPostgres.class)) {
        AbstractPostgres postgres = config.getBackend().as(AbstractPostgres.class);

        if (cliConfig.isAskForPassword()) {
            console.print("Database user " + postgres.getUser() + " password:");
            postgres.setPassword(readPwd());
        }
    } else if (config.getBackend().isLike(AbstractDerby.class)) {
        AbstractDerby derby = config.getBackend().as(AbstractDerby.class);

        if (cliConfig.isAskForPassword()) {
            console.print("Database user " + derby.getUser() + " password:");
            derby.setPassword(readPwd());
        }
    }

    try {
        Clock clock = Clock.systemDefaultZone();
        Service server;
        if (config.getProtocol().getMongo().getReplication() == null
                || config.getProtocol().getMongo().getReplication().isEmpty()) {
            Service toroDbServer = ToroDbBootstrap.createStandaloneService(config, clock);

            toroDbServer.startAsync();
            toroDbServer.awaitRunning();

            server = toroDbServer;
        } else {
            throw new UnsupportedOperationException("Replication not supported yet!");
        }

        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            server.stopAsync();
            server.awaitTerminated();
        }));
    } catch (CreationException ex) {
        ex.getErrorMessages().stream().forEach(m -> {
            if (m.getCause() != null) {
                LOGGER.error(m.getCause().getMessage());
            } else {
                LOGGER.error(m.getMessage());
            }
        });
        System.exit(1);
    } catch (Throwable ex) {
        LOGGER.error("Fatal error on initialization", ex);
        Throwable rootCause = Throwables.getRootCause(ex);
        String causeMessage = rootCause.getMessage();
        JCommander.getConsole().println("Fatal error while ToroDB was starting: " + causeMessage);
        System.exit(1);
    }
}

From source file:org.dcache.nfs.v4.client.Main.java

public static void main(String[] args) throws IOException, OncRpcException, InterruptedException {

    System.out.println("Started the NFS4 Client ....");
    String line;/*from  w ww .j a v a  2 s  .  c  o  m*/

    Main nfsClient = null;

    final String[] commands = { "mount", "cd", "ls", "lookup", "lookup-fh", "mkdir", "read", "readatonce",
            "filebomb", "remove", "umount", "write", "fs_locations", "getattr", "openbomb", "read-nostate" };

    ConsoleReader reader = new ConsoleReader();
    reader.setPrompt(PROMPT);
    reader.setHistoryEnabled(true);
    reader.addCompleter(new StringsCompleter(commands));

    if (args.length > 0) {
        HostAndPort hp = HostAndPort.fromString(args[0]).withDefaultPort(2049).requireBracketsForIPv6();

        InetSocketAddress serverAddress = new InetSocketAddress(hp.getHostText(), hp.getPort());
        nfsClient = new Main(serverAddress);
        nfsClient.mount("/");
    }

    PrintWriter out = new PrintWriter(reader.getOutput());

    while ((line = reader.readLine()) != null) {
        line = line.trim();
        if (line.length() == 0) {
            continue;
        }

        String[] commandArgs = line.split("[ \t]+");

        try {

            if (commandArgs[0].equals("mount")) {

                String host = commandArgs.length > 1 ? commandArgs[1] : "localhost";
                String root = commandArgs.length > 2 ? commandArgs[2] : "/";
                nfsClient = new Main(InetAddress.getByName(host));
                nfsClient.mount(root);

            } else if (commandArgs[0].equals("umount")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                nfsClient.umount();
                nfsClient = null;

            } else if (commandArgs[0].equals("ls")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length == 2) {
                    nfsClient.readdir(commandArgs[1]);
                } else {
                    nfsClient.readdir();
                }

            } else if (commandArgs[0].equals("cd")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length != 2) {
                    System.out.println("usage: cd <path>");
                    continue;
                }
                nfsClient.cwd(commandArgs[1]);

            } else if (commandArgs[0].equals("lookup")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length != 2) {
                    System.out.println("usage: lookup <path>");
                    continue;
                }
                nfsClient.lookup(commandArgs[1]);

            } else if (commandArgs[0].equals("lookup-fh")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length != 3) {
                    System.out.println("usage: lookup-fh <fh> <path>");
                    continue;
                }
                nfsClient.lookup(commandArgs[1], commandArgs[2]);

            } else if (commandArgs[0].equals("getattr")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length != 2) {
                    System.out.println("usage: getattr <path>");
                    continue;
                }
                nfsClient.getattr(commandArgs[1]);

            } else if (commandArgs[0].equals("mkdir")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length != 2) {
                    System.out.println("usage: mkdir <path>");
                    continue;
                }
                nfsClient.mkdir(commandArgs[1]);
            } else if (commandArgs[0].equals("read")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length < 2 || commandArgs.length > 3) {
                    System.out.println("usage: read <file> [-nopnfs]");
                    continue;
                }
                boolean usePNFS = commandArgs.length == 2 || !commandArgs[2].equals("-nopnfs");
                nfsClient.read(commandArgs[1], usePNFS);

            } else if (commandArgs[0].equals("readatonce")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length != 2) {
                    System.out.println("usage: readatonce <file>");
                    continue;
                }
                nfsClient.readatonce(commandArgs[1]);

            } else if (commandArgs[0].equals("read-nostate")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length != 2) {
                    System.out.println("usage: read-nostate <file>");
                    continue;
                }
                nfsClient.readNoState(commandArgs[1]);

            } else if (commandArgs[0].equals("fs_locations")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length != 2) {
                    System.out.println("usage: fs_locations <file>");
                    continue;
                }

                nfsClient.get_fs_locations(commandArgs[1]);

            } else if (commandArgs[0].equals("remove")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length != 2) {
                    System.out.println("usage: remove <file>");
                    continue;
                }
                nfsClient.remove(commandArgs[1]);

            } else if (commandArgs[0].equals("write")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length < 3 || commandArgs.length > 4) {
                    System.out.println("usage: write <src> <dest> [-nopnfs]");
                    continue;
                }
                boolean usePNFS = commandArgs.length == 3 || !commandArgs[3].equals("-nopnfs");
                nfsClient.write(commandArgs[1], commandArgs[2], usePNFS);

            } else if (commandArgs[0].equals("filebomb")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length != 2) {
                    System.out.println("usage: filebomb <num>");
                    continue;
                }
                nfsClient.filebomb(Integer.parseInt(commandArgs[1]));

            } else if (commandArgs[0].equals("openbomb")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                if (commandArgs.length != 3) {
                    System.out.println("usage: openbomb <file> <count>");
                    continue;
                }
                nfsClient.openbomb(commandArgs[1], Integer.parseInt(commandArgs[2]));

            } else if (commandArgs[0].equals("gc")) {

                if (nfsClient == null) {
                    System.out.println("Not mounted");
                    continue;
                }

                nfsClient.gc();

            } else if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit")) {

                if (nfsClient != null) {
                    nfsClient.destroy_session();
                    nfsClient.destroy_clientid();
                }
                System.exit(0);
            } else {
                out.println("Supported commands: ");
                for (String command : commands) {
                    out.println("    " + command);
                }
            }
            out.flush();
        } catch (ChimeraNFSException e) {
            out.printf("%s failed: %s(%d) \n", commandArgs[0], nfsstat.toString(e.getStatus()), e.getStatus());
        }
    }
}

From source file:alluxio.examples.Performance.java

/**
 * Runs the performance test.// www .j  a  v a  2 s  .  c  o  m
 *
 * Usage:
 * {@code java -cp <ALLUXIO-VERSION> alluxio.examples.Performance <MasterIp> <FileNamePrefix>
 * <WriteBlockSizeInBytes> <BlocksPerFile> <DebugMode:true/false> <Threads> <FilesPerThread>
 * <TestCaseNumber> <BaseFileNumber>}
 *
 * @param args the arguments for this example
 * @throws Exception if the example fails
 */
public static void main(String[] args) throws Exception {
    if (args.length != 9) {
        System.out.println("java -cp " + RuntimeConstants.ALLUXIO_JAR + " alluxio.examples.Performance "
                + "<MasterIp> <FileNamePrefix> <WriteBlockSizeInBytes> <BlocksPerFile> "
                + "<DebugMode:true/false> <Threads> <FilesPerThread> <TestCaseNumber> " + "<BaseFileNumber>\n"
                + "1: Files Write Test\n" + "2: Files Read Test\n" + "3: RamFile Write Test \n"
                + "4: RamFile Read Test \n" + "5: ByteBuffer Write Test \n" + "6: ByteBuffer Read Test \n");
        System.exit(-1);
    }

    HostAndPort masterAddress = HostAndPort.fromString(args[0]);
    sFileName = args[1];
    sBlockSizeBytes = Integer.parseInt(args[2]);
    sBlocksPerFile = Long.parseLong(args[3]);
    sDebugMode = ("true".equals(args[4]));
    sThreads = Integer.parseInt(args[5]);
    sFiles = Integer.parseInt(args[6]) * sThreads;
    final int testCase = Integer.parseInt(args[7]);
    sBaseFileNumber = Integer.parseInt(args[8]);

    sFileBytes = sBlocksPerFile * sBlockSizeBytes;
    sFilesBytes = sFileBytes * sFiles;

    long fileBufferBytes = Configuration.getBytes(PropertyKey.USER_FILE_BUFFER_BYTES);
    sResultPrefix = String.format(
            "Threads %d FilesPerThread %d TotalFiles %d "
                    + "BLOCK_SIZE_KB %d BLOCKS_PER_FILE %d FILE_SIZE_MB %d "
                    + "Alluxio_WRITE_BUFFER_SIZE_KB %d BaseFileNumber %d : ",
            sThreads, sFiles / sThreads, sFiles, sBlockSizeBytes / 1024, sBlocksPerFile,
            sFileBytes / Constants.MB, fileBufferBytes / 1024, sBaseFileNumber);

    CommonUtils.warmUpLoop();

    Configuration.set(PropertyKey.MASTER_HOSTNAME, masterAddress.getHostText());
    Configuration.set(PropertyKey.MASTER_RPC_PORT, Integer.toString(masterAddress.getPort()));

    if (testCase == 1) {
        sResultPrefix = "AlluxioFilesWriteTest " + sResultPrefix;
        LOG.info(sResultPrefix);
        sFileSystem = FileSystem.Factory.get();
        AlluxioTest(true /* write */);
    } else if (testCase == 2 || testCase == 9) {
        sResultPrefix = "AlluxioFilesReadTest " + sResultPrefix;
        LOG.info(sResultPrefix);
        sFileSystem = FileSystem.Factory.get();
        sAlluxioStreamingRead = (9 == testCase);
        AlluxioTest(false /* read */);
    } else if (testCase == 3) {
        sResultPrefix = "RamFile Write " + sResultPrefix;
        LOG.info(sResultPrefix);
        memoryCopyTest(true, false);
    } else if (testCase == 4) {
        sResultPrefix = "RamFile Read " + sResultPrefix;
        LOG.info(sResultPrefix);
        memoryCopyTest(false, false);
    } else if (testCase == 5) {
        sResultPrefix = "ByteBuffer Write Test " + sResultPrefix;
        LOG.info(sResultPrefix);
        memoryCopyTest(true, true);
    } else if (testCase == 6) {
        sResultPrefix = "ByteBuffer Read Test " + sResultPrefix;
        LOG.info(sResultPrefix);
        memoryCopyTest(false, true);
    } else if (testCase == 7) {
        sResultPrefix = "HdfsFilesWriteTest " + sResultPrefix;
        LOG.info(sResultPrefix);
        HdfsTest(true);
    } else if (testCase == 8) {
        sResultPrefix = "HdfsFilesReadTest " + sResultPrefix;
        LOG.info(sResultPrefix);
        HdfsTest(false);
    } else {
        throw new RuntimeException("No Test Case " + testCase);
    }

    for (int k = 0; k < RESULT_ARRAY_SIZE; k++) {
        System.out.print(sResults[k] + " ");
    }
    System.out.println();
    System.exit(0);
}

From source file:org.apache.hadoop.hbase.favored.StartcodeAgnosticServerName.java

public static StartcodeAgnosticServerName valueOf(final HostAndPort hostnameAndPort, long startcode) {
    return new StartcodeAgnosticServerName(hostnameAndPort.getHostText(), hostnameAndPort.getPort(), startcode);
}

From source file:org.apache.accumulo.core.rpc.TTimeoutTransport.java

public static TTransport create(HostAndPort addr, long timeoutMillis) throws IOException {
    return create(new InetSocketAddress(addr.getHostText(), addr.getPort()), timeoutMillis);
}

From source file:com.mgmtp.perfload.core.console.model.Daemon.java

public static Daemon fromHostAndPort(final int id, final HostAndPort hostAndPort) {
    String host = hostAndPort.getHostText();
    int port = hostAndPort.getPort();
    return new Daemon(id, host, port);
}

From source file:com.streamsets.pipeline.destination.aerospike.AerospikeBeanConfig.java

public static List<Host> getAerospikeHosts(List<Target.ConfigIssue> issues, List<String> connectionString,
        String configGroupName, String configName, Target.Context context) {
    List<Host> clusterNodesList = new ArrayList<>();
    if (connectionString == null || connectionString.isEmpty()) {
        issues.add(context.createConfigIssue(configGroupName, configName, AerospikeErrors.AEROSPIKE_01,
                configName));//w  ww . j a  v a  2  s . com
    } else {
        for (String node : connectionString) {
            try {
                HostAndPort hostAndPort = HostAndPort.fromString(node);
                if (!hostAndPort.hasPort() || hostAndPort.getPort() < 0) {
                    issues.add(context.createConfigIssue(configGroupName, configName,
                            AerospikeErrors.AEROSPIKE_02, connectionString));
                } else {
                    clusterNodesList.add(new Host(hostAndPort.getHostText(), hostAndPort.getPort()));
                }
            } catch (IllegalArgumentException e) {
                issues.add(context.createConfigIssue(configGroupName, configName, AerospikeErrors.AEROSPIKE_02,
                        connectionString));
            }
        }
    }
    return clusterNodesList;
}