|
|
@ -36,10 +36,13 @@ public class NacosRule extends AbstractLoadBalancerRule {
|
|
|
|
String name = loadBalancer.getName();
|
|
|
|
String name = loadBalancer.getName();
|
|
|
|
|
|
|
|
|
|
|
|
NamingService namingService = this.nacosDiscoveryProperties.namingServiceInstance();
|
|
|
|
NamingService namingService = this.nacosDiscoveryProperties.namingServiceInstance();
|
|
|
|
|
|
|
|
|
|
|
|
List<Instance> instances = namingService.selectInstances(name, true);
|
|
|
|
List<Instance> instances = namingService.selectInstances(name, true);
|
|
|
|
List<Instance> instancesToChoose = instances;
|
|
|
|
if (CollectionUtils.isEmpty(instances)) {
|
|
|
|
|
|
|
|
log.warn("{}服务当前无任何实例", name);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Instance> instancesToChoose = instances;
|
|
|
|
if (StringUtils.isNotBlank(clusterName)) {
|
|
|
|
if (StringUtils.isNotBlank(clusterName)) {
|
|
|
|
List<Instance> sameClusterInstances = instances.stream()
|
|
|
|
List<Instance> sameClusterInstances = instances.stream()
|
|
|
|
.filter(instance -> Objects.equals(clusterName, instance.getClusterName()))
|
|
|
|
.filter(instance -> Objects.equals(clusterName, instance.getClusterName()))
|
|
|
@ -63,4 +66,4 @@ public class NacosRule extends AbstractLoadBalancerRule {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void initWithNiwsConfig(IClientConfig iClientConfig) {
|
|
|
|
public void initWithNiwsConfig(IClientConfig iClientConfig) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|