You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2023/06/12 04:16:30 UTC
[shardingsphere] branch master updated: Add feature configuration changed event and subscribe at shadow module (#26270)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 d0a9d6a44b6 Add feature configuration changed event and subscribe at shadow module (#26270)
d0a9d6a44b6 is described below
commit d0a9d6a44b627673c1c4b0d082324486399769c8
Author: ChenJiaHao <Pa...@163.com>
AuthorDate: Mon Jun 12 12:16:22 2023 +0800
Add feature configuration changed event and subscribe at shadow module (#26270)
---
.../subscriber/MaskConfigurationSubscriber.java | 3 +-
.../ReadwriteSplittingConfigurationSubscriber.java | 3 +-
features/shadow/core/pom.xml | 6 +-
.../event/ShadowRuleConfigurationEventBuilder.java | 114 +++++++++++++++++++++
.../event/algorithm/AddShadowAlgorithmEvent.java | 38 +++++++
.../event/algorithm/AlterShadowAlgorithmEvent.java | 38 +++++++
.../algorithm/DeleteShadowAlgorithmEvent.java | 34 ++++++
.../event/config/AddShadowConfigurationEvent.java | 36 +++++++
.../config/AlterShadowConfigurationEvent.java | 38 +++++++
.../config/DeleteShadowConfigurationEvent.java | 34 ++++++
.../shadow/event/table/AddShadowTableEvent.java | 38 +++++++
.../shadow/event/table/AlterShadowTableEvent.java | 38 +++++++
.../shadow/event/table/DeleteShadowTableEvent.java | 34 ++++++
.../subscriber/ShadowAlgorithmSubscriber.java | 101 ++++++++++++++++++
.../subscriber/ShadowConfigurationSubscriber.java} | 62 +++++------
.../shadow/subscriber/ShadowTableSubscriber.java | 101 ++++++++++++++++++
...nfra.rule.RuleConfigurationSubscribeCoordinator | 20 ++++
...mode.event.config.RuleConfigurationEventBuilder | 18 ++++
18 files changed, 723 insertions(+), 33 deletions(-)
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskConfigurationSubscriber.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskConfigurationSubscriber.java
index 666b6ca67a7..4b14adbcbef 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskConfigurationSubscriber.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskConfigurationSubscriber.java
@@ -90,7 +90,8 @@ public final class MaskConfigurationSubscriber implements RuleConfigurationSubsc
Collection<RuleConfiguration> ruleConfigs = new LinkedList<>(database.getRuleMetaData().getConfigurations());
MaskRuleConfiguration config = (MaskRuleConfiguration) database.getRuleMetaData().getSingleRule(MaskRule.class).getConfiguration();
config.getTables().removeIf(each -> each.getName().equals(event.getTableName()));
- ruleConfigs.add(new MaskRuleConfiguration(Collections.singletonList(needToAlteredConfig), Collections.emptyMap()));
+ config.getTables().add(needToAlteredConfig);
+ ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/subscriber/ReadwriteSplittingConfigurationSubscriber.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/subscriber/ReadwriteSplittingConfigurationSubscriber.java
index 5b3de785325..5e9d47c968c 100644
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/subscriber/ReadwriteSplittingConfigurationSubscriber.java
+++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/subscriber/ReadwriteSplittingConfigurationSubscriber.java
@@ -90,7 +90,8 @@ public final class ReadwriteSplittingConfigurationSubscriber implements RuleConf
Collection<RuleConfiguration> ruleConfigs = new LinkedList<>(database.getRuleMetaData().getConfigurations());
ReadwriteSplittingRuleConfiguration config = (ReadwriteSplittingRuleConfiguration) database.getRuleMetaData().getSingleRule(ReadwriteSplittingRule.class).getConfiguration();
config.getDataSources().removeIf(each -> each.getName().equals(event.getGroupName()));
- ruleConfigs.add(new ReadwriteSplittingRuleConfiguration(Collections.singletonList(needToAlteredConfig), Collections.emptyMap()));
+ config.getDataSources().add(needToAlteredConfig);
+ ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
diff --git a/features/shadow/core/pom.xml b/features/shadow/core/pom.xml
index 350042f9fb9..9e8c62e3f4a 100644
--- a/features/shadow/core/pom.xml
+++ b/features/shadow/core/pom.xml
@@ -33,7 +33,6 @@
<artifactId>shardingsphere-shadow-api</artifactId>
<version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra-binder</artifactId>
@@ -49,6 +48,11 @@
<artifactId>shardingsphere-infra-rewrite</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-mode-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
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
new file mode 100644
index 00000000000..afa6500b8d5
--- /dev/null
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleConfigurationEventBuilder.java
@@ -0,0 +1,114 @@
+/*
+ * 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.shadow.event;
+
+import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
+import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration;
+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.shadow.api.config.datasource.ShadowDataSourceConfiguration;
+import org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
+import org.apache.shardingsphere.shadow.event.algorithm.AddShadowAlgorithmEvent;
+import org.apache.shardingsphere.shadow.event.algorithm.AlterShadowAlgorithmEvent;
+import org.apache.shardingsphere.shadow.event.algorithm.DeleteShadowAlgorithmEvent;
+import org.apache.shardingsphere.shadow.event.config.AddShadowConfigurationEvent;
+import org.apache.shardingsphere.shadow.event.config.AlterShadowConfigurationEvent;
+import org.apache.shardingsphere.shadow.event.config.DeleteShadowConfigurationEvent;
+import org.apache.shardingsphere.shadow.event.table.AddShadowTableEvent;
+import org.apache.shardingsphere.shadow.event.table.AlterShadowTableEvent;
+import org.apache.shardingsphere.shadow.event.table.DeleteShadowTableEvent;
+import org.apache.shardingsphere.shadow.metadata.converter.ShadowNodeConverter;
+import org.apache.shardingsphere.shadow.yaml.config.YamlShadowRuleConfiguration;
+import org.apache.shardingsphere.shadow.yaml.config.table.YamlShadowTableConfiguration;
+import org.apache.shardingsphere.shadow.yaml.swapper.YamlShadowRuleConfigurationSwapper;
+import org.apache.shardingsphere.shadow.yaml.swapper.table.YamlShadowTableConfigurationSwapper;
+
+import java.util.Optional;
+
+/**
+ * Shadow rule configuration event builder.
+ */
+public final class ShadowRuleConfigurationEventBuilder implements RuleConfigurationEventBuilder {
+
+ @Override
+ public Optional<GovernanceEvent> build(final String databaseName, final DataChangedEvent event) {
+ if (!ShadowNodeConverter.isShadowPath(event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
+ return Optional.empty();
+ }
+ Optional<String> dataSourceName = ShadowNodeConverter.getDataSourceName(event.getKey());
+ if (dataSourceName.isPresent() && !Strings.isNullOrEmpty(event.getValue())) {
+ return createShadowConfigEvent(databaseName, dataSourceName.get(), event);
+ }
+ Optional<String> tableName = ShadowNodeConverter.getTableName(event.getKey());
+ if (tableName.isPresent() && !Strings.isNullOrEmpty(event.getValue())) {
+ return createShadowTableConfigEvent(databaseName, tableName.get(), event);
+ }
+ Optional<String> algorithmName = ShadowNodeConverter.getAlgorithmName(event.getKey());
+ if (algorithmName.isPresent() && !Strings.isNullOrEmpty(event.getValue())) {
+ return createShadowAlgorithmEvent(databaseName, algorithmName.get(), event);
+ }
+ return Optional.empty();
+ }
+
+ private Optional<GovernanceEvent> createShadowConfigEvent(final String databaseName, final String dataSourceName, final DataChangedEvent event) {
+ if (Type.ADDED == event.getType()) {
+ return Optional.of(new AddShadowConfigurationEvent<>(databaseName, swapShadowDataSourceRuleConfig(event.getValue())));
+ }
+ if (Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterShadowConfigurationEvent<>(databaseName, dataSourceName, swapShadowDataSourceRuleConfig(event.getValue())));
+ }
+ return Optional.of(new DeleteShadowConfigurationEvent(databaseName, dataSourceName));
+ }
+
+ private ShadowDataSourceConfiguration swapShadowDataSourceRuleConfig(final String yamlContext) {
+ return new YamlShadowRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlShadowRuleConfiguration.class)).getDataSources().iterator().next();
+ }
+
+ private Optional<GovernanceEvent> createShadowTableConfigEvent(final String databaseName, final String tableName, final DataChangedEvent event) {
+ if (Type.ADDED == event.getType()) {
+ return Optional.of(new AddShadowTableEvent<>(databaseName, tableName, swapToTableConfig(event.getValue())));
+ }
+ if (Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterShadowTableEvent<>(databaseName, tableName, swapToTableConfig(event.getValue())));
+ }
+ return Optional.of(new DeleteShadowTableEvent(databaseName, tableName));
+ }
+
+ private ShadowTableConfiguration swapToTableConfig(final String yamlContext) {
+ return new YamlShadowTableConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlShadowTableConfiguration.class));
+ }
+
+ private Optional<GovernanceEvent> createShadowAlgorithmEvent(final String databaseName, final String algorithmName, final DataChangedEvent event) {
+ if (Type.ADDED == event.getType()) {
+ return Optional.of(new AddShadowAlgorithmEvent<>(databaseName, algorithmName, swapToAlgorithmConfig(event.getValue())));
+ }
+ if (Type.UPDATED == event.getType()) {
+ return Optional.of(new AlterShadowAlgorithmEvent<>(databaseName, algorithmName, swapToAlgorithmConfig(event.getValue())));
+ }
+ return Optional.of(new DeleteShadowAlgorithmEvent(databaseName, algorithmName));
+ }
+
+ private AlgorithmConfiguration swapToAlgorithmConfig(final String yamlContext) {
+ return new YamlAlgorithmConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlAlgorithmConfiguration.class));
+ }
+}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/AddShadowAlgorithmEvent.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/AddShadowAlgorithmEvent.java
new file mode 100644
index 00000000000..5e7bf95137d
--- /dev/null
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/AddShadowAlgorithmEvent.java
@@ -0,0 +1,38 @@
+/*
+ * 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.shadow.event.algorithm;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
+
+/**
+ * Add shadow algorithm event.
+ *
+ * @param <T> algorithm configuration
+ */
+@RequiredArgsConstructor
+@Getter
+public final class AddShadowAlgorithmEvent<T> implements GovernanceEvent {
+
+ private final String databaseName;
+
+ private final String algorithmName;
+
+ private final T config;
+}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/AlterShadowAlgorithmEvent.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/AlterShadowAlgorithmEvent.java
new file mode 100644
index 00000000000..b0dc4e6d758
--- /dev/null
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/AlterShadowAlgorithmEvent.java
@@ -0,0 +1,38 @@
+/*
+ * 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.shadow.event.algorithm;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
+
+/**
+ * Alter shadow algorithm event.
+ *
+ * @param <T> algorithm configuration
+ */
+@RequiredArgsConstructor
+@Getter
+public final class AlterShadowAlgorithmEvent<T> implements GovernanceEvent {
+
+ private final String databaseName;
+
+ private final String algorithmName;
+
+ private final T config;
+}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/DeleteShadowAlgorithmEvent.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/DeleteShadowAlgorithmEvent.java
new file mode 100644
index 00000000000..8f4a2365ac5
--- /dev/null
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/DeleteShadowAlgorithmEvent.java
@@ -0,0 +1,34 @@
+/*
+ * 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.shadow.event.algorithm;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
+
+/**
+ * Delete shadow algorithm event.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class DeleteShadowAlgorithmEvent implements GovernanceEvent {
+
+ private final String databaseName;
+
+ private final String algorithmName;
+}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/config/AddShadowConfigurationEvent.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/config/AddShadowConfigurationEvent.java
new file mode 100644
index 00000000000..1c3ed61a382
--- /dev/null
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/config/AddShadowConfigurationEvent.java
@@ -0,0 +1,36 @@
+/*
+ * 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.shadow.event.config;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
+
+/**
+ * Add shadow configuration event.
+ *
+ * @param <T> shadow configuration
+ */
+@RequiredArgsConstructor
+@Getter
+public final class AddShadowConfigurationEvent<T> implements GovernanceEvent {
+
+ private final String databaseName;
+
+ private final T config;
+}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/config/AlterShadowConfigurationEvent.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/config/AlterShadowConfigurationEvent.java
new file mode 100644
index 00000000000..d517684f3da
--- /dev/null
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/config/AlterShadowConfigurationEvent.java
@@ -0,0 +1,38 @@
+/*
+ * 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.shadow.event.config;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
+
+/**
+ * Alter shadow configuration event.
+ *
+ * @param <T> shadow configuration
+ */
+@RequiredArgsConstructor
+@Getter
+public final class AlterShadowConfigurationEvent<T> implements GovernanceEvent {
+
+ private final String databaseName;
+
+ private final String dataSourceName;
+
+ private final T config;
+}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/config/DeleteShadowConfigurationEvent.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/config/DeleteShadowConfigurationEvent.java
new file mode 100644
index 00000000000..302bfd91a31
--- /dev/null
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/config/DeleteShadowConfigurationEvent.java
@@ -0,0 +1,34 @@
+/*
+ * 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.shadow.event.config;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
+
+/**
+ * Delete shadow configuration event.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class DeleteShadowConfigurationEvent implements GovernanceEvent {
+
+ private final String databaseName;
+
+ private final String dataSourceName;
+}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/table/AddShadowTableEvent.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/table/AddShadowTableEvent.java
new file mode 100644
index 00000000000..3c0dcd931ed
--- /dev/null
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/table/AddShadowTableEvent.java
@@ -0,0 +1,38 @@
+/*
+ * 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.shadow.event.table;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
+
+/**
+ * Add shadow table event.
+ *
+ * @param <T> shadow table configuration
+ */
+@RequiredArgsConstructor
+@Getter
+public final class AddShadowTableEvent<T> implements GovernanceEvent {
+
+ private final String databaseName;
+
+ private final String tableName;
+
+ private final T config;
+}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/table/AlterShadowTableEvent.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/table/AlterShadowTableEvent.java
new file mode 100644
index 00000000000..fdd1cde035d
--- /dev/null
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/table/AlterShadowTableEvent.java
@@ -0,0 +1,38 @@
+/*
+ * 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.shadow.event.table;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
+
+/**
+ * Alter shadow table event.
+ *
+ * @param <T> shadow table configuration
+ */
+@RequiredArgsConstructor
+@Getter
+public final class AlterShadowTableEvent<T> implements GovernanceEvent {
+
+ private final String databaseName;
+
+ private final String tableName;
+
+ private final T config;
+}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/table/DeleteShadowTableEvent.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/table/DeleteShadowTableEvent.java
new file mode 100644
index 00000000000..583e0e4f662
--- /dev/null
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/table/DeleteShadowTableEvent.java
@@ -0,0 +1,34 @@
+/*
+ * 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.shadow.event.table;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
+
+/**
+ * Delete shadow table event.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class DeleteShadowTableEvent implements GovernanceEvent {
+
+ private final String databaseName;
+
+ private final String tableName;
+}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowAlgorithmSubscriber.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowAlgorithmSubscriber.java
new file mode 100644
index 00000000000..f75983ae153
--- /dev/null
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowAlgorithmSubscriber.java
@@ -0,0 +1,101 @@
+/*
+ * 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.shadow.subscriber;
+
+import com.google.common.eventbus.Subscribe;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
+import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator;
+import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
+import org.apache.shardingsphere.shadow.event.algorithm.AddShadowAlgorithmEvent;
+import org.apache.shardingsphere.shadow.event.algorithm.AlterShadowAlgorithmEvent;
+import org.apache.shardingsphere.shadow.event.algorithm.DeleteShadowAlgorithmEvent;
+import org.apache.shardingsphere.shadow.rule.ShadowRule;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Map;
+
+/**
+ * Shadow algorithm subscriber.
+ */
+@SuppressWarnings("UnstableApiUsage")
+@RequiredArgsConstructor
+public final class ShadowAlgorithmSubscriber implements RuleConfigurationSubscribeCoordinator {
+
+ private Map<String, ShardingSphereDatabase> databases;
+
+ private InstanceContext instanceContext;
+
+ @Override
+ public void registerRuleConfigurationSubscriber(final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext) {
+ this.databases = databases;
+ this.instanceContext = instanceContext;
+ instanceContext.getEventBusContext().register(this);
+ }
+
+ /**
+ * Renew with add algorithm.
+ *
+ * @param event add algorithm event
+ */
+ @Subscribe
+ public synchronized void renew(final AddShadowAlgorithmEvent<AlgorithmConfiguration> event) {
+ renew(event.getDatabaseName(), event.getAlgorithmName(), event.getConfig());
+ }
+
+ /**
+ * Renew with alter algorithm.
+ *
+ * @param event alter algorithm event
+ */
+ @Subscribe
+ public synchronized void renew(final AlterShadowAlgorithmEvent<AlgorithmConfiguration> event) {
+ renew(event.getDatabaseName(), event.getAlgorithmName(), event.getConfig());
+ }
+
+ private void renew(final String databaseName, final String algorithmName, final AlgorithmConfiguration algorithmConfig) {
+ ShardingSphereDatabase database = databases.get(databaseName);
+ Collection<RuleConfiguration> ruleConfigs = new LinkedList<>(database.getRuleMetaData().getConfigurations());
+ ShadowRuleConfiguration config = (ShadowRuleConfiguration) database.getRuleMetaData().getSingleRule(ShadowRule.class).getConfiguration();
+ config.getShadowAlgorithms().put(algorithmName, algorithmConfig);
+ ruleConfigs.add(config);
+ database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
+ instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(databaseName, config));
+ }
+
+ /**
+ * Renew with delete algorithm.
+ *
+ * @param event delete algorithm event
+ */
+ @Subscribe
+ public synchronized void renew(final DeleteShadowAlgorithmEvent event) {
+ ShardingSphereDatabase database = databases.get(event.getDatabaseName());
+ Collection<RuleConfiguration> ruleConfigs = new LinkedList<>(database.getRuleMetaData().getConfigurations());
+ ShadowRuleConfiguration config = (ShadowRuleConfiguration) database.getRuleMetaData().getSingleRule(ShadowRule.class).getConfiguration();
+ config.getShadowAlgorithms().remove(event.getAlgorithmName());
+ ruleConfigs.add(config);
+ database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
+ instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ }
+}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskConfigurationSubscriber.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowConfigurationSubscriber.java
similarity index 58%
copy from features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskConfigurationSubscriber.java
copy to features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowConfigurationSubscriber.java
index 666b6ca67a7..6515a576b10 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskConfigurationSubscriber.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowConfigurationSubscriber.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mask.subscriber;
+package org.apache.shardingsphere.shadow.subscriber;
import com.google.common.eventbus.Subscribe;
import lombok.RequiredArgsConstructor;
@@ -23,13 +23,13 @@ import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator;
-import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
-import org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
-import org.apache.shardingsphere.mask.event.config.AddMaskConfigurationEvent;
-import org.apache.shardingsphere.mask.event.config.AlterMaskConfigurationEvent;
-import org.apache.shardingsphere.mask.event.config.DeleteMaskConfigurationEvent;
-import org.apache.shardingsphere.mask.rule.MaskRule;
import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
+import org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
+import org.apache.shardingsphere.shadow.event.config.AddShadowConfigurationEvent;
+import org.apache.shardingsphere.shadow.event.config.AlterShadowConfigurationEvent;
+import org.apache.shardingsphere.shadow.event.config.DeleteShadowConfigurationEvent;
+import org.apache.shardingsphere.shadow.rule.ShadowRule;
import java.util.Collection;
import java.util.Collections;
@@ -38,11 +38,11 @@ import java.util.Map;
import java.util.Optional;
/**
- * Mask configuration subscriber.
+ * Shadow configuration subscriber.
*/
@SuppressWarnings("UnstableApiUsage")
@RequiredArgsConstructor
-public final class MaskConfigurationSubscriber implements RuleConfigurationSubscribeCoordinator {
+public final class ShadowConfigurationSubscriber implements RuleConfigurationSubscribeCoordinator {
private Map<String, ShardingSphereDatabase> databases;
@@ -56,22 +56,23 @@ public final class MaskConfigurationSubscriber implements RuleConfigurationSubsc
}
/**
- * Renew with add mask configuration.
+ * Renew with add shadow configuration.
*
- * @param event add mask configuration event
+ * @param event add shadow configuration event
*/
@Subscribe
- public synchronized void renew(final AddMaskConfigurationEvent<MaskTableRuleConfiguration> event) {
+ public synchronized void renew(final AddShadowConfigurationEvent<ShadowDataSourceConfiguration> event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- MaskTableRuleConfiguration needToAddedConfig = event.getConfig();
+ ShadowDataSourceConfiguration needToAddedConfig = event.getConfig();
Collection<RuleConfiguration> ruleConfigs = new LinkedList<>(database.getRuleMetaData().getConfigurations());
- Optional<MaskRule> rule = database.getRuleMetaData().findSingleRule(MaskRule.class);
- MaskRuleConfiguration config;
+ Optional<ShadowRule> rule = database.getRuleMetaData().findSingleRule(ShadowRule.class);
+ ShadowRuleConfiguration config;
if (rule.isPresent()) {
- config = (MaskRuleConfiguration) rule.get().getConfiguration();
- config.getTables().add(needToAddedConfig);
+ config = (ShadowRuleConfiguration) rule.get().getConfiguration();
+ config.getDataSources().add(needToAddedConfig);
} else {
- config = new MaskRuleConfiguration(Collections.singletonList(needToAddedConfig), Collections.emptyMap());
+ config = new ShadowRuleConfiguration();
+ config.setDataSources(Collections.singletonList(needToAddedConfig));
}
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
@@ -79,33 +80,34 @@ public final class MaskConfigurationSubscriber implements RuleConfigurationSubsc
}
/**
- * Renew with alter mask configuration.
+ * Renew with alter shadow configuration.
*
- * @param event alter mask configuration event
+ * @param event alter shadow configuration event
*/
@Subscribe
- public synchronized void renew(final AlterMaskConfigurationEvent<MaskTableRuleConfiguration> event) {
+ public synchronized void renew(final AlterShadowConfigurationEvent<ShadowDataSourceConfiguration> event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- MaskTableRuleConfiguration needToAlteredConfig = event.getConfig();
+ ShadowDataSourceConfiguration needToAlteredConfig = event.getConfig();
Collection<RuleConfiguration> ruleConfigs = new LinkedList<>(database.getRuleMetaData().getConfigurations());
- MaskRuleConfiguration config = (MaskRuleConfiguration) database.getRuleMetaData().getSingleRule(MaskRule.class).getConfiguration();
- config.getTables().removeIf(each -> each.getName().equals(event.getTableName()));
- ruleConfigs.add(new MaskRuleConfiguration(Collections.singletonList(needToAlteredConfig), Collections.emptyMap()));
+ ShadowRuleConfiguration config = (ShadowRuleConfiguration) database.getRuleMetaData().getSingleRule(ShadowRule.class).getConfiguration();
+ config.getDataSources().removeIf(each -> each.getName().equals(event.getDataSourceName()));
+ config.getDataSources().add(needToAlteredConfig);
+ ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
/**
- * Renew with delete mask configuration.
+ * Renew with delete shadow configuration.
*
- * @param event delete mask configuration event
+ * @param event delete shadow configuration event
*/
@Subscribe
- public synchronized void renew(final DeleteMaskConfigurationEvent event) {
+ public synchronized void renew(final DeleteShadowConfigurationEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
Collection<RuleConfiguration> ruleConfigs = new LinkedList<>(database.getRuleMetaData().getConfigurations());
- MaskRuleConfiguration config = (MaskRuleConfiguration) database.getRuleMetaData().getSingleRule(MaskRule.class).getConfiguration();
- config.getTables().removeIf(each -> each.getName().equals(event.getTableName()));
+ ShadowRuleConfiguration config = (ShadowRuleConfiguration) database.getRuleMetaData().getSingleRule(ShadowRule.class).getConfiguration();
+ config.getDataSources().removeIf(each -> each.getName().equals(event.getDataSourceName()));
ruleConfigs.add(config);
database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowTableSubscriber.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowTableSubscriber.java
new file mode 100644
index 00000000000..1308bf496fe
--- /dev/null
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/subscriber/ShadowTableSubscriber.java
@@ -0,0 +1,101 @@
+/*
+ * 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.shadow.subscriber;
+
+import com.google.common.eventbus.Subscribe;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator;
+import org.apache.shardingsphere.mode.event.config.RuleConfigurationChangedEvent;
+import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
+import org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
+import org.apache.shardingsphere.shadow.event.table.AddShadowTableEvent;
+import org.apache.shardingsphere.shadow.event.table.AlterShadowTableEvent;
+import org.apache.shardingsphere.shadow.event.table.DeleteShadowTableEvent;
+import org.apache.shardingsphere.shadow.rule.ShadowRule;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Map;
+
+/**
+ * Shadow table subscriber.
+ */
+@SuppressWarnings("UnstableApiUsage")
+@RequiredArgsConstructor
+public final class ShadowTableSubscriber implements RuleConfigurationSubscribeCoordinator {
+
+ private Map<String, ShardingSphereDatabase> databases;
+
+ private InstanceContext instanceContext;
+
+ @Override
+ public void registerRuleConfigurationSubscriber(final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext) {
+ this.databases = databases;
+ this.instanceContext = instanceContext;
+ instanceContext.getEventBusContext().register(this);
+ }
+
+ /**
+ * Renew with add table.
+ *
+ * @param event add table event
+ */
+ @Subscribe
+ public synchronized void renew(final AddShadowTableEvent<ShadowTableConfiguration> event) {
+ renew(event.getDatabaseName(), event.getTableName(), event.getConfig());
+ }
+
+ /**
+ * Renew with alter table.
+ *
+ * @param event alter table event
+ */
+ @Subscribe
+ public synchronized void renew(final AlterShadowTableEvent<ShadowTableConfiguration> event) {
+ renew(event.getDatabaseName(), event.getTableName(), event.getConfig());
+ }
+
+ private void renew(final String databaseName, final String tableName, final ShadowTableConfiguration tableConfig) {
+ ShardingSphereDatabase database = databases.get(databaseName);
+ Collection<RuleConfiguration> ruleConfigs = new LinkedList<>(database.getRuleMetaData().getConfigurations());
+ ShadowRuleConfiguration config = (ShadowRuleConfiguration) database.getRuleMetaData().getSingleRule(ShadowRule.class).getConfiguration();
+ config.getTables().put(tableName, tableConfig);
+ ruleConfigs.add(config);
+ database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
+ instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(databaseName, config));
+ }
+
+ /**
+ * Renew with delete table.
+ *
+ * @param event delete table event
+ */
+ @Subscribe
+ public synchronized void renew(final DeleteShadowTableEvent event) {
+ ShardingSphereDatabase database = databases.get(event.getDatabaseName());
+ Collection<RuleConfiguration> ruleConfigs = new LinkedList<>(database.getRuleMetaData().getConfigurations());
+ ShadowRuleConfiguration config = (ShadowRuleConfiguration) database.getRuleMetaData().getSingleRule(ShadowRule.class).getConfiguration();
+ config.getTables().remove(event.getTableName());
+ ruleConfigs.add(config);
+ database.getRuleMetaData().getConfigurations().addAll(ruleConfigs);
+ instanceContext.getEventBusContext().post(new RuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ }
+}
diff --git a/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator b/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator
new file mode 100644
index 00000000000..7685f858e8f
--- /dev/null
+++ b/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.RuleConfigurationSubscribeCoordinator
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.shadow.subscriber.ShadowConfigurationSubscriber
+org.apache.shardingsphere.shadow.subscriber.ShadowTableSubscriber
+org.apache.shardingsphere.shadow.subscriber.ShadowAlgorithmSubscriber
diff --git a/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder b/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
new file mode 100644
index 00000000000..4f0050d908e
--- /dev/null
+++ b/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.event.config.RuleConfigurationEventBuilder
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.shadow.event.ShadowRuleConfigurationEventBuilder