Skip to content
Permalink
Browse files
Optimize configuration item key (#10006)
  • Loading branch information
chickenlj committed May 9, 2022
1 parent 5880b02 commit ec98ff364cb58f0fad82dda044cbcc0604c098c0
Showing 2 changed files with 12 additions and 3 deletions.
@@ -24,7 +24,7 @@
import org.apache.dubbo.registry.client.migration.model.MigrationStep;

public class MigrationRuleHandler<T> {
public static final String DUBBO_SERVICEDISCOVERY_MIGRATION = "dubbo.application.service-discovery.migration";
public static final String DUBBO_SERVICEDISCOVERY_MIGRATION = "dubbo.application.migration.step";
private static final Logger logger = LoggerFactory.getLogger(MigrationRuleHandler.class);

private MigrationClusterInvoker<T> migrationInvoker;
@@ -19,6 +19,7 @@
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.config.ConfigurationUtils;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.metadata.ServiceNameMapping;

import org.yaml.snakeyaml.Yaml;
@@ -180,13 +181,21 @@ public MigrationStep getStep(URL consumerURL) {
// initial step : APPLICATION_FIRST
step = MigrationStep.APPLICATION_FIRST;
step = Enum.valueOf(MigrationStep.class,
consumerURL.getParameter(MIGRATION_STEP_KEY,
ConfigurationUtils.getCachedDynamicProperty(consumerURL.getScopeModel(), DUBBO_SERVICEDISCOVERY_MIGRATION, step.name())));
consumerURL.getParameter(MIGRATION_STEP_KEY, getDefaultStep(consumerURL, step.name())));
}

return step;
}

private String getDefaultStep(URL consumerURL, String defaultStep) {
String globalDefaultStep = ConfigurationUtils.getCachedDynamicProperty(consumerURL.getScopeModel(), DUBBO_SERVICEDISCOVERY_MIGRATION, null);
if (StringUtils.isEmpty(globalDefaultStep)) {
// check 'dubbo.application.service-discovery.migration' for compatibility
globalDefaultStep = ConfigurationUtils.getCachedDynamicProperty(consumerURL.getScopeModel(), "dubbo.application.service-discovery.migration", defaultStep);
}
return globalDefaultStep;
}

public MigrationStep getStep() {
return step;
}

0 comments on commit ec98ff3

Please sign in to comment.