Search in sources :

Example 1 with UserServiceEndpointStrategy

use of co.cask.cdap.gateway.discovery.UserServiceEndpointStrategy in project cdap by caskdata.

the class RouterServiceLookup method discover.

private EndpointStrategy discover(RouteDestination routeDestination) throws ExecutionException {
    LOG.debug("Looking up service name {}", routeDestination);
    // If its a user service, then use DistributionEndpoint Strategy
    String serviceName = routeDestination.getServiceName();
    ServiceDiscovered serviceDiscovered = discoveryServiceClient.discover(serviceName);
    EndpointStrategy endpointStrategy = ServiceDiscoverable.isServiceDiscoverable(serviceName) ? new UserServiceEndpointStrategy(serviceDiscovered, routeStore, ServiceDiscoverable.getId(serviceName), fallbackStrategy, routeDestination.getVersion()) : new RandomEndpointStrategy(serviceDiscovered);
    if (endpointStrategy.pick(300L, TimeUnit.MILLISECONDS) == null) {
        LOG.debug("Discoverable endpoint {} not found", routeDestination);
    }
    return endpointStrategy;
}
Also used : UserServiceEndpointStrategy(co.cask.cdap.gateway.discovery.UserServiceEndpointStrategy) UserServiceEndpointStrategy(co.cask.cdap.gateway.discovery.UserServiceEndpointStrategy) EndpointStrategy(co.cask.cdap.common.discovery.EndpointStrategy) RandomEndpointStrategy(co.cask.cdap.common.discovery.RandomEndpointStrategy) ServiceDiscovered(org.apache.twill.discovery.ServiceDiscovered) RandomEndpointStrategy(co.cask.cdap.common.discovery.RandomEndpointStrategy)

Aggregations

EndpointStrategy (co.cask.cdap.common.discovery.EndpointStrategy)1 RandomEndpointStrategy (co.cask.cdap.common.discovery.RandomEndpointStrategy)1 UserServiceEndpointStrategy (co.cask.cdap.gateway.discovery.UserServiceEndpointStrategy)1 ServiceDiscovered (org.apache.twill.discovery.ServiceDiscovered)1