From 03abe135dc74cfb1e2a0be5058da0668e4dfd6ac Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Tue, 10 Nov 2020 10:38:04 +0800 Subject: [PATCH] fix migration rule ip match logic --- .../client/migration/MigrationRuleHandler.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationRuleHandler.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationRuleHandler.java index 7588f74d2d..ab802f848a 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationRuleHandler.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationRuleHandler.java @@ -57,13 +57,13 @@ public class MigrationRuleHandler { try { rule = MigrationRule.parse(rawRule); // FIXME, consumerURL.getHost() might not exactly the ip expected. - if (rule.getTargetIps() == null || !rule.getTargetIps().contains(consumerURL.getHost())) { + if (rule.getTargetIps() != null && rule.getTargetIps().contains(consumerURL.getHost())) { + setMigrationRule(rule); + step = rule.getStep(consumerURL.getServiceKey()); + threshold = rule.getThreshold(consumerURL.getServiceKey()); + } else { logger.info("Migration rule ignored, rule target ips " + rule.getTargetIps() + " and local ip " + consumerURL.getHost() + " do not match"); - return; } - setMigrationRule(rule); - step = rule.getStep(consumerURL.getServiceKey()); - threshold = rule.getThreshold(consumerURL.getServiceKey()); } catch (Exception e) { logger.error("Parse migration rule error, will use default step " + step, e); }