Skip to content

Commit

Permalink
Refactor CreateDatabaseRuleRDLExecuteEngine (#29820)
Browse files Browse the repository at this point in the history
* Remove useless generic type on RuleDefinitionBackendHandler

* Refactor CreateDatabaseRuleRDLExecuteEngine

* Refactor DropDatabaseRuleRDLExecuteEngine
  • Loading branch information
terrymanu authored Jan 23, 2024
1 parent 48d669c commit 30c1ec4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ public final class CreateDatabaseRuleRDLExecuteEngine implements DatabaseRuleRDL
@SuppressWarnings("unchecked")
public Collection<MetaDataVersion> execute(final RuleDefinitionStatement sqlStatement, final ShardingSphereDatabase database, final RuleConfiguration currentRuleConfig) {
RuleConfiguration toBeCreatedRuleConfig = executor.buildToBeCreatedRuleConfiguration(currentRuleConfig, sqlStatement);
if (null != currentRuleConfig) {
executor.updateCurrentRuleConfiguration(currentRuleConfig, toBeCreatedRuleConfig);
}
executor.updateCurrentRuleConfiguration(currentRuleConfig, toBeCreatedRuleConfig);
ModeContextManager modeContextManager = ProxyContext.getInstance().getContextManager().getInstanceContext().getModeContextManager();
return modeContextManager.alterRuleConfiguration(database.getName(), getToBeCreatedRuleConfiguration(sqlStatement, database, currentRuleConfig, toBeCreatedRuleConfig));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Collection<MetaDataVersion> execute(final RuleDefinitionStatement sqlStat
if (executor.updateCurrentRuleConfiguration(sqlStatement, currentRuleConfig) && ((DatabaseRuleConfiguration) currentRuleConfig).isEmpty()) {
modeContextManager.removeRuleConfigurationItem(database.getName(), toBeDroppedRuleConfig);
new NewYamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(Collections.singleton(currentRuleConfig)).values().stream().findFirst()
.ifPresent(swapper -> modeContextManager.removeRuleConfiguration(database.getName(), swapper.getRuleTagName().toLowerCase()));
.ifPresent(optional -> modeContextManager.removeRuleConfiguration(database.getName(), optional.getRuleTagName().toLowerCase()));
return Collections.emptyList();
}
if (executor instanceof DropReadwriteSplittingRuleExecutor) {
Expand Down

0 comments on commit 30c1ec4

Please sign in to comment.