Examples of pick()


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

    ServiceDiscovered serviceDiscovered = discoveryServiceClient.discover(String.format("service.%s.%s.%s",
                                                                                        accountId,
                                                                                        applicationId,
                                                                                        serviceName));
    EndpointStrategy endpointStrategy = new RandomEndpointStrategy(serviceDiscovered);
    Discoverable discoverable = endpointStrategy.pick();
    if (discoverable != null) {
      return createURL(discoverable, applicationId, serviceName);
    }

    final SynchronousQueue<URL> discoverableQueue = new SynchronousQueue<URL>();
View Full Code Here

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

    String service = cacheKey.getService();
    if (service.contains("$HOST")) {
      // Route URLs to host in the header.
      endpointStrategy = discoverService(cacheKey);

      if (endpointStrategy.pick() == null) {
        // Now try default, this matches any host / any port in the host header.
        endpointStrategy = discoverDefaultService(cacheKey);
      }
    } else {
      endpointStrategy = discover(service);
View Full Code Here

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

      }
    } else {
      endpointStrategy = discover(service);
    }

    if (endpointStrategy.pick() == null) {
      String message = String.format("No discoverable endpoints found for service %s", cacheKey);
      LOG.error(message);
      throw new Exception(message);
    }
View Full Code Here

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

    throws UnsupportedEncodingException, ExecutionException {
    // First try with path routing
    String lookupService = genLookupName(key.getService(), key.getHost(), key.getFirstPathPart());
    EndpointStrategy endpointStrategy = discover(lookupService);

    if (endpointStrategy.pick() == null) {
      // Try without path routing
      lookupService = genLookupName(key.getService(), key.getHost());
      endpointStrategy = discover(lookupService);
    }
View Full Code Here

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

    if (strategy == null) {
      throw  new HandlerException(HttpResponseStatus.SERVICE_UNAVAILABLE,
                                  String.format("No endpoint strategy found for request : %s",
                                  httpRequest.getUri()));
    }
    Discoverable discoverable = strategy.pick();
    if (discoverable == null) {
      throw  new HandlerException(HttpResponseStatus.SERVICE_UNAVAILABLE,
                                  String.format("No discoverable found for request : %s",
                                                httpRequest.getUri()));
    }
View Full Code Here

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

  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

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

    ServiceDiscovered serviceDiscovered = discoveryServiceClient.discover(String.format("service.%s.%s.%s",
                                                                                        getAccountId(),
                                                                                        applicationId,
                                                                                        serviceId));
    EndpointStrategy endpointStrategy = new RandomEndpointStrategy(serviceDiscovered);
    Discoverable discoverable = endpointStrategy.pick();
    if (discoverable != null) {
      return createURL(discoverable, applicationId, serviceId);
    }

    final SynchronousQueue<URL> discoverableQueue = new SynchronousQueue<URL>();
View Full Code Here

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

  }

  @Override
  protected InetSocketAddress getExploreServiceAddress() {
    EndpointStrategy endpointStrategy = this.endpointStrategySupplier.get();
    if (endpointStrategy == null || endpointStrategy.pick() == null) {
      String message = String.format("Cannot discover service %s", Service.EXPLORE_HTTP_USER_SERVICE);
      LOG.debug(message);
      throw new RuntimeException(message);
    }
View Full Code Here

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

      String message = String.format("Cannot discover service %s", Service.EXPLORE_HTTP_USER_SERVICE);
      LOG.debug(message);
      throw new RuntimeException(message);
    }

    return endpointStrategy.pick().getSocketAddress();
  }

  @Override
  protected String getAuthorizationToken() {
    return null;
View Full Code Here

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

    ServiceDiscovered serviceDiscovered = discoveryServiceClient.discover(String.format("service.%s.%s.%s",
                                                                                        accountId,
                                                                                        applicationId,
                                                                                        serviceName));
    EndpointStrategy endpointStrategy = new RandomEndpointStrategy(serviceDiscovered);
    Discoverable discoverable = endpointStrategy.pick();
    if (discoverable != null) {
      return createURL(discoverable, applicationId, serviceName);
    }

    final SynchronousQueue<URL> discoverableQueue = new SynchronousQueue<URL>();
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.