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:org.kududb.util.NetUtil.java

/**
 * Parse a "host:port" pair into a {@link HostAndPort} object. If there is no
 * port specified in the string, then 'defaultPort' is used.
 *
 * @param addrString  A host or a "host:port" pair.
 * @param defaultPort Default port to use if no port is specified in addrString.
 * @return The HostAndPort object constructed from addrString.
 *///from   w  ww .  j  a v  a 2 s.c o  m
public static HostAndPort parseString(String addrString, int defaultPort) {
    return addrString.indexOf(':') == -1 ? HostAndPort.fromParts(addrString, defaultPort)
            : HostAndPort.fromString(addrString);
}

From source file:org.jclouds.examples.minecraft.Utils.java

public static Function<NodeMetadata, HostAndPort> firstPublicAddressToHostAndPort(final int port) {
    return new Function<NodeMetadata, HostAndPort>() {

        @Override/*from ww  w.  j  av a2s . co m*/
        public HostAndPort apply(NodeMetadata input) {
            return HostAndPort.fromParts(get(input.getPublicAddresses(), 0), port);
        }

        @Override
        public String toString() {
            return "firstPublicAddressToHostAndPort(" + port + ")";
        }

    };
}

From source file:io.mandrel.cluster.discovery.ServiceInstance.java

public HostAndPort getHostAndPort() {
    return HostAndPort.fromParts(this.getHost(), this.getPort());
}

From source file:com.groupon.mesos.util.UPID.java

public static UPID create(final String master) {
    checkNotNull(master, "master is null");
    final List<String> parts = ImmutableList
            .copyOf(Splitter.on(CharMatcher.anyOf(":@")).limit(3).split(master));
    checkState(parts.size() == 3, "%s is not a valid master definition", master);

    Integer ip = null;//  w w w .  j  a v a2  s . com
    try {
        ip = resolveIp(parts.get(1));
    } catch (final IOException e) {
        LOG.warn("Could not resolve %s: %s", parts.get(1), e.getMessage());
    }

    return new UPID(parts.get(0), HostAndPort.fromParts(parts.get(1), Integer.parseInt(parts.get(2))), ip);
}

From source file:com.facebook.swift.service.async.DelayedMapAsyncProxyHandler.java

public DelayedMapAsyncProxyHandler(ThriftClientManager clientManager, ThriftServer targetServer)
        throws ExecutionException, InterruptedException {
    FramedClientConnector connector = new FramedClientConnector(
            HostAndPort.fromParts("localhost", targetServer.getPort()));
    asyncClient = clientManager.createClient(connector, DelayedMap.AsyncClient.class).get();
}

From source file:com.facebook.swift.perf.loadgenerator.AbstractClientWorker.java

public AbstractClientWorker(ThriftClientManager clientManager, LoadGeneratorCommandLineConfig config) {
    this.clientManager = clientManager;
    this.config = config;
    this.serverHostAndPort = HostAndPort.fromParts(config.serverAddress, config.serverPort);
}

From source file:org.excalibur.client.jcommander.converters.HostAndPortConverter.java

@Override
public HostAndPort convert(String value) {
    if (!isNullOrEmpty(value)) {
        String[] parts = value.split(":");
        return HostAndPort.fromParts(parts[0],
                parts.length == 1 ? DEFAULT_HOST.getPort() : Integer.parseInt(parts[1]));
    }//from w  w  w  . j a va  2 s . c  o m

    return DEFAULT_HOST;
}

From source file:com.torodb.packaging.guice.FakeMongoServerModule.java

@Provides
public MongodServerConfig createMongodServerConfig() {
    return new MongodServerConfig(HostAndPort.fromParts("localhost", 27017));
}

From source file:com.streamsets.pipeline.kafka.impl.Kafka08LowLevelConsumerFactory.java

@Override
public SdcKafkaLowLevelConsumer create() {
    return new KafkaLowLevelConsumer08(settings.getTopic(), settings.getPartition(),
            HostAndPort.fromParts(settings.getBrokerHost(), settings.getBrokerPort()),
            settings.getMinFetchSize(), settings.getMaxFetchSize(), settings.getMaxWaitTime(),
            settings.getClientName());/*from w  w w.  j ava  2s.co m*/
}

From source file:com.streamsets.pipeline.kafka.impl.Kafka09LowLevelConsumerFactory.java

@Override
public SdcKafkaLowLevelConsumer create() {
    return new KafkaLowLevelConsumer09(settings.getTopic(), settings.getPartition(),
            HostAndPort.fromParts(settings.getBrokerHost(), settings.getBrokerPort()),
            settings.getMinFetchSize(), settings.getMaxFetchSize(), settings.getMaxWaitTime(),
            settings.getClientName());/*w ww  . j  a  va 2  s.  c om*/
}