List of usage examples for com.google.common.net HostAndPort getHostText
public String getHostText()
From source file:org.apache.brooklyn.entity.nosql.solr.SolrServerImpl.java
@Override protected void connectSensors() { super.connectSensors(); HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, getSolrPort()); String solrUri = String.format("http://%s:%d/solr", hp.getHostText(), hp.getPort()); sensors().set(Attributes.MAIN_URI, URI.create(solrUri)); httpFeed = HttpFeed.builder().entity(this).period(500, TimeUnit.MILLISECONDS).baseUri(solrUri) .poll(new HttpPollConfig<Boolean>(SERVICE_UP).onSuccess(HttpValueFunctions.responseCodeEquals(200)) .onFailureOrException(Functions.constant(false))) .build();/*from w ww.j av a 2s.c o m*/ }
From source file:de.uniulm.omi.cloudiator.sword.base.BaseConnectionService.java
@Override public RemoteConnection getRemoteConnection(HostAndPort hostAndPort, RemoteType remoteType, LoginCredential loginCredential) throws RemoteException { return this.remoteConnectionFactory.createRemoteConnection(hostAndPort.getHostText(), remoteType, loginCredential, hostAndPort.getPort()); }
From source file:org.mayocat.shop.application.MayocatShopService.java
@Override public void run(MayocatShopSettings configuration, Environment environment) throws Exception { super.run(configuration, environment); if (configuration.getDevelopmentEnvironment().isEnabled()) { HostAndPort hp = HostAndPort.fromString(configuration.getSiteSettings().getDomainName()); swaggerDropwizard.onRun(configuration, environment, hp.getHostText(), hp.getPort()); }//from ww w . ja va 2s .co m }
From source file:com.facebook.presto.hive.DiscoveryLocatedHiveCluster.java
@Override public HiveMetastoreClient createMetastoreClient() { List<ServiceDescriptor> descriptors = selector.selectAllServices().stream() .filter(input -> input.getState() != ServiceState.STOPPED).collect(toList()); if (descriptors.isEmpty()) { throw new DiscoveryException("No metastore servers available for pool: " + selector.getPool()); }/*from w ww . j ava 2s . c o m*/ Collections.shuffle(descriptors); TTransportException lastException = null; for (ServiceDescriptor descriptor : descriptors) { String thrift = descriptor.getProperties().get("thrift"); if (thrift != null) { try { HostAndPort metastore = HostAndPort.fromString(thrift); checkArgument(metastore.hasPort()); return clientFactory.create(metastore.getHostText(), metastore.getPort()); } catch (IllegalArgumentException ignored) { // Ignore entries with parse issues } catch (TTransportException e) { lastException = e; } } } throw new DiscoveryException("Unable to connect to any metastore servers in pool: " + selector.getPool(), lastException); }
From source file:com.splicemachine.stream.RemoteQueryClientImpl.java
@Override public void submit() throws StandardException { Activation activation = root.getActivation(); ActivationHolder ah = new ActivationHolder(activation, root); try {//from ww w . j a va 2s . c om updateLimitOffset(); int streamingBatches = HConfiguration.getConfiguration().getSparkResultStreamingBatches(); int streamingBatchSize = HConfiguration.getConfiguration().getSparkResultStreamingBatchSize(); streamListener = new StreamListener(limit, offset, streamingBatches, streamingBatchSize); StreamListenerServer server = getServer(); server.register(streamListener); HostAndPort hostAndPort = server.getHostAndPort(); String host = hostAndPort.getHostText(); int port = hostAndPort.getPort(); UUID uuid = streamListener.getUuid(); String sql = activation.getPreparedStatement().getSource(); sql = sql == null ? root.toString() : sql; String userId = activation.getLanguageConnectionContext().getCurrentUserId(activation); RemoteQueryJob jobRequest = new RemoteQueryJob(ah, root.getResultSetNumber(), uuid, host, port, userId, sql, streamingBatches, streamingBatchSize); olapFuture = EngineDriver.driver().getOlapClient().submit(jobRequest); olapFuture.addListener(new Runnable() { @Override public void run() { try { OlapResult olapResult = olapFuture.get(); streamListener.completed(olapResult); } catch (ExecutionException e) { LOG.warn("Execution failed", e); streamListener.failed(e.getCause()); } catch (InterruptedException e) { // this shouldn't happen, the olapFuture already completed Thread.currentThread().interrupt(); LOG.error("Unexpected exception, shouldn't happen", e); streamListener.failed(e); } } }, MoreExecutors.sameThreadExecutor()); } catch (IOException e) { throw Exceptions.parseException(e); } }
From source file:brooklyn.entity.webapp.nodejs.NodeJsWebAppServiceImpl.java
@Override protected void connectSensors() { super.connectSensors(); ConfigToAttributes.apply(this); HostAndPort accessible = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, getHttpPort()); String nodeJsUrl = String.format("http://%s:%d", accessible.getHostText(), accessible.getPort()); LOG.info("Connecting to {}", nodeJsUrl); httpFeed = HttpFeed.builder().entity(this).baseUri(nodeJsUrl) .poll(new HttpPollConfig<Boolean>(SERVICE_UP).suburl(getConfig(NodeJsWebAppService.SERVICE_UP_PATH)) .checkSuccess(Predicates.alwaysTrue()).onSuccess(HttpValueFunctions.responseCodeEquals(200)) .setOnException(false)) .build();//from ww w .ja va 2 s. c o m WebAppServiceMethods.connectWebAppServerPolicies(this); }
From source file:org.apache.brooklyn.entity.nosql.mongodb.sharding.MongoDBConfigServerClusterImpl.java
@Override public void start(Collection<? extends Location> locs) { super.start(locs); // TODO this should be an enricher Iterable<String> memberHostNamesAndPorts = Iterables.transform(getMembers(), new Function<Entity, String>() { @Override//from w w w . j a v a 2 s. co m public String apply(Entity entity) { HostAndPort hostAndPort = BrooklynAccessUtils.getBrooklynAccessibleAddress(entity, entity.getAttribute(MongoDBConfigServer.PORT)); return hostAndPort.getHostText() + ":" + hostAndPort.getPort(); } }); sensors().set(MongoDBConfigServerCluster.CONFIG_SERVER_ADDRESSES, ImmutableList.copyOf(memberHostNamesAndPorts)); }
From source file:org.graylog.plugins.metrics.mongodb.providers.MongoDBReporterProvider.java
private ServerAddress[] extractServerAddresses(MongoClientURI mongoClientURI) { final List<String> hosts = mongoClientURI.getHosts(); final List<ServerAddress> serverAddresses = new ArrayList<>(hosts.size()); for (String host : hosts) { final HostAndPort hostAndPort = HostAndPort.fromString(host) .withDefaultPort(ServerAddress.defaultPort()); final ServerAddress serverAddress = new ServerAddress(hostAndPort.getHostText(), hostAndPort.getPort()); serverAddresses.add(serverAddress); }/*from ww w. j a v a 2 s. com*/ return serverAddresses.toArray(new ServerAddress[serverAddresses.size()]); }
From source file:alluxio.wire.FileBlockInfo.java
/** * @return thrift representation of the file block information *///from w ww .ja va 2 s .co m protected alluxio.thrift.FileBlockInfo toThrift() { List<alluxio.thrift.WorkerNetAddress> ufsLocations = new ArrayList<>(); for (String ufsLocation : mUfsLocations) { HostAndPort address = HostAndPort.fromString(ufsLocation); ufsLocations.add(new alluxio.thrift.WorkerNetAddress().setHost(address.getHostText()) .setDataPort(address.getPortOrDefault(-1))); } return new alluxio.thrift.FileBlockInfo(mBlockInfo.toThrift(), mOffset, ufsLocations, mUfsLocations); }
From source file:com.spotify.helios.testing.DockerHost.java
private DockerHost(final String endpoint, final String dockerCertPath) { if (endpoint.startsWith("unix://")) { this.port = 0; this.address = DEFAULT_HOST; this.host = endpoint; this.uri = URI.create(endpoint); this.bindURI = URI.create(endpoint); } else {// www .j a v a 2 s.co m final String stripped = endpoint.replaceAll(".*://", ""); final HostAndPort hostAndPort = HostAndPort.fromString(stripped); final String hostText = hostAndPort.getHostText(); final String scheme = isNullOrEmpty(dockerCertPath) ? "http" : "https"; this.port = hostAndPort.getPortOrDefault(defaultPort()); this.address = isNullOrEmpty(hostText) ? DEFAULT_HOST : hostText; this.host = address + ":" + port; this.uri = URI.create(scheme + "://" + address + ":" + port); this.bindURI = URI.create("tcp://" + address + ":" + port); } this.dockerCertPath = dockerCertPath; }