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

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

Introduction

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

Prototype

public static HostAndPort fromParts(String host, int port) 

Source Link

Document

Build a HostAndPort instance from separate host and port values.

Usage

From source file:ezbake.thriftrunner.starters.OpenShiftStarter.java

@Override
public HostAndPort getPrivateHostInfo() {
    return HostAndPort.fromParts(privateHostName, privatePort);
}

From source file:cloud.strategies.PasswordRemoteConnectionStrategy.java

@Override
public RemoteConnection apply(VirtualMachine virtualMachine) {

    checkArgument(virtualMachine.publicIpAddress().isPresent());
    checkArgument(virtualMachine.loginName().isPresent());
    checkArgument(virtualMachine.loginPassword().isPresent());
    int remotePort = virtualMachine.remotePortOrDefault();
    OSFamily osFamily = virtualMachine.operatingSystemVendorTypeOrDefault().osFamily();

    try {/* w  w  w .  j  a  v  a2  s .com*/
        return connectionService.getRemoteConnection(
                HostAndPort.fromParts(virtualMachine.publicIpAddress().get().getIp(), remotePort), osFamily,
                LoginCredentialBuilder.newBuilder().password(virtualMachine.loginPassword().get())
                        .username(virtualMachine.loginName().get()).build());
    } catch (RemoteException e) {
        throw new RemoteRuntimeException(e);
    }
}

From source file:dk.dma.ais.reader.AisReaders.java

public static AisTcpReader createReader(String hostname, int port) {
    AisTcpReader r = new AisTcpReader();
    r.addHostPort(HostAndPort.fromParts(hostname, port));
    return r;//w w  w .ja v a 2 s.c o  m
}

From source file:com.torodb.mongodb.repl.oplogreplier.fetcher.StaticOplogReader.java

public StaticOplogReader(SortedMap<OpTime, OplogOperation> oplog) {
    this(HostAndPort.fromParts("localhost", 27017), oplog);
}

From source file:net.myrrix.common.PartitionsUtils.java

/**
 * @param value describes all partitions, when partitioning across Serving Layers
 *  by user. Each partition may have multiple replicas. Serving Layers are specified as "host:port".
 *  Replicas are specified as many Serving Layers, separated by commas, like "rep1:port1,rep2:port2,...".
 *  Finally, partitions are specified as multiple replicas separated by semicolon, like
 *  "part1rep1:port11,part1rep2:port12;part2rep1:port21,part2rep2:port22;...". Example:
 *  "foo:80,foo2:8080;bar:8080;baz2:80,baz3:80"
 * @return {@link List} of partitions, where each partition is a {@link List} of replicas, where each
 *  replica is a host-port pair, as {@link HostAndPort}
 *//*from   ww w .j  a  v  a  2s  . c  o m*/
public static List<List<HostAndPort>> parseAllPartitions(CharSequence value) {
    if (value == null) {
        return null;
    }
    List<List<HostAndPort>> allPartitions = Lists.newArrayList();
    for (CharSequence partitionString : SEMICOLON.split(value)) {
        List<HostAndPort> partition = Lists.newArrayList();
        for (CharSequence replicaString : COMMA.split(partitionString)) {
            String[] hostPort = COLON.split(replicaString);
            String host = hostPort[0];
            int port = hostPort.length > 1 ? Integer.parseInt(hostPort[1]) : 80;
            Preconditions.checkArgument(port > 0, "port must be positive: %s", port);
            partition.add(HostAndPort.fromParts(host, port));
        }
        Preconditions.checkArgument(!partition.isEmpty(), "At least one partition must be specified");
        allPartitions.add(partition);
    }

    log(allPartitions);
    return allPartitions;
}

From source file:com.facebook.presto.connector.thrift.clientproviders.DefaultPrestoThriftServiceProvider.java

private PrestoThriftService connectTo(HostAddress host) {
    try {// w  w w  .j  av a 2  s.c  o m
        return thriftClient
                .open(new FramedClientConnector(HostAndPort.fromParts(host.getHostText(), host.getPort())))
                .get(thriftConnectTimeoutMs, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new RuntimeException("Interrupted while connecting to thrift host at " + host, e);
    } catch (ExecutionException | TimeoutException e) {
        throw new PrestoException(THRIFT_SERVICE_CONNECTION_ERROR, "Cannot connect to thrift host at " + host,
                e);
    }
}

From source file:com.groupon.mesos.executor.ExecutorDriverContext.java

ExecutorDriverContext(final String hostName, final UPID slaveUpid, final SlaveID slaveId,
        final FrameworkID frameworkId, final ExecutorID executorId) throws IOException {
    this.slaveUpid = slaveUpid;
    this.slaveId = slaveId;
    this.frameworkId = frameworkId;
    this.executorId = executorId;

    this.driverUpid = UPID.fromParts(UUID.randomUUID().toString(),
            HostAndPort.fromParts(hostName, NetworkUtil.findUnusedPort()));
}

From source file:com.torodb.mongodb.core.MongoDbCoreConfig.java

@SuppressWarnings("checkstyle:LineLength")
/**/*from  www . j  a v  a2 s .c  om*/
 * Like {@link #simpleConfig(com.torodb.torod.TorodBundle, com.torodb.mongodb.core.MongodServerConfig, com.torodb.core.modules.BundleConfig)
 * }, but focused on cores that will not be used as ToroDB Server and therefore provides a
 * default{@link MongodServerConfig}
 */
public static MongoDbCoreConfig simpleNonServerConfig(TorodBundle torodBundle, LoggerFactory lf,
        Optional<ToroMetricRegistry> metricRegistry, BundleConfig bundleConfig) {
    /*
     * The following config file is used by command implementations like isMaster to return
     * information about the server. That has no sense on Stampede and, in fact, that command is
     * never executed. Ideally, implementations like that one should be implemented on the ToroDB
     * Server layer, but right now almost all commands must be implemented on the mongodb core
     * layer, which means we need to provide a value even if it is not used.
     */
    MongodServerConfig mongodServerConfig = new MongodServerConfig(HostAndPort.fromParts("localhost", 27017));
    return simpleConfig(torodBundle, lf, mongodServerConfig, metricRegistry, bundleConfig);
}

From source file:ws.prager.camel.consul.ConsulRegistry.java

public ConsulRegistry(String hostname, int port) {
    super();//from   w w w. j a va  2s . c  o m
    this.hostname = hostname;
    this.port = port;
    logger.debug("get consul client for: " + hostname + ":" + port);
    HostAndPort hostAndPort = HostAndPort.fromParts(hostname, port);
    this.consul = Consul.builder().withHostAndPort(hostAndPort).build();
}

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

@Override
protected void configure() {
    binder().requireExplicitBindings();//from   w  w  w  .  j a v a 2  s. c o  m
    install(new PackagingModule(clock));
    install(new CoreModule());
    install(new ExecutorServicesModule());
    install(new ConcurrentModule());
    install(new MetainfModule());
    install(new MetricsModule(config.getGeneric()));

    install(new BackendMultiImplementationModule(config.getProtocol().getMongo(), config.getGeneric(),
            config.getBackend().getBackendImplementation(), new BackendPostgresImplementationModule(),
            new BackendDerbyImplementationModule()));

    bind(Config.class).toInstance(config);
    bind(MongodServerConfig.class)
            .toInstance(new MongodServerConfig(HostAndPort.fromParts("localhost", 27017)));
    bind(BuildProperties.class).to(DefaultBuildProperties.class).asEagerSingleton();
}