Package co.cask.cdap.common.discovery

Examples of co.cask.cdap.common.discovery.TimeLimitEndpointStrategy.pick()


      @Override
      public URI get() {
        Iterable<Discoverable> serviceDiscovered = discoveryServiceClient.discover(Constants.Service.ACL);
        TimeLimitEndpointStrategy strategy = new TimeLimitEndpointStrategy(
          new RandomEndpointStrategy(serviceDiscovered), 5, TimeUnit.SECONDS);
        Preconditions.checkNotNull(strategy.pick(), "No discoverable endpoint found for ACLService");

        InetSocketAddress socketAddress = strategy.pick().getSocketAddress();
        try {
          // TODO: support https by checking router ssl enabled from Configuration
          String url = String.format("http://%s:%d", socketAddress.getAddress().getHostName(), socketAddress.getPort());
View Full Code Here


        Iterable<Discoverable> serviceDiscovered = discoveryServiceClient.discover(Constants.Service.ACL);
        TimeLimitEndpointStrategy strategy = new TimeLimitEndpointStrategy(
          new RandomEndpointStrategy(serviceDiscovered), 5, TimeUnit.SECONDS);
        Preconditions.checkNotNull(strategy.pick(), "No discoverable endpoint found for ACLService");

        InetSocketAddress socketAddress = strategy.pick().getSocketAddress();
        try {
          // TODO: support https by checking router ssl enabled from Configuration
          String url = String.format("http://%s:%d", socketAddress.getAddress().getHostName(), socketAddress.getPort());
          return new URI(url);
        } catch (URISyntaxException e) {
View Full Code Here

  public boolean isServiceAvailable() {
    try {
      Iterable<Discoverable> discoverables = this.discoveryServiceClient.discover(serviceName);
      EndpointStrategy endpointStrategy = new TimeLimitEndpointStrategy(
        new RandomEndpointStrategy(discoverables), discoveryTimeout, TimeUnit.SECONDS);
      Discoverable discoverable = endpointStrategy.pick();
      if (discoverable == null) {
        return false;
      }

      return txClient.status().equals(Constants.Monitor.STATUS_OK);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.