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;
}
Aggregations