You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2023/06/12 06:48:52 UTC
[shardingsphere] branch master updated: Add global rule build event (#26269)
This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 0b9b78cd32f Add global rule build event (#26269)
0b9b78cd32f is described below
commit 0b9b78cd32feeec690872f8e8e0a29f95e571be5
Author: zhaojinchao <zh...@apache.org>
AuthorDate: Mon Jun 12 14:48:43 2023 +0800
Add global rule build event (#26269)
* Add global rule build event
* Fix checkstyle
* Fix unit test
* Complete global build watch event
* Fix checkstyle
* Fix ci
---
.../EncryptRuleConfigurationEventBuilder.java | 2 +-
.../event/MaskRuleConfigurationEventBuilder.java | 2 +-
...gsphere.mode.spi.RuleConfigurationEventBuilder} | 0
...riteSplittingRuleConfigurationEventBuilder.java | 2 +-
...gsphere.mode.spi.RuleConfigurationEventBuilder} | 0
.../event/ShadowRuleConfigurationEventBuilder.java | 2 +-
.../global}/converter/GlobalRuleNodeConverter.java | 6 +-
.../converter/GlobalRuleNodeConverterTest.java | 5 +-
kernel/authority/core/pom.xml | 5 ++
.../AuthorityRuleConfigurationEventBuilder.java | 64 ++++++++++++++++++++++
.../config/AddAuthorityConfigurationEvent.java | 22 +++-----
.../config/AlterAuthorityConfigurationEvent.java | 22 +++-----
.../config/DeleteAuthorityConfigurationEvent.java | 21 ++-----
.../NewYamlAuthorityRuleConfigurationSwapper.java | 2 +-
...ngsphere.mode.spi.RuleConfigurationEventBuilder | 3 +-
.../GlobalClockRuleConfigurationEventBuilder.java | 64 ++++++++++++++++++++++
.../config/AddGlobalClockConfigurationEvent.java | 22 +++-----
.../config/AlterGlobalClockConfigurationEvent.java | 22 +++-----
.../DeleteGlobalClockConfigurationEvent.java | 21 ++-----
...NewYamlGlobalClockRuleConfigurationSwapper.java | 2 +-
...ngsphere.mode.spi.RuleConfigurationEventBuilder | 2 +-
kernel/logging/core/pom.xml | 5 ++
.../LoggingRuleConfigurationEventBuilder.java | 64 ++++++++++++++++++++++
.../event/config/AddLoggingConfigurationEvent.java | 22 +++-----
.../config/AlterLoggingConfigurationEvent.java | 22 +++-----
.../config/DeleteLoggingConfigurationEvent.java | 21 ++-----
.../NewYamlLoggingRuleConfigurationSwapper.java | 2 +-
...ngsphere.mode.spi.RuleConfigurationEventBuilder | 2 +-
.../event/SingleRuleConfigurationEventBuilder.java | 64 ++++++++++++++++++++++
.../event/config/AddSingleConfigurationEvent.java | 22 +++-----
.../config/AlterSingleConfigurationEvent.java | 22 +++-----
.../config/DeleteSingleConfigurationEvent.java | 21 ++-----
.../NewYamlSingleRuleConfigurationSwapper.java | 2 +-
...ngsphere.mode.spi.RuleConfigurationEventBuilder | 2 +-
...SQLFederationRuleConfigurationEventBuilder.java | 64 ++++++++++++++++++++++
.../config/AddSQLFederationConfigurationEvent.java | 22 +++-----
.../AlterSQLFederationConfigurationEvent.java | 22 +++-----
.../DeleteSQLFederationConfigurationEvent.java | 21 ++-----
...wYamlSQLFederationRuleConfigurationSwapper.java | 2 +-
...ngsphere.mode.spi.RuleConfigurationEventBuilder | 2 +-
kernel/sql-parser/core/pom.xml | 5 ++
.../SQLParserRuleConfigurationEventBuilder.java | 64 ++++++++++++++++++++++
.../config/AddSQLParserConfigurationEvent.java | 22 +++-----
.../config/AlterSQLParserConfigurationEvent.java | 22 +++-----
.../config/DeleteSQLParserConfigurationEvent.java | 21 ++-----
.../NewYamlSQLParserRuleConfigurationSwapper.java | 2 +-
...ngsphere.mode.spi.RuleConfigurationEventBuilder | 2 +-
kernel/sql-translator/core/pom.xml | 5 ++
.../SQLTranslatorConfigurationEventBuilder.java | 64 ++++++++++++++++++++++
.../config/AddSQLTranslatorConfigurationEvent.java | 22 +++-----
.../AlterSQLTranslatorConfigurationEvent.java | 22 +++-----
.../DeleteSQLTranslatorConfigurationEvent.java | 21 ++-----
...wYamlSQLTranslatorRuleConfigurationSwapper.java | 2 +-
...ngsphere.mode.spi.RuleConfigurationEventBuilder | 2 +-
.../TrafficRuleConfigurationEventBuilder.java | 64 ++++++++++++++++++++++
.../event/config/AddTrafficConfigurationEvent.java | 22 +++-----
.../config/AlterTrafficConfigurationEvent.java | 22 +++-----
.../config/DeleteTrafficConfigurationEvent.java | 21 ++-----
.../NewYamlTrafficRuleConfigurationSwapper.java | 2 +-
...ngsphere.mode.spi.RuleConfigurationEventBuilder | 2 +-
.../TransactionRuleConfigurationEventBuilder.java | 64 ++++++++++++++++++++++
.../config/AddTransactionConfigurationEvent.java | 22 +++-----
.../config/AlterTransactionConfigurationEvent.java | 22 +++-----
.../DeleteTransactionConfigurationEvent.java | 21 ++-----
...NewYamlTransactionRuleConfigurationSwapper.java | 2 +-
...ngsphere.mode.spi.RuleConfigurationEventBuilder | 2 +-
.../mode/event/DataChangedEvent.java | 0
.../mode/spi}/RuleConfigurationEventBuilder.java | 2 +-
.../watcher/NewMetaDataChangedWatcher.java | 2 +-
69 files changed, 798 insertions(+), 443 deletions(-)
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/EncryptRuleConfigurationEventBuilder.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/EncryptRuleConfigurationEventBuilder.java
index d9b8f934d13..b8e395a5091 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/EncryptRuleConfigurationEventBuilder.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/EncryptRuleConfigurationEventBuilder.java
@@ -35,7 +35,7 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmC
import org.apache.shardingsphere.infra.yaml.config.swapper.algorithm.YamlAlgorithmConfigurationSwapper;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder;
+import org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder;
import java.util.Optional;
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/MaskRuleConfigurationEventBuilder.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/MaskRuleConfigurationEventBuilder.java
index 75cb07648b7..0af602f7cd6 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/MaskRuleConfigurationEventBuilder.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/MaskRuleConfigurationEventBuilder.java
@@ -35,7 +35,7 @@ import org.apache.shardingsphere.mask.yaml.config.YamlMaskRuleConfiguration;
import org.apache.shardingsphere.mask.yaml.swapper.YamlMaskRuleConfigurationSwapper;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder;
+import org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder;
import java.util.Optional;
diff --git a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder b/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
similarity index 100%
copy from features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
copy to features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/ReadwriteSplittingRuleConfigurationEventBuilder.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/ReadwriteSplittingRuleConfigurationEventBuilder.java
index 69773133252..bfaa1cd10c5 100644
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/ReadwriteSplittingRuleConfigurationEventBuilder.java
+++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/ReadwriteSplittingRuleConfigurationEventBuilder.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmC
import org.apache.shardingsphere.infra.yaml.config.swapper.algorithm.YamlAlgorithmConfigurationSwapper;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder;
+import org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder;
import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.event.config.AddReadwriteSplittingConfigurationEvent;
import org.apache.shardingsphere.readwritesplitting.event.config.AlterReadwriteSplittingConfigurationEvent;
diff --git a/features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder b/features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
similarity index 100%
rename from features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
rename to features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleConfigurationEventBuilder.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleConfigurationEventBuilder.java
index afa6500b8d5..88642c63573 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleConfigurationEventBuilder.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleConfigurationEventBuilder.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmC
import org.apache.shardingsphere.infra.yaml.config.swapper.algorithm.YamlAlgorithmConfigurationSwapper;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder;
+import org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder;
import org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
import org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
import org.apache.shardingsphere.shadow.event.algorithm.AddShadowAlgorithmEvent;
diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/converter/GlobalRuleNodeConverter.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/global/converter/GlobalRuleNodeConverter.java
similarity index 92%
rename from infra/common/src/main/java/org/apache/shardingsphere/infra/converter/GlobalRuleNodeConverter.java
rename to infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/global/converter/GlobalRuleNodeConverter.java
index 04da98a6f99..b218564e2e6 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/converter/GlobalRuleNodeConverter.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/global/converter/GlobalRuleNodeConverter.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.converter;
+package org.apache.shardingsphere.infra.config.rule.global.converter;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -62,13 +62,13 @@ public final class GlobalRuleNodeConverter {
}
/**
- * Is expect rule name.
+ * Is expected rule name.
*
* @param ruleName rule name
* @param rulePath rule path
* @return true or false
*/
- public static boolean isExpectRuleName(final String ruleName, final String rulePath) {
+ public static boolean isExpectedRuleName(final String ruleName, final String rulePath) {
Pattern pattern = Pattern.compile(getRootNode(ruleName) + "\\.*", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(rulePath);
return matcher.find();
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/converter/GlobalRuleNodeConverterTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/converter/GlobalRuleNodeConverterTest.java
index c7d911bffdb..279a9262377 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/converter/GlobalRuleNodeConverterTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/converter/GlobalRuleNodeConverterTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.infra.converter;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
import org.junit.jupiter.api.Test;
import java.util.Optional;
@@ -40,7 +41,7 @@ class GlobalRuleNodeConverterTest {
}
@Test
- void assertIsExpectRuleName() {
- assertTrue(GlobalRuleNodeConverter.isExpectRuleName("transaction", "/rules/transaction/versions/0"));
+ void assertIsExpectedRuleName() {
+ assertTrue(GlobalRuleNodeConverter.isExpectedRuleName("transaction", "/rules/transaction/versions/0"));
}
}
diff --git a/kernel/authority/core/pom.xml b/kernel/authority/core/pom.xml
index 613c2a19b16..19aa6a3cc12 100644
--- a/kernel/authority/core/pom.xml
+++ b/kernel/authority/core/pom.xml
@@ -38,6 +38,11 @@
<artifactId>shardingsphere-infra-executor</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-mode-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
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
new file mode 100644
index 00000000000..4c2d44c1c28
--- /dev/null
+++ b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/AuthorityRuleConfigurationEventBuilder.java
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+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.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.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 java.util.Optional;
+
+/**
+ * Authority rule configuration event builder.
+ */
+public final class AuthorityRuleConfigurationEventBuilder implements RuleConfigurationEventBuilder {
+
+ private static final String AUTHORITY = "authority";
+
+ @Override
+ public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
+ if (!GlobalRuleNodeConverter.isExpectedRuleName(AUTHORITY, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
+ return Optional.empty();
+ }
+ return buildAuthorityRuleConfigurationEvent(databaseName, event);
+ }
+
+ 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())));
+ }
+ return Optional.of(new DeleteAuthorityConfigurationEvent(databaseName));
+ }
+
+ private AuthorityRuleConfiguration swapToConfig(final String yamlContext) {
+ return new YamlAuthorityRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlAuthorityRuleConfiguration.class));
+ }
+}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/AddAuthorityConfigurationEvent.java
similarity index 69%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/AddAuthorityConfigurationEvent.java
index abc13dd4fc8..2f182b7fe09 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/AddAuthorityConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Add authority configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AddAuthorityConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final AuthorityRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/AlterAuthorityConfigurationEvent.java
similarity index 68%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/AlterAuthorityConfigurationEvent.java
index abc13dd4fc8..a94d0a165e7 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/AlterAuthorityConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Alter authority configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AlterAuthorityConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final AuthorityRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/DeleteAuthorityConfigurationEvent.java
similarity index 73%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/DeleteAuthorityConfigurationEvent.java
index abc13dd4fc8..72d3439e150 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/event/config/DeleteAuthorityConfigurationEvent.java
@@ -15,29 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+package org.apache.shardingsphere.authority.event.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Data changed event.
+ * Delete authority configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class DeleteAuthorityConfigurationEvent implements GovernanceEvent {
- private final String key;
-
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final String databaseName;
}
diff --git a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/NewYamlAuthorityRuleConfigurationSwapper.java b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/NewYamlAuthorityRuleConfigurationSwapper.java
index d1b2f87bc33..7cb322b755d 100644
--- a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/NewYamlAuthorityRuleConfigurationSwapper.java
+++ b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/NewYamlAuthorityRuleConfigurationSwapper.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.authority.converter.YamlUsersConfigurationConve
import org.apache.shardingsphere.authority.rule.builder.DefaultAuthorityRuleConfigurationBuilder;
import org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
-import org.apache.shardingsphere.infra.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
diff --git a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder b/kernel/authority/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
similarity index 90%
copy from features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
copy to kernel/authority/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
index 71d30521709..a0cef66e463 100644
--- a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
+++ b/kernel/authority/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
@@ -15,4 +15,5 @@
# limitations under the License.
#
-org.apache.shardingsphere.mask.event.MaskRuleConfigurationEventBuilder
+org.apache.shardingsphere.authority.event.AuthorityRuleConfigurationEventBuilder
+
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
new file mode 100644
index 00000000000..c8738d84673
--- /dev/null
+++ b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/GlobalClockRuleConfigurationEventBuilder.java
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+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.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.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 java.util.Optional;
+
+/**
+ * Global clock rule configuration event builder.
+ */
+public final class GlobalClockRuleConfigurationEventBuilder implements RuleConfigurationEventBuilder {
+
+ private static final String GLOBAL_CLOCK = "global_clock";
+
+ @Override
+ public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
+ if (!GlobalRuleNodeConverter.isExpectedRuleName(GLOBAL_CLOCK, 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 AddGlobalClockConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ }
+ if (Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterGlobalClockConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ }
+ return Optional.of(new DeleteGlobalClockConfigurationEvent(databaseName));
+ }
+
+ private GlobalClockRuleConfiguration swapToConfig(final String yamlContext) {
+ return new YamlGlobalClockRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlGlobalClockRuleConfiguration.class));
+ }
+}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/AddGlobalClockConfigurationEvent.java
similarity index 67%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/AddGlobalClockConfigurationEvent.java
index abc13dd4fc8..7ed39dce8bf 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/AddGlobalClockConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Add global clock configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AddGlobalClockConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final GlobalClockRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/AlterGlobalClockConfigurationEvent.java
similarity index 67%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/AlterGlobalClockConfigurationEvent.java
index abc13dd4fc8..5883cc39ff5 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/AlterGlobalClockConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Alter global clock configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AlterGlobalClockConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final GlobalClockRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/DeleteGlobalClockConfigurationEvent.java
similarity index 73%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/DeleteGlobalClockConfigurationEvent.java
index abc13dd4fc8..d285429b08b 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/event/config/DeleteGlobalClockConfigurationEvent.java
@@ -15,29 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+package org.apache.shardingsphere.globalclock.core.event.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Data changed event.
+ * Delete global clock configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class DeleteGlobalClockConfigurationEvent implements GovernanceEvent {
- private final String key;
-
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final String databaseName;
}
diff --git a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/swapper/NewYamlGlobalClockRuleConfigurationSwapper.java b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/swapper/NewYamlGlobalClockRuleConfigurationSwapper.java
index 59ee11a7af5..0ee2901dfcc 100644
--- a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/swapper/NewYamlGlobalClockRuleConfigurationSwapper.java
+++ b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/swapper/NewYamlGlobalClockRuleConfigurationSwapper.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.globalclock.core.yaml.swapper;
import org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
import org.apache.shardingsphere.globalclock.core.rule.constant.GlobalClockOrder;
import org.apache.shardingsphere.globalclock.core.yaml.config.YamlGlobalClockRuleConfiguration;
-import org.apache.shardingsphere.infra.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
diff --git a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder b/kernel/global-clock/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
similarity index 89%
copy from features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
copy to kernel/global-clock/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
index 71d30521709..9ee04b75cd0 100644
--- a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
+++ b/kernel/global-clock/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.mask.event.MaskRuleConfigurationEventBuilder
+org.apache.shardingsphere.globalclock.core.event.GlobalClockRuleConfigurationEventBuilder
diff --git a/kernel/logging/core/pom.xml b/kernel/logging/core/pom.xml
index 2c05f10face..91c02bb906d 100644
--- a/kernel/logging/core/pom.xml
+++ b/kernel/logging/core/pom.xml
@@ -33,6 +33,11 @@
<artifactId>shardingsphere-logging-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-mode-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
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
new file mode 100644
index 00000000000..08a007f576a
--- /dev/null
+++ b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/LoggingRuleConfigurationEventBuilder.java
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+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.yaml.config.YamlLoggingRuleConfiguration;
+import org.apache.shardingsphere.logging.yaml.swapper.YamlLoggingRuleConfigurationSwapper;
+import org.apache.shardingsphere.mode.event.DataChangedEvent;
+import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
+import org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder;
+
+import java.util.Optional;
+
+/**
+ * Logging rule configuration event builder.
+ */
+public final class LoggingRuleConfigurationEventBuilder implements RuleConfigurationEventBuilder {
+
+ private static final String LOGGING = "logging";
+
+ @Override
+ public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
+ if (!GlobalRuleNodeConverter.isExpectedRuleName(LOGGING, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
+ return Optional.empty();
+ }
+ return buildLoggingRuleConfigurationEvent(databaseName, event);
+ }
+
+ 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())));
+ }
+ return Optional.of(new DeleteLoggingConfigurationEvent(databaseName));
+ }
+
+ private LoggingRuleConfiguration swapToConfig(final String yamlContext) {
+ return new YamlLoggingRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlLoggingRuleConfiguration.class));
+ }
+}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/AddLoggingConfigurationEvent.java
similarity index 69%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/AddLoggingConfigurationEvent.java
index abc13dd4fc8..469f02f1e46 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/AddLoggingConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Add logging configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AddLoggingConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final LoggingRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/AlterLoggingConfigurationEvent.java
similarity index 69%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/AlterLoggingConfigurationEvent.java
index abc13dd4fc8..c6b38a6a8e2 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/AlterLoggingConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Alter logging configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AlterLoggingConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final LoggingRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/DeleteLoggingConfigurationEvent.java
similarity index 73%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/DeleteLoggingConfigurationEvent.java
index abc13dd4fc8..ddfe9447cdf 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/event/config/DeleteLoggingConfigurationEvent.java
@@ -15,29 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+package org.apache.shardingsphere.logging.event.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Data changed event.
+ * Delete logging configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class DeleteLoggingConfigurationEvent implements GovernanceEvent {
- private final String key;
-
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final String databaseName;
}
diff --git a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/swapper/NewYamlLoggingRuleConfigurationSwapper.java b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/swapper/NewYamlLoggingRuleConfigurationSwapper.java
index 9607725e68e..1f5e54262f7 100644
--- a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/swapper/NewYamlLoggingRuleConfigurationSwapper.java
+++ b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/swapper/NewYamlLoggingRuleConfigurationSwapper.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.logging.yaml.swapper;
-import org.apache.shardingsphere.infra.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
diff --git a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder b/kernel/logging/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
similarity index 91%
copy from features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
copy to kernel/logging/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
index 71d30521709..4370340f01a 100644
--- a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
+++ b/kernel/logging/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.mask.event.MaskRuleConfigurationEventBuilder
+org.apache.shardingsphere.logging.event.LoggingRuleConfigurationEventBuilder
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
new file mode 100644
index 00000000000..06f2b95644d
--- /dev/null
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleConfigurationEventBuilder.java
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+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.yaml.config.pojo.YamlSingleRuleConfiguration;
+import org.apache.shardingsphere.single.yaml.config.swapper.YamlSingleRuleConfigurationSwapper;
+
+import java.util.Optional;
+
+/**
+ * Single rule configuration event builder.
+ */
+public final class SingleRuleConfigurationEventBuilder implements RuleConfigurationEventBuilder {
+
+ private static final String SINGLE = "single";
+
+ @Override
+ public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
+ if (!GlobalRuleNodeConverter.isExpectedRuleName(SINGLE, event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
+ return Optional.empty();
+ }
+ return buildAuthorityRuleConfigurationEvent(databaseName, event);
+ }
+
+ 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())));
+ }
+ return Optional.of(new DeleteSingleConfigurationEvent(databaseName));
+ }
+
+ private SingleRuleConfiguration swapToConfig(final String yamlContext) {
+ return new YamlSingleRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlSingleRuleConfiguration.class));
+ }
+}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/AddSingleConfigurationEvent.java
similarity index 69%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/AddSingleConfigurationEvent.java
index abc13dd4fc8..42b86a819dd 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/AddSingleConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Add single configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AddSingleConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final SingleRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/AlterSingleConfigurationEvent.java
similarity index 69%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/AlterSingleConfigurationEvent.java
index abc13dd4fc8..3e815189af7 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/AlterSingleConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Alter single configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AlterSingleConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final SingleRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/DeleteSingleConfigurationEvent.java
similarity index 73%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/DeleteSingleConfigurationEvent.java
index abc13dd4fc8..9bf54325299 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/DeleteSingleConfigurationEvent.java
@@ -15,29 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+package org.apache.shardingsphere.single.event.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Data changed event.
+ * Delete single configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class DeleteSingleConfigurationEvent implements GovernanceEvent {
- private final String key;
-
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final String databaseName;
}
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
index 599f4e88fec..83f60b3fd18 100644
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.single.yaml.config.swapper;
-import org.apache.shardingsphere.infra.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
diff --git a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder b/kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
similarity index 91%
copy from features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
copy to kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
index 71d30521709..536551f1141 100644
--- a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
+++ b/kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.mask.event.MaskRuleConfigurationEventBuilder
+org.apache.shardingsphere.single.event.SingleRuleConfigurationEventBuilder
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
new file mode 100644
index 00000000000..ea370eae02b
--- /dev/null
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/SQLFederationRuleConfigurationEventBuilder.java
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+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.yaml.config.YamlSQLFederationRuleConfiguration;
+import org.apache.shardingsphere.sqlfederation.yaml.swapper.YamlSQLFederationRuleConfigurationSwapper;
+
+import java.util.Optional;
+
+/**
+ * SQL federation rule configuration event builder.
+ */
+public final class SQLFederationRuleConfigurationEventBuilder implements RuleConfigurationEventBuilder {
+
+ private static final String SQL_FEDERATION = "sql_federation";
+
+ @Override
+ public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
+ if (!GlobalRuleNodeConverter.isExpectedRuleName(SQL_FEDERATION, 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 AddSQLFederationConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ }
+ if (Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterSQLFederationConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ }
+ return Optional.of(new DeleteSQLFederationConfigurationEvent(databaseName));
+ }
+
+ private SQLFederationRuleConfiguration swapToConfig(final String yamlContext) {
+ return new YamlSQLFederationRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlSQLFederationRuleConfiguration.class));
+ }
+}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/AddSQLFederationConfigurationEvent.java
similarity index 67%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/AddSQLFederationConfigurationEvent.java
index abc13dd4fc8..19cc0a09dc3 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/AddSQLFederationConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Add sql federation configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AddSQLFederationConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final SQLFederationRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/AlterSQLFederationConfigurationEvent.java
similarity index 67%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/AlterSQLFederationConfigurationEvent.java
index abc13dd4fc8..564d95c7370 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/AlterSQLFederationConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Alter sql federation configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AlterSQLFederationConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final SQLFederationRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/DeleteSQLFederationConfigurationEvent.java
similarity index 73%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/DeleteSQLFederationConfigurationEvent.java
index abc13dd4fc8..8af4af0aa3c 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/event/config/DeleteSQLFederationConfigurationEvent.java
@@ -15,29 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+package org.apache.shardingsphere.sqlfederation.event.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Data changed event.
+ * Delete sql federation configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class DeleteSQLFederationConfigurationEvent implements GovernanceEvent {
- private final String key;
-
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final String databaseName;
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/NewYamlSQLFederationRuleConfigurationSwapper.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/NewYamlSQLFederationRuleConfigurationSwapper.java
index b218f8e3082..df3e96af326 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/NewYamlSQLFederationRuleConfigurationSwapper.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/NewYamlSQLFederationRuleConfigurationSwapper.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sqlfederation.yaml.swapper;
-import org.apache.shardingsphere.infra.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
diff --git a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder b/kernel/sql-federation/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
similarity index 89%
copy from features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
copy to kernel/sql-federation/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
index 71d30521709..bd2dfd8a08d 100644
--- a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
+++ b/kernel/sql-federation/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.mask.event.MaskRuleConfigurationEventBuilder
+org.apache.shardingsphere.sqlfederation.event.SQLFederationRuleConfigurationEventBuilder
diff --git a/kernel/sql-parser/core/pom.xml b/kernel/sql-parser/core/pom.xml
index 724abe63d74..5f1d7c387a1 100644
--- a/kernel/sql-parser/core/pom.xml
+++ b/kernel/sql-parser/core/pom.xml
@@ -33,6 +33,11 @@
<artifactId>shardingsphere-sql-parser-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-mode-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra-parser</artifactId>
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
new file mode 100644
index 00000000000..f3b91fbbba8
--- /dev/null
+++ b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/SQLParserRuleConfigurationEventBuilder.java
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+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.yaml.config.YamlSQLParserRuleConfiguration;
+import org.apache.shardingsphere.parser.yaml.swapper.YamlSQLParserRuleConfigurationSwapper;
+
+import java.util.Optional;
+
+/**
+ * SQL parser rule configuration event builder.
+ */
+public final class SQLParserRuleConfigurationEventBuilder implements RuleConfigurationEventBuilder {
+
+ private static final String SQL_PARSER = "sql_parser";
+
+ @Override
+ public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
+ if (!GlobalRuleNodeConverter.isExpectedRuleName(SQL_PARSER, 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 AddSQLParserConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ }
+ if (Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterSQLParserConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ }
+ return Optional.of(new DeleteSQLParserConfigurationEvent(databaseName));
+ }
+
+ private SQLParserRuleConfiguration swapToConfig(final String yamlContext) {
+ return new YamlSQLParserRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlSQLParserRuleConfiguration.class));
+ }
+}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/AddSQLParserConfigurationEvent.java
similarity index 69%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/AddSQLParserConfigurationEvent.java
index abc13dd4fc8..a07548cebf5 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/AddSQLParserConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Add sql parser configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AddSQLParserConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final SQLParserRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/AlterSQLParserConfigurationEvent.java
similarity index 69%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/AlterSQLParserConfigurationEvent.java
index abc13dd4fc8..eb21d0edb16 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/AlterSQLParserConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Alter sql parser configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AlterSQLParserConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final SQLParserRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/DeleteSQLParserConfigurationEvent.java
similarity index 73%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/DeleteSQLParserConfigurationEvent.java
index abc13dd4fc8..dd8afaefea9 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/event/config/DeleteSQLParserConfigurationEvent.java
@@ -15,29 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+package org.apache.shardingsphere.parser.event.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Data changed event.
+ * Delete sql parser configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class DeleteSQLParserConfigurationEvent implements GovernanceEvent {
- private final String key;
-
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final String databaseName;
}
diff --git a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/swapper/NewYamlSQLParserRuleConfigurationSwapper.java b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/swapper/NewYamlSQLParserRuleConfigurationSwapper.java
index 6dfb860f161..4cc791f706c 100644
--- a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/swapper/NewYamlSQLParserRuleConfigurationSwapper.java
+++ b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/swapper/NewYamlSQLParserRuleConfigurationSwapper.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.parser.yaml.swapper;
-import org.apache.shardingsphere.infra.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
diff --git a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder b/kernel/sql-parser/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
similarity index 90%
copy from features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
copy to kernel/sql-parser/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
index 71d30521709..058ff9152e4 100644
--- a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
+++ b/kernel/sql-parser/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.mask.event.MaskRuleConfigurationEventBuilder
+org.apache.shardingsphere.parser.event.SQLParserRuleConfigurationEventBuilder
diff --git a/kernel/sql-translator/core/pom.xml b/kernel/sql-translator/core/pom.xml
index 7d00c78bc3a..21e2200ced9 100644
--- a/kernel/sql-translator/core/pom.xml
+++ b/kernel/sql-translator/core/pom.xml
@@ -33,5 +33,10 @@
<artifactId>shardingsphere-sql-translator-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-mode-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
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
new file mode 100644
index 00000000000..f43387eb9cf
--- /dev/null
+++ b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/SQLTranslatorConfigurationEventBuilder.java
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+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.yaml.config.YamlSQLTranslatorRuleConfiguration;
+import org.apache.shardingsphere.sqltranslator.yaml.swapper.YamlSQLTranslatorRuleConfigurationSwapper;
+
+import java.util.Optional;
+
+/**
+ * SQL parser rule configuration event builder.
+ */
+public final class SQLTranslatorConfigurationEventBuilder implements RuleConfigurationEventBuilder {
+
+ private static final String SQL_TRANSLATOR = "sql_translator";
+
+ @Override
+ public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
+ if (!GlobalRuleNodeConverter.isExpectedRuleName(SQL_TRANSLATOR, 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 AddSQLTranslatorConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ }
+ if (Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterSQLTranslatorConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ }
+ return Optional.of(new DeleteSQLTranslatorConfigurationEvent(databaseName));
+ }
+
+ private SQLTranslatorRuleConfiguration swapToConfig(final String yamlContext) {
+ return new YamlSQLTranslatorRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlSQLTranslatorRuleConfiguration.class));
+ }
+}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/AddSQLTranslatorConfigurationEvent.java
similarity index 67%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/AddSQLTranslatorConfigurationEvent.java
index abc13dd4fc8..cf21d6327f6 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/AddSQLTranslatorConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Add sql translator configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AddSQLTranslatorConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final SQLTranslatorRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/AlterSQLTranslatorConfigurationEvent.java
similarity index 67%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/AlterSQLTranslatorConfigurationEvent.java
index abc13dd4fc8..0d98cbf7599 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/AlterSQLTranslatorConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Alter sql translator configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AlterSQLTranslatorConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final SQLTranslatorRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/DeleteSQLTranslatorConfigurationEvent.java
similarity index 73%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/DeleteSQLTranslatorConfigurationEvent.java
index abc13dd4fc8..37384db611e 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/event/config/DeleteSQLTranslatorConfigurationEvent.java
@@ -15,29 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+package org.apache.shardingsphere.sqltranslator.event.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Data changed event.
+ * Delete sql translator configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class DeleteSQLTranslatorConfigurationEvent implements GovernanceEvent {
- private final String key;
-
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final String databaseName;
}
diff --git a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/swapper/NewYamlSQLTranslatorRuleConfigurationSwapper.java b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/swapper/NewYamlSQLTranslatorRuleConfigurationSwapper.java
index 49f7f377ddd..0931e498c8d 100644
--- a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/swapper/NewYamlSQLTranslatorRuleConfigurationSwapper.java
+++ b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/swapper/NewYamlSQLTranslatorRuleConfigurationSwapper.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sqltranslator.yaml.swapper;
-import org.apache.shardingsphere.infra.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
diff --git a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder b/kernel/sql-translator/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
similarity index 90%
copy from features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
copy to kernel/sql-translator/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
index 71d30521709..c35e2a25846 100644
--- a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
+++ b/kernel/sql-translator/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.mask.event.MaskRuleConfigurationEventBuilder
+org.apache.shardingsphere.sqltranslator.event.SQLTranslatorConfigurationEventBuilder
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
new file mode 100644
index 00000000000..f96247d1fae
--- /dev/null
+++ b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/TrafficRuleConfigurationEventBuilder.java
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+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.yaml.config.YamlTrafficRuleConfiguration;
+import org.apache.shardingsphere.traffic.yaml.swapper.YamlTrafficRuleConfigurationSwapper;
+
+import java.util.Optional;
+
+/**
+ * Traffic rule configuration event builder.
+ */
+public final class TrafficRuleConfigurationEventBuilder implements RuleConfigurationEventBuilder {
+
+ private static final String SQL_FEDERATION = "sql_federation";
+
+ @Override
+ public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
+ if (!GlobalRuleNodeConverter.isExpectedRuleName(SQL_FEDERATION, 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())));
+ }
+ return Optional.of(new DeleteTrafficConfigurationEvent(databaseName));
+ }
+
+ private TrafficRuleConfiguration swapToConfig(final String yamlContext) {
+ return new YamlTrafficRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlTrafficRuleConfiguration.class));
+ }
+}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/AddTrafficConfigurationEvent.java
similarity index 69%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/AddTrafficConfigurationEvent.java
index abc13dd4fc8..476085309e2 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/AddTrafficConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Add traffic configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AddTrafficConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final TrafficRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/AlterTrafficConfigurationEvent.java
similarity index 69%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/AlterTrafficConfigurationEvent.java
index abc13dd4fc8..39901157bf8 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/AlterTrafficConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Alter traffic configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AlterTrafficConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final TrafficRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/DeleteTrafficConfigurationEvent.java
similarity index 73%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/DeleteTrafficConfigurationEvent.java
index abc13dd4fc8..d47bec5c35b 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/event/config/DeleteTrafficConfigurationEvent.java
@@ -15,29 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+package org.apache.shardingsphere.traffic.event.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Data changed event.
+ * Delete traffic configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class DeleteTrafficConfigurationEvent implements GovernanceEvent {
- private final String key;
-
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final String databaseName;
}
diff --git a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/swapper/NewYamlTrafficRuleConfigurationSwapper.java b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/swapper/NewYamlTrafficRuleConfigurationSwapper.java
index 43df38dfd21..f1fff7b0373 100644
--- a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/swapper/NewYamlTrafficRuleConfigurationSwapper.java
+++ b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/swapper/NewYamlTrafficRuleConfigurationSwapper.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.traffic.yaml.swapper;
-import org.apache.shardingsphere.infra.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.yaml.config.swapper.algorithm.YamlAlgorithmConfigurationSwapper;
diff --git a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder b/kernel/traffic/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
similarity index 91%
copy from features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
copy to kernel/traffic/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
index 71d30521709..a76730d6256 100644
--- a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
+++ b/kernel/traffic/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.mask.event.MaskRuleConfigurationEventBuilder
+org.apache.shardingsphere.traffic.event.TrafficRuleConfigurationEventBuilder
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
new file mode 100644
index 00000000000..a2422bf429b
--- /dev/null
+++ b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/TransactionRuleConfigurationEventBuilder.java
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+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.yaml.config.YamlTransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.yaml.swapper.YamlTransactionRuleConfigurationSwapper;
+
+import java.util.Optional;
+
+/**
+ * Transaction rule configuration event builder.
+ */
+public final class TransactionRuleConfigurationEventBuilder implements RuleConfigurationEventBuilder {
+
+ private static final String TRANSACTION = "transaction";
+
+ @Override
+ public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
+ if (!GlobalRuleNodeConverter.isExpectedRuleName(TRANSACTION, 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 AddTransactionConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ }
+ if (Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterTransactionConfigurationEvent(databaseName, swapToConfig(event.getValue())));
+ }
+ return Optional.of(new DeleteTransactionConfigurationEvent(databaseName));
+ }
+
+ private TransactionRuleConfiguration swapToConfig(final String yamlContext) {
+ return new YamlTransactionRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlTransactionRuleConfiguration.class));
+ }
+}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/AddTransactionConfigurationEvent.java
similarity index 68%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/AddTransactionConfigurationEvent.java
index abc13dd4fc8..7ecdf425a54 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/AddTransactionConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Add transaction configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AddTransactionConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final TransactionRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/AlterTransactionConfigurationEvent.java
similarity index 68%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/AlterTransactionConfigurationEvent.java
index abc13dd4fc8..5449c54b384 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/AlterTransactionConfigurationEvent.java
@@ -15,29 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+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;
/**
- * Data changed event.
+ * Alter transaction configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class AlterTransactionConfigurationEvent implements GovernanceEvent {
- private final String key;
+ private final String databaseName;
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final TransactionRuleConfiguration config;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/DeleteTransactionConfigurationEvent.java
similarity index 73%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
copy to kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/DeleteTransactionConfigurationEvent.java
index abc13dd4fc8..74198e2171a 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
+++ b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/event/config/DeleteTransactionConfigurationEvent.java
@@ -15,29 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event;
+package org.apache.shardingsphere.transaction.event.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Data changed event.
+ * Delete transaction configuration event.
*/
@RequiredArgsConstructor
@Getter
-public final class DataChangedEvent {
+public final class DeleteTransactionConfigurationEvent implements GovernanceEvent {
- private final String key;
-
- private final String value;
-
- private final Type type;
-
- /**
- * Data changed type.
- */
- public enum Type {
-
- ADDED, UPDATED, DELETED, IGNORED
- }
+ private final String databaseName;
}
diff --git a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/NewYamlTransactionRuleConfigurationSwapper.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/NewYamlTransactionRuleConfigurationSwapper.java
index 69bb043f965..bc7f8d5be47 100644
--- a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/NewYamlTransactionRuleConfigurationSwapper.java
+++ b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/NewYamlTransactionRuleConfigurationSwapper.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.transaction.yaml.swapper;
-import org.apache.shardingsphere.infra.converter.GlobalRuleNodeConverter;
+import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
diff --git a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder b/kernel/transaction/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
similarity index 90%
rename from features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
rename to kernel/transaction/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
index 71d30521709..2b0e3bb244e 100644
--- a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
+++ b/kernel/transaction/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.mask.event.MaskRuleConfigurationEventBuilder
+org.apache.shardingsphere.transaction.event.TransactionRuleConfigurationEventBuilder
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
similarity index 100%
rename from mode/core/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
rename to mode/api/src/main/java/org/apache/shardingsphere/mode/event/DataChangedEvent.java
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/RuleConfigurationEventBuilder.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RuleConfigurationEventBuilder.java
similarity index 96%
rename from mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/RuleConfigurationEventBuilder.java
rename to mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RuleConfigurationEventBuilder.java
index b922b46051b..97193794530 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/RuleConfigurationEventBuilder.java
+++ b/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RuleConfigurationEventBuilder.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event.config;
+package org.apache.shardingsphere.mode.spi;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/NewMetaDataChangedWatcher.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/NewMetaDataChangedWatcher.java
index 3918cd4d0d6..2b881667d03 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/NewMetaDataChangedWatcher.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/NewMetaDataChangedWatcher.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.meta
import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.metadata.persist.node.DatabaseMetaDataNode;
import org.apache.shardingsphere.metadata.persist.node.NewDatabaseMetaDataNode;
-import org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder;
+import org.apache.shardingsphere.mode.spi.RuleConfigurationEventBuilder;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.NewGovernanceWatcher;
import org.apache.shardingsphere.mode.event.DataChangedEvent;