Package com.google.common.net

Examples of com.google.common.net.HostAndPort


        }

        final List<ServerAddress> replicaServers = new ArrayList<>(mongoReplicaSet.size());
        for (String host : mongoReplicaSet) {
            try {
                final HostAndPort hostAndPort = HostAndPort.fromString(host)
                        .withDefaultPort(27017);
                replicaServers.add(new ServerAddress(
                        InetAddress.getByName(hostAndPort.getHostText()), hostAndPort.getPort()));
            } catch (IllegalArgumentException e) {
                LOG.error("Malformed mongodb_replica_set configuration.", e);
                return null;
            } catch (UnknownHostException e) {
                LOG.error("Unknown host in mongodb_replica_set", e);
View Full Code Here


                    final Iterable<String> hostList = Splitter.on(',').omitEmptyStrings().trimResults().split(hosts);

                    // if no elasticsearch running
                    for (String host : hostList) {
                        // guess that Elasticsearch http is listening on port 9200
                        final HostAndPort hostAndPort = HostAndPort.fromString(host);
                        LOG.info("Checking Elasticsearch HTTP API at http://{}:9200/", hostAndPort.getHostText());

                        try {
                            // Try the HTTP API endpoint
                            final ListenableFuture<Response> future = httpClient.prepareGet("http://" + hostAndPort.getHostText() + ":9200/_nodes").execute();
                            final Response response = future.get();

                            final JsonNode resultTree = new ObjectMapper().readTree(response.getResponseBody());
                            final String clusterName = resultTree.get("cluster_name").textValue();
                            final JsonNode nodesList = resultTree.get("nodes");

                            final Iterator<String> nodes = nodesList.fieldNames();
                            while (nodes.hasNext()) {
                                final String id = nodes.next();
                                final Version clusterVersion = Version.fromString(nodesList.get(id).get("version").textValue());

                                if (!configuration.isEsDisableVersionCheck()) {
                                    checkClusterVersion(clusterVersion);
                                }
                            }

                            checkClusterName(clusterName);
                        } catch (IOException ioException) {
                            LOG.error("Could not connect to Elasticsearch.", ioException);
                        } catch (InterruptedException ignore) {
                        } catch (ExecutionException e1) {
                            // could not find any server on that address
                            LOG.error("Could not connect to Elasticsearch at http://" + hostAndPort.getHostText() + ":9200/, is it running?",
                                    e1.getCause());
                        }
                    }
                }
View Full Code Here

                       AccumuloKeys.MASTER_ADDRESS), null);
   
    String monitorKey = "Active Accumulo Monitor: ";
    String monitorAddr = getInfoAvoidingNull(clusterDesc, AccumuloKeys.MONITOR_ADDRESS);
    if (!StringUtils.isBlank(monitorAddr)) {
        HostAndPort hostPort = HostAndPort.fromString(monitorAddr);
        details.put(monitorKey,
            String.format("http://%s:%d", hostPort.getHostText(), hostPort.getPort()));
    } else {
      details.put(monitorKey + "N/A", null);
    }

    return details;
View Full Code Here

      if (vm.getPassword() != null && loginCredentials.getOptionalPassword() == null)
         loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build();
      assert HostSpecifier.isValid(vm.getIPAddress());
      if (!InetAddresses2.isPrivateIPAddress(vm.getIPAddress())) {
         // not sure if the network is public or not, so we have to test
         HostAndPort socket = HostAndPort.fromParts(vm.getIPAddress(), 22);
         System.err.printf("testing socket %s%n", socket);
         System.err.printf("testing ssh %s%n", socket);
         checkSSH(socket);
      } else {
         System.err.printf("skipping ssh %s, as private%n", vm.getIPAddress());
View Full Code Here

      assertEquals(server.getStatus(), ServerStatus.ACTIVE);
   }

   @Test(dependsOnMethods = "testCreateAndStartServer")
   public void testConnectivity() throws Exception {
      HostAndPort vncsocket = HostAndPort.fromParts(server.getVnc().getIp(), 5900);
      Logger.getAnonymousLogger().info("awaiting vnc: " + vncsocket);
      assert socketTester.apply(vncsocket) : server;
      HostAndPort sshsocket = HostAndPort.fromParts(server.getNics().get(0).getDhcp(), 22);
      Logger.getAnonymousLogger().info("awaiting ssh: " + sshsocket);
      assert socketTester.apply(sshsocket) : server;
      doConnectViaSsh(server, getSshCredentials(server));
   }
View Full Code Here

         assertEquals(Iterables.size(publicIps), 1);

         // Check that the address is public and port 22 is accessible
         String ip = Iterables.getOnlyElement(publicIps);
         assertFalse(InetAddresses2.isPrivateIPAddress(ip));
         HostAndPort socket = HostAndPort.fromParts(ip, 22);
         assertTrue(socketTester.apply(socket), String.format("failed to open socket %s on node %s", socket, node));

         // check that there is an elastic ip correlating to it
         EC2Client ec2 = EC2Client.class.cast(context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi());
         Set<PublicIpInstanceIdPair> ipidpairs =
View Full Code Here

   }

   @Test(dependsOnMethods = "testCreateMachine")
   protected void testSsh() {
      String publicAddress = Iterables.find(machine.getIps(), not(InetAddresses2.IsPrivateIPAddress.INSTANCE));
      HostAndPort socket = HostAndPort.fromParts(publicAddress, 22);
      assertTrue(socketTester.apply(socket), socket.toString());
      SshClient api = context.utils().injector().getInstance(SshClient.Factory.class)
            .create(socket, LoginCredentials.builder().user("root").privateKey(key.get("private")).build());
      try {
         api.connect();
         ExecResponse exec = api.exec("echo hello");
View Full Code Here

        return new Message(topicPartition.getTopic(), topicPartition.getPartition(),
                messageAndOffset.offset(), payloadBytes);
    }

   public SimpleConsumer createConsumer(TopicPartition topicPartition) {
        HostAndPort leader = findLeader(topicPartition);
        LOG.info("leader for topic " + topicPartition.getTopic() + " partition " +
                 topicPartition.getPartition() + " is " + leader.toString());
        final String clientName = getClientName(topicPartition);
        return new SimpleConsumer(leader.getHostText(), leader.getPort(), 100000, 64 * 1024,
                                  clientName);
    }
View Full Code Here

  private HostAndPort startTabletClientService() throws UnknownHostException {
    // start listening for client connection last
    Iface tch = RpcWrapper.service(new ThriftClientHandler());
    Processor<Iface> processor = new Processor<Iface>(tch);
    HostAndPort address = startServer(getSystemConfiguration(), clientAddress.getHostText(), Property.TSERV_CLIENTPORT, processor, "Thrift Client Server");
    log.info("address = " + address);
    return address;
  }
View Full Code Here

    double currentMajorAvg = 0;
    double currentMinorStdDev = 0;
    double currentMajorStdDev = 0;
    TabletStats total = new TabletStats(null, new ActionStats(), new ActionStats(), new ActionStats(), 0, 0, 0, 0);
   
    HostAndPort address = HostAndPort.fromString(tserverAddress);
    TabletStats historical = new TabletStats(null, new ActionStats(), new ActionStats(), new ActionStats(), 0, 0, 0, 0);
    List<TabletStats> tsStats = new ArrayList<TabletStats>();
    try {
      TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, Monitor.getSystemConfiguration());
      try {
View Full Code Here

TOP

Related Classes of com.google.common.net.HostAndPort

Copyright © 2018 www.massapicom. 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.