Package com.google.common.net

Examples of com.google.common.net.HostAndPort


        if (portHint != 0 && i > 0)
          port = 1024 + random.nextInt(65535 - 1024);
        if (port > 65535)
          port = 1024 + port % (65535 - 1024);
        try {
          HostAndPort addr = HostAndPort.fromParts(address, port);
          return TServerUtils.startTServer(addr, timedProcessor, serverName, threadName, minThreads, timeBetweenThreadChecks, maxMessageSize,
              SslConnectionParams.forServer(conf), conf.getTimeInMillis(Property.GENERAL_RPC_TIMEOUT));
        } catch (TTransportException ex) {
          log.error("Unable to start TServer", ex);
          if (ex.getCause() == null || ex.getCause().getClass() == BindException.class) {
View Full Code Here


      hitRate.add(new Pair<Long,Double>(currentTime, null));
  }

  private static GCStatus fetchGcStatus() {
    GCStatus result = null;
    HostAndPort address = null;
    try {
      // Read the gc location from its lock
      ZooReaderWriter zk = ZooReaderWriter.getInstance();
      String path = ZooUtil.getRoot(instance) + Constants.ZGC_LOCK;
      List<String> locks = zk.getChildren(path, null);
View Full Code Here

  private HostAndPort startStatsService() throws UnknownHostException {
    Processor<Iface> processor = new Processor<Iface>(RpcWrapper.service(this));
    int port = config.getPort(Property.GC_PORT);
    long maxMessageSize = config.getMemoryInBytes(Property.GENERAL_MAX_MESSAGE_SIZE);
    HostAndPort result = HostAndPort.fromParts(opts.getAddress(), port);
    log.debug("Starting garbage collector listening on " + result);
    try {
      return TServerUtils.startTServer(result, processor, this.getClass().getSimpleName(), "GC Monitor Service", 2, 1000, maxMessageSize,
          SslConnectionParams.forServer(config), 0).address;
    } catch (Exception ex) {
View Full Code Here

   * Read the host and port information for the Monitor's log4j socket and update the system properties so that, on logger refresh, it sees the new information.
   */
  protected void updateMonitorLog4jLocation() {
    try {
      String hostPortString = new String(ZooReaderWriter.getInstance().getData(path, null), Constants.UTF8);
      HostAndPort hostAndPort = HostAndPort.fromString(hostPortString);

      System.setProperty(HOST_PROPERTY_NAME, hostAndPort.getHostText());
      System.setProperty(PORT_PROPERTY_NAME, Integer.toString(hostAndPort.getPort()));

      log.info("Changing monitor log4j address to " + hostAndPort.toString());

      doOnChange();
    } catch (NoNodeException e) {
      // Not sure on the synchronization guarantees for Loggers and Appenders
      // on configuration reload
View Full Code Here

          } catch (IOException ex) {
            log.error("Unable to delete wal " + path + ": " + ex);
          }
        }
      } else {
        HostAndPort address = AddressUtil.parseAddress(entry.getKey(), false);
        if (!holdsLock(address)) {
          for (Path path : entry.getValue()) {
            log.debug("Removing WAL for offline server " + path);
            try {
              if (!useTrash || !fs.moveToTrash(path))
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
         EC2Api ec2 = context.unwrapApi(EC2Api.class);
         Set<PublicIpInstanceIdPair> ipidpairs =
View Full Code Here

         }
      };

      OpenSocketFinder finder = new ConcurrentOpenSocketFinder(secondSocketOpen, nodeRunning, userExecutor);

      HostAndPort result = finder.findOpenSocketOnNode(node, 22, 2000, MILLISECONDS);
      assertEquals(result, HostAndPort.fromParts(PRIVATE_IP, 22));

   }
View Full Code Here

            HostAndPort.fromParts(PUBLIC_IP, 22), new SlowCallable<Boolean>(true, 1500),
            HostAndPort.fromParts(PRIVATE_IP, 22), new SlowCallable<Boolean>(true, 1000)));

      OpenSocketFinder finder = new ConcurrentOpenSocketFinder(socketTester, nodeRunning, userExecutor);

      HostAndPort result = finder.findOpenSocketOnNode(node, 22, 2000, MILLISECONDS);
      assertEquals(result, HostAndPort.fromParts(PRIVATE_IP, 22));
   }
View Full Code Here

      checkState(sshFactory != null, "ssh requested, but no SshModule configured");
      checkNotNull(node.getCredentials(), "no credentials found for node %s", node.getId());
      checkNotNull(node.getCredentials().identity, "no login identity found for node %s", node.getId());
      checkArgument(node.getCredentials().credential != null || sshFactory.isAgentAvailable(), "no credential or ssh agent found for %s on node %s", node
               .getCredentials().identity, node.getId());
      HostAndPort socket = openSocketFinder.findOpenSocketOnNode(node, node.getLoginPort(),
               timeoutMs, TimeUnit.MILLISECONDS);
      return sshFactory.create(socket, node.getCredentials());
   }
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

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.