use of com.linkedin.d2.balancer.strategies.LoadBalancerStrategy in project rest.li by linkedin.
the class SimpleLoadBalancerState method buildTrackerClient.
@Nullable
private TrackerClient buildTrackerClient(URI uri, UriProperties uriProperties, String serviceName, ServiceProperties serviceProperties) {
TransportClient transportClient = getTransportClient(serviceName, uri);
LoadBalancerStrategy loadBalancerStrategy = _serviceStrategies.get(serviceName).get(uri.getScheme().toLowerCase());
if (transportClient == null) {
return null;
}
if (loadBalancerStrategy == null) {
return null;
}
return serviceProperties == null ? null : TrackerClientFactory.createTrackerClient(uri, uriProperties, serviceProperties, loadBalancerStrategy.getName(), transportClient);
}
use of com.linkedin.d2.balancer.strategies.LoadBalancerStrategy in project rest.li by linkedin.
the class SimpleLoadBalancerState method createNewStrategies.
private Map<String, LoadBalancerStrategy> createNewStrategies(ServiceProperties serviceProperties) {
List<String> strategyList = serviceProperties.getLoadBalancerStrategyList();
LoadBalancerStrategyFactory<? extends LoadBalancerStrategy> factory = null;
if (strategyList != null && !strategyList.isEmpty()) {
for (String strategy : strategyList) {
factory = _loadBalancerStrategyFactories.get(strategy);
if (factory != null) {
break;
}
}
}
Map<String, LoadBalancerStrategy> newStrategies = new ConcurrentHashMap<>();
if (factory == null && strategyList != null && strategyList.size() == 1 && strategyList.contains(RelativeLoadBalancerStrategy.RELATIVE_LOAD_BALANCER_STRATEGY_NAME) && !_loadBalancerStrategyFactories.containsKey(RelativeLoadBalancerStrategy.RELATIVE_LOAD_BALANCER_STRATEGY_NAME)) {
factory = _loadBalancerStrategyFactories.get(DegraderLoadBalancerStrategyV3.DEGRADER_STRATEGY_NAME);
warn(_log, "unable to find cluster or factory for ", serviceProperties, ", defaulting to ", factory);
}
if (factory == null || serviceProperties.getPrioritizedSchemes() == null || serviceProperties.getPrioritizedSchemes().isEmpty()) {
warn(_log, "unable to find cluster or factory for ", serviceProperties, ": ", factory);
} else {
List<String> schemes = serviceProperties.getPrioritizedSchemes();
for (String scheme : schemes) {
LoadBalancerStrategy strategy = factory.newLoadBalancer(serviceProperties);
newStrategies.put(scheme, strategy);
}
}
info(_log, "putting strategies ", serviceProperties.getServiceName(), ": ", newStrategies);
return newStrategies;
}
Aggregations