You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2023/06/12 09:38:01 UTC
[shardingsphere] branch master updated: Add global rule refresh logic (#26303)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new f50b71597b6 Add global rule refresh logic (#26303)
f50b71597b6 is described below
commit f50b71597b6c55accd12dcd551b408ee9f789bf5
Author: zhaojinchao <zh...@apache.org>
AuthorDate: Mon Jun 12 17:37:54 2023 +0800
Add global rule refresh logic (#26303)
---
.../subscriber/EncryptConfigurationSubscriber.java | 8 ++--
.../encrypt/subscriber/EncryptorSubscriber.java | 6 +--
.../mask/subscriber/MaskAlgorithmSubscriber.java | 6 +--
.../subscriber/MaskConfigurationSubscriber.java | 8 ++--
.../ReadwriteSplittingConfigurationSubscriber.java | 8 ++--
.../ReadwriteSplittingLoadBalanceSubscriber.java | 6 +--
.../subscriber/ShadowAlgorithmSubscriber.java | 6 +--
.../subscriber/ShadowConfigurationSubscriber.java | 8 ++--
.../shadow/subscriber/ShadowTableSubscriber.java | 6 +--
.../event/AlterGlobalRuleConfigurationEvent.java | 11 +++--
.../event/DeleteGlobalRuleConfigurationEvent.java | 8 ++--
.../AuthorityRuleConfigurationEventBuilder.java | 17 ++++---
.../config/AddAuthorityConfigurationEvent.java | 35 ---------------
.../config/AlterAuthorityConfigurationEvent.java | 35 ---------------
.../config/DeleteAuthorityConfigurationEvent.java | 32 -------------
.../GlobalClockRuleConfigurationEventBuilder.java | 17 ++++---
.../config/AddGlobalClockConfigurationEvent.java | 35 ---------------
.../config/AlterGlobalClockConfigurationEvent.java | 35 ---------------
.../DeleteGlobalClockConfigurationEvent.java | 32 -------------
.../LoggingRuleConfigurationEventBuilder.java | 17 ++++---
.../event/config/AddLoggingConfigurationEvent.java | 35 ---------------
.../config/AlterLoggingConfigurationEvent.java | 35 ---------------
.../event/SingleRuleConfigurationEventBuilder.java | 17 ++++---
.../event/config/AddSingleConfigurationEvent.java | 35 ---------------
.../config/AlterSingleConfigurationEvent.java | 35 ---------------
.../config/DeleteSingleConfigurationEvent.java | 32 -------------
...SQLFederationRuleConfigurationEventBuilder.java | 17 ++++---
.../config/AddSQLFederationConfigurationEvent.java | 35 ---------------
.../AlterSQLFederationConfigurationEvent.java | 35 ---------------
.../DeleteSQLFederationConfigurationEvent.java | 32 -------------
.../SQLParserRuleConfigurationEventBuilder.java | 17 ++++---
.../config/AddSQLParserConfigurationEvent.java | 35 ---------------
.../config/AlterSQLParserConfigurationEvent.java | 35 ---------------
.../SQLTranslatorConfigurationEventBuilder.java | 17 ++++---
.../config/AddSQLTranslatorConfigurationEvent.java | 35 ---------------
.../AlterSQLTranslatorConfigurationEvent.java | 35 ---------------
.../DeleteSQLTranslatorConfigurationEvent.java | 32 -------------
.../TrafficRuleConfigurationEventBuilder.java | 21 +++++----
.../event/config/AddTrafficConfigurationEvent.java | 35 ---------------
.../config/AlterTrafficConfigurationEvent.java | 35 ---------------
.../config/DeleteTrafficConfigurationEvent.java | 32 -------------
.../TransactionRuleConfigurationEventBuilder.java | 17 ++++---
.../config/AddTransactionConfigurationEvent.java | 35 ---------------
.../config/AlterTransactionConfigurationEvent.java | 35 ---------------
.../DeleteTransactionConfigurationEvent.java | 32 -------------
... => DatabaseRuleConfigurationChangedEvent.java} | 4 +-
.../NewConfigurationChangedSubscriber.java | 52 +++++++++++++++++++++-
47 files changed, 170 insertions(+), 978 deletions(-)
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptConfigurationSubscriber.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptConfigurationSubscriber.java
index be47a095186..3e79c70558b 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptConfigurationSubscriber.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptConfigurationSubscriber.java
@@ -29,7 +29,7 @@ import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import java.util.Collection;
import java.util.Collections;
@@ -75,7 +75,7 @@ public final class EncryptConfigurationSubscriber implements RuleConfigurationSu
}
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
/**
@@ -93,7 +93,7 @@ public final class EncryptConfigurationSubscriber implements RuleConfigurationSu
config.getTables().add(needToAlteredConfig);
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
/**
@@ -109,6 +109,6 @@ public final class EncryptConfigurationSubscriber implements RuleConfigurationSu
config.getTables().removeIf(each -> each.getName().equals(event.getTableName()));
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptorSubscriber.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptorSubscriber.java
index 16a1f8aed17..17c7bde4cbd 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptorSubscriber.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptorSubscriber.java
@@ -29,7 +29,7 @@ import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import java.util.Collection;
import java.util.LinkedList;
@@ -80,7 +80,7 @@ public final class EncryptorSubscriber implements RuleConfigurationSubscribeCoor
config.getEncryptors().put(encryptorName, encryptorConfig);
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(databaseName, config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(databaseName, config));
}
/**
@@ -96,6 +96,6 @@ public final class EncryptorSubscriber implements RuleConfigurationSubscribeCoor
config.getEncryptors().remove(event.getEncryptorName());
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskAlgorithmSubscriber.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskAlgorithmSubscriber.java
index c330094b852..26f3d9ae5c5 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskAlgorithmSubscriber.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskAlgorithmSubscriber.java
@@ -29,7 +29,7 @@ import org.apache.shardingsphere.mask.event.algorithm.AddMaskAlgorithmEvent;
import org.apache.shardingsphere.mask.event.algorithm.AlterMaskAlgorithmEvent;
import org.apache.shardingsphere.mask.event.algorithm.DeleteMaskAlgorithmEvent;
import org.apache.shardingsphere.mask.rule.MaskRule;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import java.util.Collection;
import java.util.LinkedList;
@@ -80,7 +80,7 @@ public final class MaskAlgorithmSubscriber implements RuleConfigurationSubscribe
config.getMaskAlgorithms().put(algorithmName, algorithmConfig);
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(databaseName, config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(databaseName, config));
}
/**
@@ -96,6 +96,6 @@ public final class MaskAlgorithmSubscriber implements RuleConfigurationSubscribe
config.getMaskAlgorithms().remove(event.getAlgorithmName());
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskConfigurationSubscriber.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskConfigurationSubscriber.java
index 4b14adbcbef..2ce1b8363c2 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskConfigurationSubscriber.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskConfigurationSubscriber.java
@@ -29,7 +29,7 @@ import org.apache.shardingsphere.mask.event.config.AddMaskConfigurationEvent;
import org.apache.shardingsphere.mask.event.config.AlterMaskConfigurationEvent;
import org.apache.shardingsphere.mask.event.config.DeleteMaskConfigurationEvent;
import org.apache.shardingsphere.mask.rule.MaskRule;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import java.util.Collection;
import java.util.Collections;
@@ -75,7 +75,7 @@ public final class MaskConfigurationSubscriber implements RuleConfigurationSubsc
}
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
/**
@@ -93,7 +93,7 @@ public final class MaskConfigurationSubscriber implements RuleConfigurationSubsc
config.getTables().add(needToAlteredConfig);
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
/**
@@ -109,6 +109,6 @@ public final class MaskConfigurationSubscriber implements RuleConfigurationSubsc
config.getTables().removeIf(each -> each.getName().equals(event.getTableName()));
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
}
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/subscriber/ReadwriteSplittingConfigurationSubscriber.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/subscriber/ReadwriteSplittingConfigurationSubscriber.java
index 5e9d47c968c..f791ab6e6e1 100644
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/subscriber/ReadwriteSplittingConfigurationSubscriber.java
+++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/subscriber/ReadwriteSplittingConfigurationSubscriber.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.event.config.AddReadwriteSplittingConfigurationEvent;
@@ -75,7 +75,7 @@ public final class ReadwriteSplittingConfigurationSubscriber implements RuleConf
}
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
/**
@@ -93,7 +93,7 @@ public final class ReadwriteSplittingConfigurationSubscriber implements RuleConf
config.getDataSources().add(needToAlteredConfig);
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
/**
@@ -109,6 +109,6 @@ public final class ReadwriteSplittingConfigurationSubscriber implements RuleConf
config.getDataSources().removeIf(each -> each.getName().equals(event.getGroupName()));
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
}
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/subscriber/ReadwriteSplittingLoadBalanceSubscriber.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/subscriber/ReadwriteSplittingLoadBalanceSubscriber.java
index c17bfab355f..1e0909523b9 100644
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/subscriber/ReadwriteSplittingLoadBalanceSubscriber.java
+++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/subscriber/ReadwriteSplittingLoadBalanceSubscriber.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.event.loadbalance.AddLoadBalanceEvent;
import org.apache.shardingsphere.readwritesplitting.event.loadbalance.AlterLoadBalanceEvent;
@@ -80,7 +80,7 @@ public final class ReadwriteSplittingLoadBalanceSubscriber implements RuleConfig
config.getLoadBalancers().put(loadBalanceName, algorithmConfig);
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(databaseName, config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(databaseName, config));
}
/**
@@ -96,6 +96,6 @@ public final class ReadwriteSplittingLoadBalanceSubscriber implements RuleConfig
config.getLoadBalancers().remove(event.getLoadBalanceName());
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowAlgorithmSubscriber.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowAlgorithmSubscriber.java
index f75983ae153..2e1e2ed0ad8 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowAlgorithmSubscriber.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowAlgorithmSubscriber.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.event.algorithm.AddShadowAlgorithmEvent;
import org.apache.shardingsphere.shadow.event.algorithm.AlterShadowAlgorithmEvent;
@@ -80,7 +80,7 @@ public final class ShadowAlgorithmSubscriber implements RuleConfigurationSubscri
config.getShadowAlgorithms().put(algorithmName, algorithmConfig);
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(databaseName, config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(databaseName, config));
}
/**
@@ -96,6 +96,6 @@ public final class ShadowAlgorithmSubscriber implements RuleConfigurationSubscri
config.getShadowAlgorithms().remove(event.getAlgorithmName());
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowConfigurationSubscriber.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowConfigurationSubscriber.java
index 6515a576b10..be9d6447a59 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowConfigurationSubscriber.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowConfigurationSubscriber.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
import org.apache.shardingsphere.shadow.event.config.AddShadowConfigurationEvent;
@@ -76,7 +76,7 @@ public final class ShadowConfigurationSubscriber implements RuleConfigurationSub
}
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
/**
@@ -94,7 +94,7 @@ public final class ShadowConfigurationSubscriber implements RuleConfigurationSub
config.getDataSources().add(needToAlteredConfig);
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
/**
@@ -110,6 +110,6 @@ public final class ShadowConfigurationSubscriber implements RuleConfigurationSub
config.getDataSources().removeIf(each -> each.getName().equals(event.getDataSourceName()));
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowTableSubscriber.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowTableSubscriber.java
index 1308bf496fe..1f2b5e93438 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowTableSubscriber.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowTableSubscriber.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
import org.apache.shardingsphere.shadow.event.table.AddShadowTableEvent;
@@ -80,7 +80,7 @@ public final class ShadowTableSubscriber implements RuleConfigurationSubscribeCo
config.getTables().put(tableName, tableConfig);
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(databaseName, config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(databaseName, config));
}
/**
@@ -96,6 +96,6 @@ public final class ShadowTableSubscriber implements RuleConfigurationSubscribeCo
config.getTables().remove(event.getTableName());
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
- instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
}
diff --git a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/DeleteSQLParserConfigurationEvent.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/global/event/AlterGlobalRuleConfigurationEvent.java
similarity index 75%
rename from kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/DeleteSQLParserConfigurationEvent.java
rename to infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/global/event/AlterGlobalRuleConfigurationEvent.java
index dd8afaefea9..b41226fb02d 100644
--- a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/DeleteSQLParserConfigurationEvent.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/global/event/AlterGlobalRuleConfigurationEvent.java
@@ -15,18 +15,23 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.parser.event.config;
+package org.apache.shardingsphere.infra.config.rule.global.event;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Delete sql parser configuration event.
+ * Alter global rule configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DeleteSQLParserConfigurationEvent implements GovernanceEvent {
+public final class AlterGlobalRuleConfigurationEvent implements GovernanceEvent {
private final String databaseName;
+
+ private final RuleConfiguration config;
+
+ private final String ruleSimpleName;
}
diff --git a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/DeleteLoggingConfigurationEvent.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/global/event/DeleteGlobalRuleConfigurationEvent.java
similarity index 81%
rename from kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/DeleteLoggingConfigurationEvent.java
rename to infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/global/event/DeleteGlobalRuleConfigurationEvent.java
index ddfe9447cdf..32f62e3a080 100644
--- a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/DeleteLoggingConfigurationEvent.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/global/event/DeleteGlobalRuleConfigurationEvent.java
@@ -15,18 +15,20 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.logging.event.config;
+package org.apache.shardingsphere.infra.config.rule.global.event;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Delete logging configuration event.
+ * Delete global rule configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DeleteLoggingConfigurationEvent implements GovernanceEvent {
+public final class DeleteGlobalRuleConfigurationEvent implements GovernanceEvent {
private final String databaseName;
+
+ private final String ruleSimpleName;
}
diff --git a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/AuthorityRuleConfigurationEventBuilder.java b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/AuthorityRuleConfigurationEventBuilder.java
index 4c2d44c1c28..4bbecc6b88b 100644
--- a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/AuthorityRuleConfigurationEventBuilder.java
+++ b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/AuthorityRuleConfigurationEventBuilder.java
@@ -19,12 +19,12 @@ package org.apache.shardingsphere.authority.event;
import com.google.common.base.Strings;
import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
-import org.apache.shardingsphere.authority.event.config.AddAuthorityConfigurationEvent;
-import org.apache.shardingsphere.authority.event.config.AlterAuthorityConfigurationEvent;
-import org.apache.shardingsphere.authority.event.config.DeleteAuthorityConfigurationEvent;
+import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
import org.apache.shardingsphere.authority.yaml.swapper.YamlAuthorityRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.event.AlterGlobalRuleConfigurationEvent;
+import org.apache.shardingsphere.infra.config.rule.global.event.DeleteGlobalRuleConfigurationEvent;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
@@ -40,6 +40,8 @@ public final class AuthorityRuleConfigurationEventBuilder implements RuleConfigu
private static final String AUTHORITY = "authority";
+ private static final String RULE_TYPE = AuthorityRule.class.getSimpleName();
+
@Override
public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
if (!GlobalRuleNodeConverter.isExpectedRuleName(AUTHORITY, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
@@ -49,13 +51,10 @@ public final class AuthorityRuleConfigurationEventBuilder implements RuleConfigu
}
private Optional<GovernanceEvent> buildAuthorityRuleConfigurationEvent(final String databaseName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType()) {
- return Optional.of(new AddAuthorityConfigurationEvent(databaseName, swapToConfig(event.getValue())));
- }
- if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterAuthorityConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterGlobalRuleConfigurationEvent(databaseName, swapToConfig(event.getValue()), RULE_TYPE));
}
- return Optional.of(new DeleteAuthorityConfigurationEvent(databaseName));
+ return Optional.of(new DeleteGlobalRuleConfigurationEvent(databaseName, RULE_TYPE));
}
private AuthorityRuleConfiguration swapToConfig(final String yamlContext) {
diff --git a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/AddAuthorityConfigurationEvent.java b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/AddAuthorityConfigurationEvent.java
deleted file mode 100644
index 2f182b7fe09..00000000000
--- a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/AddAuthorityConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.authority.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Add authority configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AddAuthorityConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final AuthorityRuleConfiguration config;
-}
diff --git a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/AlterAuthorityConfigurationEvent.java b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/AlterAuthorityConfigurationEvent.java
deleted file mode 100644
index a94d0a165e7..00000000000
--- a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/AlterAuthorityConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.authority.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Alter authority configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AlterAuthorityConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final AuthorityRuleConfiguration config;
-}
diff --git a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/DeleteAuthorityConfigurationEvent.java b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/DeleteAuthorityConfigurationEvent.java
deleted file mode 100644
index 72d3439e150..00000000000
--- a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/DeleteAuthorityConfigurationEvent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.authority.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Delete authority configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class DeleteAuthorityConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-}
diff --git a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/GlobalClockRuleConfigurationEventBuilder.java b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/GlobalClockRuleConfigurationEventBuilder.java
index c8738d84673..e833a8bedf6 100644
--- a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/GlobalClockRuleConfigurationEventBuilder.java
+++ b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/GlobalClockRuleConfigurationEventBuilder.java
@@ -19,12 +19,12 @@ package org.apache.shardingsphere.globalclock.core.event;
import com.google.common.base.Strings;
import org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
-import org.apache.shardingsphere.globalclock.core.event.config.AddGlobalClockConfigurationEvent;
-import org.apache.shardingsphere.globalclock.core.event.config.AlterGlobalClockConfigurationEvent;
-import org.apache.shardingsphere.globalclock.core.event.config.DeleteGlobalClockConfigurationEvent;
+import org.apache.shardingsphere.globalclock.core.rule.GlobalClockRule;
import org.apache.shardingsphere.globalclock.core.yaml.config.YamlGlobalClockRuleConfiguration;
import org.apache.shardingsphere.globalclock.core.yaml.swapper.YamlGlobalClockRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.event.AlterGlobalRuleConfigurationEvent;
+import org.apache.shardingsphere.infra.config.rule.global.event.DeleteGlobalRuleConfigurationEvent;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
@@ -40,6 +40,8 @@ public final class GlobalClockRuleConfigurationEventBuilder implements RuleConfi
private static final String GLOBAL_CLOCK = "global_clock";
+ private static final String RULE_TYPE = GlobalClockRule.class.getSimpleName();
+
@Override
public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
if (!GlobalRuleNodeConverter.isExpectedRuleName(GLOBAL_CLOCK, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
@@ -49,13 +51,10 @@ public final class GlobalClockRuleConfigurationEventBuilder implements RuleConfi
}
private Optional<GovernanceEvent> buildGlobalClockRuleConfigurationEvent(final String databaseName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType()) {
- return Optional.of(new AddGlobalClockConfigurationEvent(databaseName, swapToConfig(event.getValue())));
- }
- if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterGlobalClockConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterGlobalRuleConfigurationEvent(databaseName, swapToConfig(event.getValue()), RULE_TYPE));
}
- return Optional.of(new DeleteGlobalClockConfigurationEvent(databaseName));
+ return Optional.of(new DeleteGlobalRuleConfigurationEvent(databaseName, RULE_TYPE));
}
private GlobalClockRuleConfiguration swapToConfig(final String yamlContext) {
diff --git a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/AddGlobalClockConfigurationEvent.java b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/AddGlobalClockConfigurationEvent.java
deleted file mode 100644
index 7ed39dce8bf..00000000000
--- a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/AddGlobalClockConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.globalclock.core.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Add global clock configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AddGlobalClockConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final GlobalClockRuleConfiguration config;
-}
diff --git a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/AlterGlobalClockConfigurationEvent.java b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/AlterGlobalClockConfigurationEvent.java
deleted file mode 100644
index 5883cc39ff5..00000000000
--- a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/AlterGlobalClockConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.globalclock.core.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Alter global clock configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AlterGlobalClockConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final GlobalClockRuleConfiguration config;
-}
diff --git a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/DeleteGlobalClockConfigurationEvent.java b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/DeleteGlobalClockConfigurationEvent.java
deleted file mode 100644
index d285429b08b..00000000000
--- a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/DeleteGlobalClockConfigurationEvent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.globalclock.core.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Delete global clock configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class DeleteGlobalClockConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-}
diff --git a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/LoggingRuleConfigurationEventBuilder.java b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/LoggingRuleConfigurationEventBuilder.java
index 08a007f576a..a847f235f86 100644
--- a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/LoggingRuleConfigurationEventBuilder.java
+++ b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/LoggingRuleConfigurationEventBuilder.java
@@ -19,12 +19,12 @@ package org.apache.shardingsphere.logging.event;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.event.AlterGlobalRuleConfigurationEvent;
+import org.apache.shardingsphere.infra.config.rule.global.event.DeleteGlobalRuleConfigurationEvent;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.logging.config.LoggingRuleConfiguration;
-import org.apache.shardingsphere.logging.event.config.AddLoggingConfigurationEvent;
-import org.apache.shardingsphere.logging.event.config.AlterLoggingConfigurationEvent;
-import org.apache.shardingsphere.logging.event.config.DeleteLoggingConfigurationEvent;
+import org.apache.shardingsphere.logging.rule.LoggingRule;
import org.apache.shardingsphere.logging.yaml.config.YamlLoggingRuleConfiguration;
import org.apache.shardingsphere.logging.yaml.swapper.YamlLoggingRuleConfigurationSwapper;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
@@ -40,6 +40,8 @@ public final class LoggingRuleConfigurationEventBuilder implements RuleConfigura
private static final String LOGGING = "logging";
+ private static final String RULE_TYPE = LoggingRule.class.getSimpleName();
+
@Override
public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
if (!GlobalRuleNodeConverter.isExpectedRuleName(LOGGING, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
@@ -49,13 +51,10 @@ public final class LoggingRuleConfigurationEventBuilder implements RuleConfigura
}
private Optional<GovernanceEvent> buildLoggingRuleConfigurationEvent(final String databaseName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType()) {
- return Optional.of(new AddLoggingConfigurationEvent(databaseName, swapToConfig(event.getValue())));
- }
- if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterLoggingConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterGlobalRuleConfigurationEvent(databaseName, swapToConfig(event.getValue()), RULE_TYPE));
}
- return Optional.of(new DeleteLoggingConfigurationEvent(databaseName));
+ return Optional.of(new DeleteGlobalRuleConfigurationEvent(databaseName, RULE_TYPE));
}
private LoggingRuleConfiguration swapToConfig(final String yamlContext) {
diff --git a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/AddLoggingConfigurationEvent.java b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/AddLoggingConfigurationEvent.java
deleted file mode 100644
index 469f02f1e46..00000000000
--- a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/AddLoggingConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.logging.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.logging.config.LoggingRuleConfiguration;
-
-/**
- * Add logging configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AddLoggingConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final LoggingRuleConfiguration config;
-}
diff --git a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/AlterLoggingConfigurationEvent.java b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/AlterLoggingConfigurationEvent.java
deleted file mode 100644
index c6b38a6a8e2..00000000000
--- a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/AlterLoggingConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.logging.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.logging.config.LoggingRuleConfiguration;
-
-/**
- * Alter logging configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AlterLoggingConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final LoggingRuleConfiguration config;
-}
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleConfigurationEventBuilder.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleConfigurationEventBuilder.java
index 06f2b95644d..6a03d24cb94 100644
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleConfigurationEventBuilder.java
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleConfigurationEventBuilder.java
@@ -19,15 +19,15 @@ package org.apache.shardingsphere.single.event;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.event.AlterGlobalRuleConfigurationEvent;
+import org.apache.shardingsphere.infra.config.rule.global.event.DeleteGlobalRuleConfigurationEvent;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder;
import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
-import org.apache.shardingsphere.single.event.config.AddSingleConfigurationEvent;
-import org.apache.shardingsphere.single.event.config.AlterSingleConfigurationEvent;
-import org.apache.shardingsphere.single.event.config.DeleteSingleConfigurationEvent;
+import org.apache.shardingsphere.single.rule.SingleRule;
import org.apache.shardingsphere.single.yaml.config.pojo.YamlSingleRuleConfiguration;
import org.apache.shardingsphere.single.yaml.config.swapper.YamlSingleRuleConfigurationSwapper;
@@ -40,6 +40,8 @@ public final class SingleRuleConfigurationEventBuilder implements RuleConfigurat
private static final String SINGLE = "single";
+ private static final String RULE_TYPE = SingleRule.class.getSimpleName();
+
@Override
public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
if (!GlobalRuleNodeConverter.isExpectedRuleName(SINGLE, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
@@ -49,13 +51,10 @@ public final class SingleRuleConfigurationEventBuilder implements RuleConfigurat
}
private Optional<GovernanceEvent> buildAuthorityRuleConfigurationEvent(final String databaseName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType()) {
- return Optional.of(new AddSingleConfigurationEvent(databaseName, swapToConfig(event.getValue())));
- }
- if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterSingleConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterGlobalRuleConfigurationEvent(databaseName, swapToConfig(event.getValue()), RULE_TYPE));
}
- return Optional.of(new DeleteSingleConfigurationEvent(databaseName));
+ return Optional.of(new DeleteGlobalRuleConfigurationEvent(databaseName, RULE_TYPE));
}
private SingleRuleConfiguration swapToConfig(final String yamlContext) {
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/AddSingleConfigurationEvent.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/AddSingleConfigurationEvent.java
deleted file mode 100644
index 42b86a819dd..00000000000
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/AddSingleConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.single.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
-
-/**
- * Add single configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AddSingleConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final SingleRuleConfiguration config;
-}
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/AlterSingleConfigurationEvent.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/AlterSingleConfigurationEvent.java
deleted file mode 100644
index 3e815189af7..00000000000
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/AlterSingleConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.single.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
-
-/**
- * Alter single configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AlterSingleConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final SingleRuleConfiguration config;
-}
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/DeleteSingleConfigurationEvent.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/DeleteSingleConfigurationEvent.java
deleted file mode 100644
index 9bf54325299..00000000000
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/DeleteSingleConfigurationEvent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.single.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Delete single configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class DeleteSingleConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/SQLFederationRuleConfigurationEventBuilder.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/SQLFederationRuleConfigurationEventBuilder.java
index ea370eae02b..d4e0b7d624e 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/SQLFederationRuleConfigurationEventBuilder.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/SQLFederationRuleConfigurationEventBuilder.java
@@ -19,15 +19,15 @@ package org.apache.shardingsphere.sqlfederation.event;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.event.AlterGlobalRuleConfigurationEvent;
+import org.apache.shardingsphere.infra.config.rule.global.event.DeleteGlobalRuleConfigurationEvent;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder;
import org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
-import org.apache.shardingsphere.sqlfederation.event.config.AddSQLFederationConfigurationEvent;
-import org.apache.shardingsphere.sqlfederation.event.config.AlterSQLFederationConfigurationEvent;
-import org.apache.shardingsphere.sqlfederation.event.config.DeleteSQLFederationConfigurationEvent;
+import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule;
import org.apache.shardingsphere.sqlfederation.yaml.config.YamlSQLFederationRuleConfiguration;
import org.apache.shardingsphere.sqlfederation.yaml.swapper.YamlSQLFederationRuleConfigurationSwapper;
@@ -40,6 +40,8 @@ public final class SQLFederationRuleConfigurationEventBuilder implements RuleCon
private static final String SQL_FEDERATION = "sql_federation";
+ private static final String RULE_TYPE = SQLFederationRule.class.getSimpleName();
+
@Override
public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
if (!GlobalRuleNodeConverter.isExpectedRuleName(SQL_FEDERATION, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
@@ -49,13 +51,10 @@ public final class SQLFederationRuleConfigurationEventBuilder implements RuleCon
}
private Optional<GovernanceEvent> buildGlobalClockRuleConfigurationEvent(final String databaseName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType()) {
- return Optional.of(new AddSQLFederationConfigurationEvent(databaseName, swapToConfig(event.getValue())));
- }
- if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterSQLFederationConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterGlobalRuleConfigurationEvent(databaseName, swapToConfig(event.getValue()), RULE_TYPE));
}
- return Optional.of(new DeleteSQLFederationConfigurationEvent(databaseName));
+ return Optional.of(new DeleteGlobalRuleConfigurationEvent(databaseName, RULE_TYPE));
}
private SQLFederationRuleConfiguration swapToConfig(final String yamlContext) {
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/AddSQLFederationConfigurationEvent.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/AddSQLFederationConfigurationEvent.java
deleted file mode 100644
index 19cc0a09dc3..00000000000
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/AddSQLFederationConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sqlfederation.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
-
-/**
- * Add sql federation configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AddSQLFederationConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final SQLFederationRuleConfiguration config;
-}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/AlterSQLFederationConfigurationEvent.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/AlterSQLFederationConfigurationEvent.java
deleted file mode 100644
index 564d95c7370..00000000000
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/AlterSQLFederationConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sqlfederation.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
-
-/**
- * Alter sql federation configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AlterSQLFederationConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final SQLFederationRuleConfiguration config;
-}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/DeleteSQLFederationConfigurationEvent.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/DeleteSQLFederationConfigurationEvent.java
deleted file mode 100644
index 8af4af0aa3c..00000000000
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/DeleteSQLFederationConfigurationEvent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sqlfederation.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Delete sql federation configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class DeleteSQLFederationConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-}
diff --git a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/SQLParserRuleConfigurationEventBuilder.java b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/SQLParserRuleConfigurationEventBuilder.java
index f3b91fbbba8..3494640adf4 100644
--- a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/SQLParserRuleConfigurationEventBuilder.java
+++ b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/SQLParserRuleConfigurationEventBuilder.java
@@ -19,15 +19,15 @@ package org.apache.shardingsphere.parser.event;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.event.AlterGlobalRuleConfigurationEvent;
+import org.apache.shardingsphere.infra.config.rule.global.event.DeleteGlobalRuleConfigurationEvent;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder;
import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
-import org.apache.shardingsphere.parser.event.config.AddSQLParserConfigurationEvent;
-import org.apache.shardingsphere.parser.event.config.AlterSQLParserConfigurationEvent;
-import org.apache.shardingsphere.parser.event.config.DeleteSQLParserConfigurationEvent;
+import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfiguration;
import org.apache.shardingsphere.parser.yaml.swapper.YamlSQLParserRuleConfigurationSwapper;
@@ -40,6 +40,8 @@ public final class SQLParserRuleConfigurationEventBuilder implements RuleConfigu
private static final String SQL_PARSER = "sql_parser";
+ private static final String RULE_TYPE = SQLParserRule.class.getSimpleName();
+
@Override
public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
if (!GlobalRuleNodeConverter.isExpectedRuleName(SQL_PARSER, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
@@ -49,13 +51,10 @@ public final class SQLParserRuleConfigurationEventBuilder implements RuleConfigu
}
private Optional<GovernanceEvent> buildGlobalClockRuleConfigurationEvent(final String databaseName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType()) {
- return Optional.of(new AddSQLParserConfigurationEvent(databaseName, swapToConfig(event.getValue())));
- }
- if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterSQLParserConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterGlobalRuleConfigurationEvent(databaseName, swapToConfig(event.getValue()), RULE_TYPE));
}
- return Optional.of(new DeleteSQLParserConfigurationEvent(databaseName));
+ return Optional.of(new DeleteGlobalRuleConfigurationEvent(databaseName, RULE_TYPE));
}
private SQLParserRuleConfiguration swapToConfig(final String yamlContext) {
diff --git a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/AddSQLParserConfigurationEvent.java b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/AddSQLParserConfigurationEvent.java
deleted file mode 100644
index a07548cebf5..00000000000
--- a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/AddSQLParserConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.parser.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
-
-/**
- * Add sql parser configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AddSQLParserConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final SQLParserRuleConfiguration config;
-}
diff --git a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/AlterSQLParserConfigurationEvent.java b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/AlterSQLParserConfigurationEvent.java
deleted file mode 100644
index eb21d0edb16..00000000000
--- a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/AlterSQLParserConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.parser.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
-
-/**
- * Alter sql parser configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AlterSQLParserConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final SQLParserRuleConfiguration config;
-}
diff --git a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/SQLTranslatorConfigurationEventBuilder.java b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/SQLTranslatorConfigurationEventBuilder.java
index f43387eb9cf..63dc3fd3473 100644
--- a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/SQLTranslatorConfigurationEventBuilder.java
+++ b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/SQLTranslatorConfigurationEventBuilder.java
@@ -19,15 +19,15 @@ package org.apache.shardingsphere.sqltranslator.event;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.event.AlterGlobalRuleConfigurationEvent;
+import org.apache.shardingsphere.infra.config.rule.global.event.DeleteGlobalRuleConfigurationEvent;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder;
import org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration;
-import org.apache.shardingsphere.sqltranslator.event.config.AddSQLTranslatorConfigurationEvent;
-import org.apache.shardingsphere.sqltranslator.event.config.AlterSQLTranslatorConfigurationEvent;
-import org.apache.shardingsphere.sqltranslator.event.config.DeleteSQLTranslatorConfigurationEvent;
+import org.apache.shardingsphere.sqltranslator.rule.SQLTranslatorRule;
import org.apache.shardingsphere.sqltranslator.yaml.config.YamlSQLTranslatorRuleConfiguration;
import org.apache.shardingsphere.sqltranslator.yaml.swapper.YamlSQLTranslatorRuleConfigurationSwapper;
@@ -40,6 +40,8 @@ public final class SQLTranslatorConfigurationEventBuilder implements RuleConfigu
private static final String SQL_TRANSLATOR = "sql_translator";
+ private static final String RULE_TYPE = SQLTranslatorRule.class.getSimpleName();
+
@Override
public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
if (!GlobalRuleNodeConverter.isExpectedRuleName(SQL_TRANSLATOR, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
@@ -49,13 +51,10 @@ public final class SQLTranslatorConfigurationEventBuilder implements RuleConfigu
}
private Optional<GovernanceEvent> buildGlobalClockRuleConfigurationEvent(final String databaseName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType()) {
- return Optional.of(new AddSQLTranslatorConfigurationEvent(databaseName, swapToConfig(event.getValue())));
- }
- if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterSQLTranslatorConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterGlobalRuleConfigurationEvent(databaseName, swapToConfig(event.getValue()), RULE_TYPE));
}
- return Optional.of(new DeleteSQLTranslatorConfigurationEvent(databaseName));
+ return Optional.of(new DeleteGlobalRuleConfigurationEvent(databaseName, RULE_TYPE));
}
private SQLTranslatorRuleConfiguration swapToConfig(final String yamlContext) {
diff --git a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/AddSQLTranslatorConfigurationEvent.java b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/AddSQLTranslatorConfigurationEvent.java
deleted file mode 100644
index cf21d6327f6..00000000000
--- a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/AddSQLTranslatorConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sqltranslator.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration;
-
-/**
- * Add sql translator configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AddSQLTranslatorConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final SQLTranslatorRuleConfiguration config;
-}
diff --git a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/AlterSQLTranslatorConfigurationEvent.java b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/AlterSQLTranslatorConfigurationEvent.java
deleted file mode 100644
index 0d98cbf7599..00000000000
--- a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/AlterSQLTranslatorConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sqltranslator.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration;
-
-/**
- * Alter sql translator configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AlterSQLTranslatorConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final SQLTranslatorRuleConfiguration config;
-}
diff --git a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/DeleteSQLTranslatorConfigurationEvent.java b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/DeleteSQLTranslatorConfigurationEvent.java
deleted file mode 100644
index 37384db611e..00000000000
--- a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/DeleteSQLTranslatorConfigurationEvent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sqltranslator.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Delete sql translator configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class DeleteSQLTranslatorConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-}
diff --git a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/TrafficRuleConfigurationEventBuilder.java b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/TrafficRuleConfigurationEventBuilder.java
index f96247d1fae..2cff51b0045 100644
--- a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/TrafficRuleConfigurationEventBuilder.java
+++ b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/TrafficRuleConfigurationEventBuilder.java
@@ -19,15 +19,15 @@ package org.apache.shardingsphere.traffic.event;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.event.AlterGlobalRuleConfigurationEvent;
+import org.apache.shardingsphere.infra.config.rule.global.event.DeleteGlobalRuleConfigurationEvent;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder;
import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
-import org.apache.shardingsphere.traffic.event.config.AddTrafficConfigurationEvent;
-import org.apache.shardingsphere.traffic.event.config.AlterTrafficConfigurationEvent;
-import org.apache.shardingsphere.traffic.event.config.DeleteTrafficConfigurationEvent;
+import org.apache.shardingsphere.traffic.rule.TrafficRule;
import org.apache.shardingsphere.traffic.yaml.config.YamlTrafficRuleConfiguration;
import org.apache.shardingsphere.traffic.yaml.swapper.YamlTrafficRuleConfigurationSwapper;
@@ -38,24 +38,23 @@ import java.util.Optional;
*/
public final class TrafficRuleConfigurationEventBuilder implements RuleConfigurationEventBuilder {
- private static final String SQL_FEDERATION = "sql_federation";
+ private static final String TRAFFIC = "traffic";
+
+ private static final String RULE_TYPE = TrafficRule.class.getSimpleName();
@Override
public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
- if (!GlobalRuleNodeConverter.isExpectedRuleName(SQL_FEDERATION, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
+ if (!GlobalRuleNodeConverter.isExpectedRuleName(TRAFFIC, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
return Optional.empty();
}
return buildGlobalClockRuleConfigurationEvent(databaseName, event);
}
private Optional<GovernanceEvent> buildGlobalClockRuleConfigurationEvent(final String databaseName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType()) {
- return Optional.of(new AddTrafficConfigurationEvent(databaseName, swapToConfig(event.getValue())));
- }
- if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterTrafficConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterGlobalRuleConfigurationEvent(databaseName, swapToConfig(event.getValue()), RULE_TYPE));
}
- return Optional.of(new DeleteTrafficConfigurationEvent(databaseName));
+ return Optional.of(new DeleteGlobalRuleConfigurationEvent(databaseName, RULE_TYPE));
}
private TrafficRuleConfiguration swapToConfig(final String yamlContext) {
diff --git a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/AddTrafficConfigurationEvent.java b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/AddTrafficConfigurationEvent.java
deleted file mode 100644
index 476085309e2..00000000000
--- a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/AddTrafficConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.traffic.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
-
-/**
- * Add traffic configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AddTrafficConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final TrafficRuleConfiguration config;
-}
diff --git a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/AlterTrafficConfigurationEvent.java b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/AlterTrafficConfigurationEvent.java
deleted file mode 100644
index 39901157bf8..00000000000
--- a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/AlterTrafficConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.traffic.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
-
-/**
- * Alter traffic configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AlterTrafficConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final TrafficRuleConfiguration config;
-}
diff --git a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/DeleteTrafficConfigurationEvent.java b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/DeleteTrafficConfigurationEvent.java
deleted file mode 100644
index d47bec5c35b..00000000000
--- a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/DeleteTrafficConfigurationEvent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.traffic.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Delete traffic configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class DeleteTrafficConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-}
diff --git a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/TransactionRuleConfigurationEventBuilder.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/TransactionRuleConfigurationEventBuilder.java
index a2422bf429b..97a7f4f4b23 100644
--- a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/TransactionRuleConfigurationEventBuilder.java
+++ b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/TransactionRuleConfigurationEventBuilder.java
@@ -19,15 +19,15 @@ package org.apache.shardingsphere.transaction.event;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.event.AlterGlobalRuleConfigurationEvent;
+import org.apache.shardingsphere.infra.config.rule.global.event.DeleteGlobalRuleConfigurationEvent;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder;
import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
-import org.apache.shardingsphere.transaction.event.config.AddTransactionConfigurationEvent;
-import org.apache.shardingsphere.transaction.event.config.AlterTransactionConfigurationEvent;
-import org.apache.shardingsphere.transaction.event.config.DeleteTransactionConfigurationEvent;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
import org.apache.shardingsphere.transaction.yaml.config.YamlTransactionRuleConfiguration;
import org.apache.shardingsphere.transaction.yaml.swapper.YamlTransactionRuleConfigurationSwapper;
@@ -40,6 +40,8 @@ public final class TransactionRuleConfigurationEventBuilder implements RuleConfi
private static final String TRANSACTION = "transaction";
+ private static final String RULE_TYPE = TransactionRule.class.getSimpleName();
+
@Override
public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
if (!GlobalRuleNodeConverter.isExpectedRuleName(TRANSACTION, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
@@ -49,13 +51,10 @@ public final class TransactionRuleConfigurationEventBuilder implements RuleConfi
}
private Optional<GovernanceEvent> buildGlobalClockRuleConfigurationEvent(final String databaseName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType()) {
- return Optional.of(new AddTransactionConfigurationEvent(databaseName, swapToConfig(event.getValue())));
- }
- if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterTransactionConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterGlobalRuleConfigurationEvent(databaseName, swapToConfig(event.getValue()), RULE_TYPE));
}
- return Optional.of(new DeleteTransactionConfigurationEvent(databaseName));
+ return Optional.of(new DeleteGlobalRuleConfigurationEvent(databaseName, RULE_TYPE));
}
private TransactionRuleConfiguration swapToConfig(final String yamlContext) {
diff --git a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/AddTransactionConfigurationEvent.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/AddTransactionConfigurationEvent.java
deleted file mode 100644
index 7ecdf425a54..00000000000
--- a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/AddTransactionConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.transaction.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
-
-/**
- * Add transaction configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AddTransactionConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final TransactionRuleConfiguration config;
-}
diff --git a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/AlterTransactionConfigurationEvent.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/AlterTransactionConfigurationEvent.java
deleted file mode 100644
index 5449c54b384..00000000000
--- a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/AlterTransactionConfigurationEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.transaction.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
-
-/**
- * Alter transaction configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AlterTransactionConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final TransactionRuleConfiguration config;
-}
diff --git a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/DeleteTransactionConfigurationEvent.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/DeleteTransactionConfigurationEvent.java
deleted file mode 100644
index 74198e2171a..00000000000
--- a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/DeleteTransactionConfigurationEvent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.transaction.event.config;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Delete transaction configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class DeleteTransactionConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/RuleConfigurationChangedEvent.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/DatabaseRuleConfigurationChangedEvent.java
similarity index 91%
rename from mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/RuleConfigurationChangedEvent.java
rename to mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/DatabaseRuleConfigurationChangedEvent.java
index a526b686692..d5754c79563 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/RuleConfigurationChangedEvent.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/DatabaseRuleConfigurationChangedEvent.java
@@ -22,11 +22,11 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
/**
- * Rule configuration changed event.
+ * Database rule configuration changed event.
*/
@Getter
@RequiredArgsConstructor
-public final class RuleConfigurationChangedEvent {
+public final class DatabaseRuleConfigurationChangedEvent {
private final String databaseName;
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/NewConfigurationChangedSubscriber.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/NewConfigurationChangedSubscriber.java
index bcbc6098e35..5d062591a17 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/NewConfigurationChangedSubscriber.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/NewConfigurationChangedSubscriber.java
@@ -18,13 +18,17 @@
package org.apache.shardingsphere.mode.manager.cluster.coordinator.subscriber;
import com.google.common.eventbus.Subscribe;
+import org.apache.shardingsphere.infra.config.rule.global.event.AlterGlobalRuleConfigurationEvent;
+import org.apache.shardingsphere.infra.config.rule.global.event.DeleteGlobalRuleConfigurationEvent;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder;
+import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import org.apache.shardingsphere.mode.manager.ContextManager;
import java.util.Collection;
+import java.util.Collections;
import java.util.LinkedList;
/**
@@ -41,8 +45,13 @@ public final class NewConfigurationChangedSubscriber {
contextManager.getInstanceContext().getEventBusContext().register(this);
}
+ /**
+ * Renew for database rule configuration.
+ *
+ * @param event database rule changed event
+ */
@Subscribe
- private synchronized void renew(final RuleConfigurationChangedEvent event) {
+ public synchronized void renew(final DatabaseRuleConfigurationChangedEvent event) {
String databaseName = event.getDatabaseName();
ShardingSphereDatabase database = contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName);
Collection<ShardingSphereRule> rules = new LinkedList<>(database.getRuleMetaData().getRules());
@@ -50,4 +59,43 @@ public final class NewConfigurationChangedSubscriber {
event.getRuleConfig(), contextManager.getInstanceContext()));
database.getRuleMetaData().getRules().addAll(rules);
}
+
+ /**
+ * Renew for global rule configuration.
+ *
+ * @param event global rule alter event
+ */
+ @Subscribe
+ public synchronized void renew(final AlterGlobalRuleConfigurationEvent event) {
+ ShardingSphereDatabase database = contextManager.getMetaDataContexts().getMetaData().getDatabase(event.getDatabaseName());
+ Collection<ShardingSphereRule> rules = removeSingleGlobalRule(database, event.getRuleSimpleName());
+ rules.addAll(GlobalRulesBuilder.buildRules(Collections.singletonList(event.getConfig()), contextManager.getMetaDataContexts().getMetaData().getDatabases(),
+ contextManager.getMetaDataContexts().getMetaData().getProps()));
+ database.getRuleMetaData().getRules().clear();
+ database.getRuleMetaData().getRules().addAll(rules);
+ }
+
+ /**
+ * Renew for global rule configuration.
+ *
+ * @param event global rule delete event
+ */
+ @Subscribe
+ public synchronized void renew(final DeleteGlobalRuleConfigurationEvent event) {
+ ShardingSphereDatabase database = contextManager.getMetaDataContexts().getMetaData().getDatabase(event.getDatabaseName());
+ Collection<ShardingSphereRule> rules = removeSingleGlobalRule(database, event.getRuleSimpleName());
+ database.getRuleMetaData().getRules().clear();
+ database.getRuleMetaData().getRules().addAll(rules);
+ }
+
+ private Collection<ShardingSphereRule> removeSingleGlobalRule(final ShardingSphereDatabase database, final String ruleSimpleName) {
+ Collection<ShardingSphereRule> result = new LinkedList<>(database.getRuleMetaData().getRules());
+ for (ShardingSphereRule each : result) {
+ if (!each.getType().equals(ruleSimpleName)) {
+ continue;
+ }
+ result.remove(each);
+ }
+ return result;
+ }
}