Skip to content

Commit

Permalink
Fix the issue of taking the zone parameter value in ZoneAwareClusterI…
Browse files Browse the repository at this point in the history
…nvoker (#8521)
  • Loading branch information
BurningCN committed Aug 23, 2021
1 parent 6acd5a2 commit c22d746
Showing 1 changed file with 2 additions and 5 deletions.
Expand Up @@ -40,7 +40,6 @@
import java.util.stream.Collectors;

import static org.apache.dubbo.common.constants.RegistryConstants.LOADBALANCE_AMONG_REGISTRIES;
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_KEY;
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_ZONE;
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_ZONE_FORCE;
import static org.apache.dubbo.common.constants.RegistryConstants.ZONE_KEY;
Expand All @@ -58,8 +57,6 @@
public class ZoneAwareClusterInvoker<T> extends AbstractClusterInvoker<T> {

private static final Logger logger = LoggerFactory.getLogger(ZoneAwareClusterInvoker.class);

private static final String PREFER_REGISTRY_WITH_ZONE_KEY = REGISTRY_KEY + "." + ZONE_KEY;

private final LoadBalance loadBalanceAmongRegistries = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(LOADBALANCE_AMONG_REGISTRIES);

Expand All @@ -84,7 +81,7 @@ public Result doInvoke(Invocation invocation, final List<Invoker<T>> invokers, L
if (StringUtils.isNotEmpty(zone)) {
for (Invoker<T> invoker : invokers) {
ClusterInvoker<T> clusterInvoker = (ClusterInvoker<T>) invoker;
if (clusterInvoker.isAvailable() && zone.equals(clusterInvoker.getRegistryUrl().getParameter(PREFER_REGISTRY_WITH_ZONE_KEY))) {
if (clusterInvoker.isAvailable() && zone.equals(clusterInvoker.getRegistryUrl().getParameter(ZONE_KEY))) {
return clusterInvoker.invoke(invocation);
}
}
Expand Down Expand Up @@ -248,4 +245,4 @@ private void clusterRefresh(boolean addressChanged, List<Invoker<T>> invokers) {
}
}

}
}

0 comments on commit c22d746

Please sign in to comment.