Migration rule add ip support (#6893)

This commit is contained in:
ken.lj 2020-11-10 10:34:29 +08:00 committed by GitHub
parent 94ba6e2f8f
commit 530ea1a50a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -56,6 +56,11 @@ public class MigrationRuleHandler<T> {
} else {
try {
rule = MigrationRule.parse(rawRule);
// FIXME, consumerURL.getHost() might not exactly the ip expected.
if (rule.getTargetIps() == null || !rule.getTargetIps().contains(consumerURL.getHost())) {
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());

View File

@ -41,6 +41,8 @@ public class MigrationRule {
private String key;
private MigrationStep step;
private Float threshold;
// FIXME
private List<String> targetIps;
private List<InterfaceMigrationRule> interfaces;
private transient Map<String, InterfaceMigrationRule> interfaceRules;
@ -100,6 +102,13 @@ public class MigrationRule {
return interfaces;
}
public List<String> getTargetIps() {
return targetIps;
}
public void setTargetIps(List<String> targetIps) {
this.targetIps = targetIps;
}
public void setInterfaces(List<InterfaceMigrationRule> interfaces) {
this.interfaces = interfaces;