use of com.alipay.sofa.rpc.client.LoadBalancer in project sofa-rpc by sofastack.
the class AutoLoadBalancer method doSelect.
@Override
protected ProviderInfo doSelect(SofaRequest request, List<ProviderInfo> providerInfos) {
// 动态配置优先
final String dynamicAlias = consumerConfig.getParameter(DynamicConfigKeys.DYNAMIC_ALIAS);
if (StringUtils.isNotBlank(dynamicAlias)) {
String dynamicLoadBalancer = null;
DynamicConfigManager dynamicConfigManager = DynamicConfigManagerFactory.getDynamicManager(consumerConfig.getAppName(), dynamicAlias);
if (dynamicConfigManager != null) {
dynamicLoadBalancer = dynamicConfigManager.getConsumerServiceProperty(request.getTargetServiceUniqueName(), LOAD_BALANCER_KEY);
if (DynamicHelper.isNotDefault(dynamicLoadBalancer) && StringUtils.isNotBlank(dynamicLoadBalancer)) {
LoadBalancer loadBalancer = LoadBalancerFactory.getLoadBalancer(consumerBootstrap, dynamicLoadBalancer);
return loadBalancer.select(request, providerInfos);
}
}
}
LoadBalancer loadBalancer = LoadBalancerFactory.getLoadBalancer(consumerBootstrap, DEFAULT_LOAD_BALANCER);
return loadBalancer.select(request, providerInfos);
}
Aggregations