Examples of EndpointStrategy


Examples of co.cask.cdap.common.discovery.EndpointStrategy

  public URL getServiceURL() {
    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

  public void updateServiceMap(Map<Integer, String> serviceMap) {
    serviceMapRef.set(serviceMap);
  }

  private EndpointStrategy loadCache(CacheKey cacheKey) throws Exception {
    EndpointStrategy endpointStrategy;
    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);
    }

    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

  private EndpointStrategy discoverService(CacheKey key)
    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

  }

  private EndpointStrategy discover(String discoverName) throws ExecutionException {
    LOG.debug("Looking up service name {}", discoverName);

    EndpointStrategy endpointStrategy = new RandomEndpointStrategy(discoveryServiceClient.discover(discoverName));
    if (new TimeLimitEndpointStrategy(endpointStrategy, 300L, TimeUnit.MILLISECONDS).pick() == null) {
      LOG.debug("Discoverable endpoint {} not found", discoverName);
    }
    return endpointStrategy;
  }
View Full Code Here

Examples of co.cask.cdap.common.discovery.EndpointStrategy

    }
  }

  private WrappedDiscoverable getDiscoverable(final HttpRequest httpRequest,
                                              final InetSocketAddress address) {
    EndpointStrategy strategy = serviceLookup.getDiscoverable(address.getPort(), httpRequest);
    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

  @Override
  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

  public URL getServiceURL(final String applicationId, final String serviceId) {
    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

    });
  }

  @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);
    }

    return endpointStrategy.pick().getSocketAddress();
  }
View Full Code Here

Examples of com.eviware.soapui.model.project.EndpointStrategy

  public void filterRequest( SubmitContext context, Request wsdlRequest )
  {
    Operation operation = wsdlRequest.getOperation();
    if( operation != null )
    {
      EndpointStrategy endpointStrategy = operation.getInterface().getProject().getEndpointStrategy();
      if( endpointStrategy != null )
        endpointStrategy.filterRequest( context, wsdlRequest );
    }
  }
View Full Code Here

Examples of com.eviware.soapui.model.project.EndpointStrategy

    }
  }

  public void importEndpoints( Interface iface )
  {
    EndpointStrategy ep = iface.getProject().getEndpointStrategy();
    if( ep instanceof DefaultEndpointStrategy )
    {
      DefaultEndpointStrategy dep = ( DefaultEndpointStrategy )ep;
      String[] endpoints = iface.getEndpoints();
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.