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/24 13:11:32 UTC
[shardingsphere] branch master updated: Refactor shading event & subscriber (#26489)
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 f3adf7d7b0d Refactor shading event & subscriber (#26489)
f3adf7d7b0d is described below
commit f3adf7d7b0d2779ef01ac5eed98bbfb33a5ee020
Author: ChenJiaHao <Pa...@163.com>
AuthorDate: Sat Jun 24 21:11:24 2023 +0800
Refactor shading event & subscriber (#26489)
---
.../ShardingRuleConfigurationEventBuilder.java | 221 ++++++---------------
.../event/algorithm/auditor/AlterAuditorEvent.java | 3 -
.../algorithm/auditor/DeleteAuditorEvent.java | 4 -
.../keygenerator/AlterKeyGeneratorEvent.java | 3 -
.../keygenerator/DeleteKeyGeneratorEvent.java | 4 -
.../sharding/AlterShardingAlgorithmEvent.java | 3 -
.../sharding/DeleteShardingAlgorithmEvent.java | 4 -
.../cache/AddShardingCacheConfigurationEvent.java | 3 -
.../AlterShardingCacheConfigurationEvent.java | 3 -
.../DeleteShardingCacheConfigurationEvent.java | 4 -
...dShardingAuditorStrategyConfigurationEvent.java | 3 -
...rShardingAuditorStrategyConfigurationEvent.java | 3 -
...eShardingAuditorStrategyConfigurationEvent.java | 4 -
...DatabaseShardingStrategyConfigurationEvent.java | 3 -
...DatabaseShardingStrategyConfigurationEvent.java | 3 -
...DatabaseShardingStrategyConfigurationEvent.java | 4 -
.../AddKeyGenerateStrategyConfigurationEvent.java | 3 -
...AlterKeyGenerateStrategyConfigurationEvent.java | 3 -
...eleteKeyGenerateStrategyConfigurationEvent.java | 4 -
.../AddDefaultShardingColumnEvent.java | 2 -
.../AlterDefaultShardingColumnEvent.java | 2 -
.../DeleteDefaultShardingColumnEvent.java | 4 -
...AddTableShardingStrategyConfigurationEvent.java | 3 -
...terTableShardingStrategyConfigurationEvent.java | 3 -
...eteTableShardingStrategyConfigurationEvent.java | 4 -
.../AddShardingAutoTableConfigurationEvent.java | 6 +-
.../AlterShardingAutoTableConfigurationEvent.java | 6 +-
.../DeleteShardingAutoTableConfigurationEvent.java | 4 -
...ddShardingTableReferenceConfigurationEvent.java | 8 +-
...erShardingTableReferenceConfigurationEvent.java | 8 +-
.../AddBroadcastTableConfigurationEvent.java | 40 ----
.../AlterBroadcastTableConfigurationEvent.java | 40 ----
.../DeleteBroadcastTableConfigurationEvent.java | 36 ----
.../AddShardingTableConfigurationEvent.java | 6 +-
.../AlterShardingTableConfigurationEvent.java | 6 +-
.../DeleteShardingTableConfigurationEvent.java | 4 -
.../metadata/converter/ShardingNodeConverter.java | 161 +++++++--------
.../subscriber/ShardingAlgorithmSubscriber.java | 17 +-
.../ShardingCacheConfigurationSubscriber.java | 14 +-
.../ShardingStrategyConfigurationSubscriber.java | 47 ++++-
.../ShardingTableConfigurationSubscriber.java | 104 ++++------
.../converter/ShardingNodeConverterTest.java | 72 +++----
42 files changed, 277 insertions(+), 602 deletions(-)
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/ShardingRuleConfigurationEventBuilder.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/ShardingRuleConfigurationEventBuilder.java
index 7d0a74f71ea..a93f1f66dbb 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/ShardingRuleConfigurationEventBuilder.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/ShardingRuleConfigurationEventBuilder.java
@@ -18,21 +18,10 @@
package org.apache.shardingsphere.sharding.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.spi.RuleConfigurationEventBuilder;
-import org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheConfiguration;
-import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
-import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableReferenceRuleConfiguration;
-import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
-import org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
-import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
-import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.event.algorithm.auditor.AlterAuditorEvent;
import org.apache.shardingsphere.sharding.event.algorithm.auditor.DeleteAuditorEvent;
import org.apache.shardingsphere.sharding.event.algorithm.keygenerator.AlterKeyGeneratorEvent;
@@ -60,28 +49,11 @@ import org.apache.shardingsphere.sharding.event.strategy.table.DeleteTableShardi
import org.apache.shardingsphere.sharding.event.table.auto.AddShardingAutoTableConfigurationEvent;
import org.apache.shardingsphere.sharding.event.table.auto.AlterShardingAutoTableConfigurationEvent;
import org.apache.shardingsphere.sharding.event.table.auto.DeleteShardingAutoTableConfigurationEvent;
-import org.apache.shardingsphere.sharding.event.table.broadcast.AddBroadcastTableConfigurationEvent;
-import org.apache.shardingsphere.sharding.event.table.broadcast.AlterBroadcastTableConfigurationEvent;
-import org.apache.shardingsphere.sharding.event.table.broadcast.DeleteBroadcastTableConfigurationEvent;
import org.apache.shardingsphere.sharding.event.table.sharding.AddShardingTableConfigurationEvent;
import org.apache.shardingsphere.sharding.event.table.sharding.AlterShardingTableConfigurationEvent;
import org.apache.shardingsphere.sharding.event.table.sharding.DeleteShardingTableConfigurationEvent;
import org.apache.shardingsphere.sharding.metadata.converter.ShardingNodeConverter;
-import org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheConfiguration;
-import org.apache.shardingsphere.sharding.yaml.config.rule.YamlShardingAutoTableRuleConfiguration;
-import org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
-import org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
-import org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
-import org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
-import org.apache.shardingsphere.sharding.yaml.swapper.cache.YamlShardingCacheConfigurationSwapper;
-import org.apache.shardingsphere.sharding.yaml.swapper.rule.YamlShardingAutoTableRuleConfigurationSwapper;
-import org.apache.shardingsphere.sharding.yaml.swapper.rule.YamlShardingTableReferenceRuleConfigurationConverter;
-import org.apache.shardingsphere.sharding.yaml.swapper.rule.YamlShardingTableRuleConfigurationSwapper;
-import org.apache.shardingsphere.sharding.yaml.swapper.strategy.YamlKeyGenerateStrategyConfigurationSwapper;
-import org.apache.shardingsphere.sharding.yaml.swapper.strategy.YamlShardingAuditStrategyConfigurationSwapper;
-import org.apache.shardingsphere.sharding.yaml.swapper.strategy.YamlShardingStrategyConfigurationSwapper;
-import java.util.Collection;
import java.util.Optional;
/**
@@ -96,236 +68,157 @@ public final class ShardingRuleConfigurationEventBuilder implements RuleConfigur
}
Optional<String> tableName = ShardingNodeConverter.getTableName(event.getKey());
if (tableName.isPresent() && !Strings.isNullOrEmpty(event.getValue())) {
- Optional<String> tableNameVersion = ShardingNodeConverter.getTableNameVersion(event.getKey());
- if (tableNameVersion.isPresent()) {
- return createShardingTableConfigEvent(databaseName, tableName.get(), tableNameVersion.get(), event);
- }
+ return createShardingTableConfigEvent(databaseName, tableName.get(), event);
}
Optional<String> autoTableName = ShardingNodeConverter.getAutoTableName(event.getKey());
if (autoTableName.isPresent() && !Strings.isNullOrEmpty(event.getValue())) {
- Optional<String> autoTableNameVersion = ShardingNodeConverter.getAutoTableNameVersion(event.getKey());
- if (autoTableNameVersion.isPresent()) {
- return createShardingAutoTableConfigEvent(databaseName, autoTableName.get(), autoTableNameVersion.get(), event);
- }
+ return createShardingAutoTableConfigEvent(databaseName, autoTableName.get(), event);
}
Optional<String> bindingTableName = ShardingNodeConverter.getBindingTableName(event.getKey());
if (bindingTableName.isPresent() && !Strings.isNullOrEmpty(event.getValue())) {
- Optional<String> bingingTableNameVersion = ShardingNodeConverter.getBindingTableNameVersion(event.getKey());
- if (bingingTableNameVersion.isPresent()) {
- return createShardingTableReferenceConfigEvent(databaseName, bindingTableName.get(), bingingTableNameVersion.get(), event);
- }
+ return createShardingTableReferenceConfigEvent(databaseName, bindingTableName.get(), event);
}
if (ShardingNodeConverter.isDefaultDatabaseStrategyPath(event.getKey()) && !Strings.isNullOrEmpty(event.getValue())) {
- Optional<String> defaultDatabaseStrategyVersion = ShardingNodeConverter.getDefaultDatabaseStrategyVersion(event.getKey());
- if (defaultDatabaseStrategyVersion.isPresent()) {
- return createDefaultDatabaseStrategyConfigEvent(databaseName, defaultDatabaseStrategyVersion.get(), event);
- }
+ return createDefaultDatabaseStrategyConfigEvent(databaseName, event);
}
if (ShardingNodeConverter.isDefaultTableStrategyPath(event.getKey()) && !Strings.isNullOrEmpty(event.getValue())) {
- Optional<String> defaultTableStrategyVersion = ShardingNodeConverter.getDefaultTableStrategyVersion(event.getKey());
- if (defaultTableStrategyVersion.isPresent()) {
- return createDefaultTableStrategyConfigEvent(databaseName, defaultTableStrategyVersion.get(), event);
- }
+ return createDefaultTableStrategyConfigEvent(databaseName, event);
}
if (ShardingNodeConverter.isDefaultKeyGenerateStrategyPath(event.getKey()) && !Strings.isNullOrEmpty(event.getValue())) {
- Optional<String> defaultKeyGenerateStrategyVersion = ShardingNodeConverter.getDefaultKeyGenerateStrategyVersion(event.getKey());
- if (defaultKeyGenerateStrategyVersion.isPresent()) {
- return createDefaultKeyGenerateStrategyConfigEvent(databaseName, defaultKeyGenerateStrategyVersion.get(), event);
- }
+ return createDefaultKeyGenerateStrategyConfigEvent(databaseName, event);
}
if (ShardingNodeConverter.isDefaultAuditStrategyPath(event.getKey()) && !Strings.isNullOrEmpty(event.getValue())) {
- Optional<String> defaultAuditStrategyVersion = ShardingNodeConverter.getDefaultAuditStrategyVersion(event.getKey());
- if (defaultAuditStrategyVersion.isPresent()) {
- return createDefaultShardingAuditorStrategyConfigEvent(databaseName, defaultAuditStrategyVersion.get(), event);
- }
+ return createDefaultShardingAuditorStrategyConfigEvent(databaseName, event);
}
if (ShardingNodeConverter.isDefaultShardingColumnPath(event.getKey()) && !Strings.isNullOrEmpty(event.getValue())) {
- Optional<String> defaultShardingColumnVersion = ShardingNodeConverter.getDefaultShardingColumnVersion(event.getKey());
- if (defaultShardingColumnVersion.isPresent()) {
- return createDefaultShardingColumnEvent(databaseName, defaultShardingColumnVersion.get(), event);
- }
+ return createDefaultShardingColumnEvent(databaseName, event);
}
Optional<String> algorithmName = ShardingNodeConverter.getShardingAlgorithmName(event.getKey());
if (algorithmName.isPresent() && !Strings.isNullOrEmpty(event.getValue())) {
- Optional<String> algorithmVersion = ShardingNodeConverter.getShardingAlgorithmVersion(event.getKey());
- if (algorithmVersion.isPresent()) {
- return createShardingAlgorithmEvent(databaseName, algorithmName.get(), algorithmVersion.get(), event);
- }
+ return createShardingAlgorithmEvent(databaseName, algorithmName.get(), event);
}
Optional<String> keyGeneratorName = ShardingNodeConverter.getKeyGeneratorName(event.getKey());
if (keyGeneratorName.isPresent() && !Strings.isNullOrEmpty(event.getValue())) {
- Optional<String> keyGeneratorVersion = ShardingNodeConverter.getKeyGeneratorVersion(event.getKey());
- if (keyGeneratorVersion.isPresent()) {
- return createKeyGeneratorEvent(databaseName, keyGeneratorName.get(), keyGeneratorVersion.get(), event);
- }
+ return createKeyGeneratorEvent(databaseName, keyGeneratorName.get(), event);
}
Optional<String> auditorName = ShardingNodeConverter.getAuditorName(event.getKey());
if (auditorName.isPresent() && !Strings.isNullOrEmpty(event.getValue())) {
- Optional<String> auditorVersion = ShardingNodeConverter.getAuditorVersion(event.getKey());
- if (auditorVersion.isPresent()) {
- return createAuditorEvent(databaseName, auditorName.get(), auditorVersion.get(), event);
- }
+ return createAuditorEvent(databaseName, auditorName.get(), event);
}
if (ShardingNodeConverter.isShardingCachePath(event.getKey()) && !Strings.isNullOrEmpty(event.getValue())) {
- Optional<String> shardingCacheVersion = ShardingNodeConverter.getShardingCacheVersion(event.getKey());
- if (shardingCacheVersion.isPresent()) {
- return createShardingCacheEvent(databaseName, shardingCacheVersion.get(), event);
- }
+ return createShardingCacheEvent(databaseName, event);
}
return Optional.empty();
}
- private Optional<GovernanceEvent> createShardingTableConfigEvent(final String databaseName, final String tableName, final String version, final DataChangedEvent event) {
+ private Optional<GovernanceEvent> createShardingTableConfigEvent(final String databaseName, final String tableName, final DataChangedEvent event) {
if (Type.ADDED == event.getType()) {
- return Optional.of(new AddShardingTableConfigurationEvent<>(databaseName, swapShardingTableRuleConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AddShardingTableConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterShardingTableConfigurationEvent<>(databaseName, tableName, swapShardingTableRuleConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AlterShardingTableConfigurationEvent(databaseName, tableName, event.getKey(), event.getValue()));
}
- return Optional.of(new DeleteShardingTableConfigurationEvent(databaseName, tableName, event.getKey(), version));
+ return Optional.of(new DeleteShardingTableConfigurationEvent(databaseName, tableName));
}
- private ShardingTableRuleConfiguration swapShardingTableRuleConfig(final String yamlContext) {
- return new YamlShardingTableRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlTableRuleConfiguration.class));
- }
-
- private Optional<GovernanceEvent> createShardingAutoTableConfigEvent(final String databaseName, final String tableName, final String version, final DataChangedEvent event) {
+ private Optional<GovernanceEvent> createShardingAutoTableConfigEvent(final String databaseName, final String tableName, final DataChangedEvent event) {
if (Type.ADDED == event.getType()) {
- return Optional.of(new AddShardingAutoTableConfigurationEvent<>(databaseName, swapShardingAutoTableRuleConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AddShardingAutoTableConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterShardingAutoTableConfigurationEvent<>(databaseName, tableName, swapShardingAutoTableRuleConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AlterShardingAutoTableConfigurationEvent(databaseName, tableName, event.getKey(), event.getValue()));
}
- return Optional.of(new DeleteShardingAutoTableConfigurationEvent(databaseName, tableName, event.getKey(), version));
- }
-
- private ShardingAutoTableRuleConfiguration swapShardingAutoTableRuleConfig(final String yamlContext) {
- return new YamlShardingAutoTableRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlShardingAutoTableRuleConfiguration.class));
- }
-
- private Optional<GovernanceEvent> createShardingTableReferenceConfigEvent(final String databaseName, final String tableName, final String version, final DataChangedEvent event) {
- if (Type.ADDED == event.getType()) {
- return Optional.of(new AddShardingAutoTableConfigurationEvent<>(databaseName, swapShardingTableReferenceRuleConfig(event.getValue()), event.getKey(), version));
- }
- if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterShardingAutoTableConfigurationEvent<>(databaseName, tableName, swapShardingTableReferenceRuleConfig(event.getValue()), event.getKey(), version));
- }
- return Optional.of(new DeleteShardingAutoTableConfigurationEvent(databaseName, tableName, event.getKey(), version));
- }
-
- private ShardingTableReferenceRuleConfiguration swapShardingTableReferenceRuleConfig(final String yamlContext) {
- return YamlShardingTableReferenceRuleConfigurationConverter.convertToObject(yamlContext);
+ return Optional.of(new DeleteShardingAutoTableConfigurationEvent(databaseName, tableName));
}
- @SuppressWarnings("unchecked")
- private Optional<GovernanceEvent> createBroadcastTableConfigEvent(final String databaseName, final String version, final DataChangedEvent event) {
+ private Optional<GovernanceEvent> createShardingTableReferenceConfigEvent(final String databaseName, final String tableName, final DataChangedEvent event) {
if (Type.ADDED == event.getType()) {
- return Optional.of(new AddBroadcastTableConfigurationEvent(databaseName, YamlEngine.unmarshal(event.getValue(), Collection.class), event.getKey(), version));
+ return Optional.of(new AddShardingAutoTableConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterBroadcastTableConfigurationEvent(databaseName, YamlEngine.unmarshal(event.getValue(), Collection.class), event.getKey(), version));
+ return Optional.of(new AlterShardingAutoTableConfigurationEvent(databaseName, tableName, event.getKey(), event.getValue()));
}
- return Optional.of(new DeleteBroadcastTableConfigurationEvent(databaseName, event.getKey(), version));
+ return Optional.of(new DeleteShardingAutoTableConfigurationEvent(databaseName, tableName));
}
- private Optional<GovernanceEvent> createDefaultDatabaseStrategyConfigEvent(final String databaseName, final String version, final DataChangedEvent event) {
+ private Optional<GovernanceEvent> createDefaultDatabaseStrategyConfigEvent(final String databaseName, final DataChangedEvent event) {
if (Type.ADDED == event.getType()) {
- return Optional.of(new AddDatabaseShardingStrategyConfigurationEvent(databaseName, swapShardingStrategyConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AddDatabaseShardingStrategyConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterDatabaseShardingStrategyConfigurationEvent(databaseName, swapShardingStrategyConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AlterDatabaseShardingStrategyConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
- return Optional.of(new DeleteDatabaseShardingStrategyConfigurationEvent(databaseName, event.getKey(), version));
+ return Optional.of(new DeleteDatabaseShardingStrategyConfigurationEvent(databaseName));
}
- private Optional<GovernanceEvent> createDefaultTableStrategyConfigEvent(final String databaseName, final String version, final DataChangedEvent event) {
+ private Optional<GovernanceEvent> createDefaultTableStrategyConfigEvent(final String databaseName, final DataChangedEvent event) {
if (Type.ADDED == event.getType()) {
- return Optional.of(new AddTableShardingStrategyConfigurationEvent(databaseName, swapShardingStrategyConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AddTableShardingStrategyConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterTableShardingStrategyConfigurationEvent(databaseName, swapShardingStrategyConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AlterTableShardingStrategyConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
- return Optional.of(new DeleteTableShardingStrategyConfigurationEvent(databaseName, event.getKey(), version));
- }
-
- private ShardingStrategyConfiguration swapShardingStrategyConfig(final String yamlContext) {
- return new YamlShardingStrategyConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlShardingStrategyConfiguration.class));
+ return Optional.of(new DeleteTableShardingStrategyConfigurationEvent(databaseName));
}
- private Optional<GovernanceEvent> createDefaultKeyGenerateStrategyConfigEvent(final String databaseName, final String version, final DataChangedEvent event) {
+ private Optional<GovernanceEvent> createDefaultKeyGenerateStrategyConfigEvent(final String databaseName, final DataChangedEvent event) {
if (Type.ADDED == event.getType()) {
- return Optional.of(new AddKeyGenerateStrategyConfigurationEvent(databaseName, swapKeyGenerateStrategyConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AddKeyGenerateStrategyConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterKeyGenerateStrategyConfigurationEvent(databaseName, swapKeyGenerateStrategyConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AlterKeyGenerateStrategyConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
- return Optional.of(new DeleteKeyGenerateStrategyConfigurationEvent(databaseName, event.getKey(), version));
+ return Optional.of(new DeleteKeyGenerateStrategyConfigurationEvent(databaseName));
}
- private KeyGenerateStrategyConfiguration swapKeyGenerateStrategyConfig(final String yamlContext) {
- return new YamlKeyGenerateStrategyConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlKeyGenerateStrategyConfiguration.class));
- }
-
- private Optional<GovernanceEvent> createDefaultShardingAuditorStrategyConfigEvent(final String databaseName, final String version, final DataChangedEvent event) {
+ private Optional<GovernanceEvent> createDefaultShardingAuditorStrategyConfigEvent(final String databaseName, final DataChangedEvent event) {
if (Type.ADDED == event.getType()) {
- return Optional.of(new AddShardingAuditorStrategyConfigurationEvent(databaseName, swapShardingAuditorStrategyConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AddShardingAuditorStrategyConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterShardingAuditorStrategyConfigurationEvent(databaseName, swapShardingAuditorStrategyConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AlterShardingAuditorStrategyConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
- return Optional.of(new DeleteShardingAuditorStrategyConfigurationEvent(databaseName, event.getKey(), version));
+ return Optional.of(new DeleteShardingAuditorStrategyConfigurationEvent(databaseName));
}
- private ShardingAuditStrategyConfiguration swapShardingAuditorStrategyConfig(final String yamlContext) {
- return new YamlShardingAuditStrategyConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlShardingAuditStrategyConfiguration.class));
- }
-
- private Optional<GovernanceEvent> createDefaultShardingColumnEvent(final String databaseName, final String version, final DataChangedEvent event) {
+ private Optional<GovernanceEvent> createDefaultShardingColumnEvent(final String databaseName, final DataChangedEvent event) {
if (Type.ADDED == event.getType()) {
- return Optional.of(new AddDefaultShardingColumnEvent(databaseName, event.getValue(), event.getKey(), version));
+ return Optional.of(new AddDefaultShardingColumnEvent(databaseName, event.getKey(), event.getValue()));
}
if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterDefaultShardingColumnEvent(databaseName, event.getValue(), event.getKey(), version));
+ return Optional.of(new AlterDefaultShardingColumnEvent(databaseName, event.getKey(), event.getValue()));
}
- return Optional.of(new DeleteDefaultShardingColumnEvent(databaseName, event.getKey(), version));
+ return Optional.of(new DeleteDefaultShardingColumnEvent(databaseName));
}
- private Optional<GovernanceEvent> createShardingAlgorithmEvent(final String databaseName, final String algorithmName, final String version, final DataChangedEvent event) {
+ private Optional<GovernanceEvent> createShardingAlgorithmEvent(final String databaseName, final String algorithmName, final DataChangedEvent event) {
if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return Optional.of(new AlterShardingAlgorithmEvent(databaseName, algorithmName, swapToAlgorithmConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AlterShardingAlgorithmEvent(databaseName, algorithmName, event.getKey(), event.getValue()));
}
- return Optional.of(new DeleteShardingAlgorithmEvent(databaseName, algorithmName, event.getKey(), version));
+ return Optional.of(new DeleteShardingAlgorithmEvent(databaseName, algorithmName));
}
- private Optional<GovernanceEvent> createKeyGeneratorEvent(final String databaseName, final String algorithmName, final String version, final DataChangedEvent event) {
+ private Optional<GovernanceEvent> createKeyGeneratorEvent(final String databaseName, final String algorithmName, final DataChangedEvent event) {
if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return Optional.of(new AlterKeyGeneratorEvent(databaseName, algorithmName, swapToAlgorithmConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AlterKeyGeneratorEvent(databaseName, algorithmName, event.getKey(), event.getValue()));
}
- return Optional.of(new DeleteKeyGeneratorEvent(databaseName, algorithmName, event.getKey(), version));
+ return Optional.of(new DeleteKeyGeneratorEvent(databaseName, algorithmName));
}
- private Optional<GovernanceEvent> createAuditorEvent(final String databaseName, final String algorithmName, final String version, final DataChangedEvent event) {
+ private Optional<GovernanceEvent> createAuditorEvent(final String databaseName, final String algorithmName, final DataChangedEvent event) {
if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return Optional.of(new AlterAuditorEvent(databaseName, algorithmName, swapToAlgorithmConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AlterAuditorEvent(databaseName, algorithmName, event.getKey(), event.getValue()));
}
- return Optional.of(new DeleteAuditorEvent(databaseName, algorithmName, event.getKey(), version));
- }
-
- private AlgorithmConfiguration swapToAlgorithmConfig(final String yamlContext) {
- return new YamlAlgorithmConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlAlgorithmConfiguration.class));
+ return Optional.of(new DeleteAuditorEvent(databaseName, algorithmName));
}
- private Optional<GovernanceEvent> createShardingCacheEvent(final String databaseName, final String version, final DataChangedEvent event) {
+ private Optional<GovernanceEvent> createShardingCacheEvent(final String databaseName, final DataChangedEvent event) {
if (Type.ADDED == event.getType()) {
- return Optional.of(new AddShardingCacheConfigurationEvent(databaseName, swapToShardingCacheConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AddShardingCacheConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
if (Type.UPDATED == event.getType()) {
- return Optional.of(new AlterShardingCacheConfigurationEvent(databaseName, swapToShardingCacheConfig(event.getValue()), event.getKey(), version));
+ return Optional.of(new AlterShardingCacheConfigurationEvent(databaseName, event.getKey(), event.getValue()));
}
- return Optional.of(new DeleteShardingCacheConfigurationEvent(databaseName, event.getKey(), version));
- }
-
- private ShardingCacheConfiguration swapToShardingCacheConfig(final String yamlContext) {
- return new YamlShardingCacheConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlShardingCacheConfiguration.class));
+ return Optional.of(new DeleteShardingCacheConfigurationEvent(databaseName));
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/auditor/AlterAuditorEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/auditor/AlterAuditorEvent.java
index 2173c690901..699fd5ccaed 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/auditor/AlterAuditorEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/auditor/AlterAuditorEvent.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.sharding.event.algorithm.auditor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
@@ -33,8 +32,6 @@ public final class AlterAuditorEvent implements GovernanceEvent {
private final String auditorName;
- private final AlgorithmConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/auditor/DeleteAuditorEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/auditor/DeleteAuditorEvent.java
index 736477ff9ea..0d18f6f42cb 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/auditor/DeleteAuditorEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/auditor/DeleteAuditorEvent.java
@@ -31,8 +31,4 @@ public final class DeleteAuditorEvent implements GovernanceEvent {
private final String databaseName;
private final String auditorName;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/keygenerator/AlterKeyGeneratorEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/keygenerator/AlterKeyGeneratorEvent.java
index 793063bbf07..062a88fdad7 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/keygenerator/AlterKeyGeneratorEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/keygenerator/AlterKeyGeneratorEvent.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.sharding.event.algorithm.keygenerator;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
@@ -33,8 +32,6 @@ public final class AlterKeyGeneratorEvent implements GovernanceEvent {
private final String keyGeneratorName;
- private final AlgorithmConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/keygenerator/DeleteKeyGeneratorEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/keygenerator/DeleteKeyGeneratorEvent.java
index db98d28a9cf..a56bfa0d959 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/keygenerator/DeleteKeyGeneratorEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/keygenerator/DeleteKeyGeneratorEvent.java
@@ -31,8 +31,4 @@ public final class DeleteKeyGeneratorEvent implements GovernanceEvent {
private final String databaseName;
private final String keyGeneratorName;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/sharding/AlterShardingAlgorithmEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/sharding/AlterShardingAlgorithmEvent.java
index e6b93482aa2..e20deca76f3 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/sharding/AlterShardingAlgorithmEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/sharding/AlterShardingAlgorithmEvent.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.sharding.event.algorithm.sharding;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
@@ -33,8 +32,6 @@ public final class AlterShardingAlgorithmEvent implements GovernanceEvent {
private final String algorithmName;
- private final AlgorithmConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/sharding/DeleteShardingAlgorithmEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/sharding/DeleteShardingAlgorithmEvent.java
index 5cde97fe823..ec6363a8eb0 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/sharding/DeleteShardingAlgorithmEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/sharding/DeleteShardingAlgorithmEvent.java
@@ -31,8 +31,4 @@ public final class DeleteShardingAlgorithmEvent implements GovernanceEvent {
private final String databaseName;
private final String algorithmName;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/AddShardingCacheConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/AddShardingCacheConfigurationEvent.java
index fa67f8a8231..e60fb32dc8f 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/AddShardingCacheConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/AddShardingCacheConfigurationEvent.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.event.cache;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheConfiguration;
/**
* Add sharding cache configuration event.
@@ -31,8 +30,6 @@ public final class AddShardingCacheConfigurationEvent implements GovernanceEvent
private final String databaseName;
- private final ShardingCacheConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/AlterShardingCacheConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/AlterShardingCacheConfigurationEvent.java
index 58f3ab7c735..ce1f9e4850f 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/AlterShardingCacheConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/AlterShardingCacheConfigurationEvent.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.event.cache;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheConfiguration;
/**
* Alter sharding cache configuration event.
@@ -31,8 +30,6 @@ public final class AlterShardingCacheConfigurationEvent implements GovernanceEve
private final String databaseName;
- private final ShardingCacheConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/DeleteShardingCacheConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/DeleteShardingCacheConfigurationEvent.java
index 213fe176bd5..9e0878bc652 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/DeleteShardingCacheConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/DeleteShardingCacheConfigurationEvent.java
@@ -29,8 +29,4 @@ import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
public final class DeleteShardingCacheConfigurationEvent implements GovernanceEvent {
private final String databaseName;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/AddShardingAuditorStrategyConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/AddShardingAuditorStrategyConfigurationEvent.java
index 8424b3baf0e..81570cfb382 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/AddShardingAuditorStrategyConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/AddShardingAuditorStrategyConfigurationEvent.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.event.strategy.audit;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
/**
* Add default sharding auditor strategy configuration event.
@@ -31,8 +30,6 @@ public final class AddShardingAuditorStrategyConfigurationEvent implements Gover
private final String databaseName;
- private final ShardingAuditStrategyConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/AlterShardingAuditorStrategyConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/AlterShardingAuditorStrategyConfigurationEvent.java
index 4b5c33756ab..bf05a29ec93 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/AlterShardingAuditorStrategyConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/AlterShardingAuditorStrategyConfigurationEvent.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.event.strategy.audit;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
/**
* Alter default sharding auditor strategy configuration event.
@@ -31,8 +30,6 @@ public final class AlterShardingAuditorStrategyConfigurationEvent implements Gov
private final String databaseName;
- private final ShardingAuditStrategyConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/DeleteShardingAuditorStrategyConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/DeleteShardingAuditorStrategyConfigurationEvent.java
index 3011094d542..8f30a81b869 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/DeleteShardingAuditorStrategyConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/DeleteShardingAuditorStrategyConfigurationEvent.java
@@ -29,8 +29,4 @@ import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
public final class DeleteShardingAuditorStrategyConfigurationEvent implements GovernanceEvent {
private final String databaseName;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/AddDatabaseShardingStrategyConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/AddDatabaseShardingStrategyConfigurationEvent.java
index ae73d53d698..76e80a8f520 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/AddDatabaseShardingStrategyConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/AddDatabaseShardingStrategyConfigurationEvent.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.event.strategy.database;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
/**
* Add default database sharding strategy configuration event.
@@ -31,8 +30,6 @@ public final class AddDatabaseShardingStrategyConfigurationEvent implements Gove
private final String databaseName;
- private final ShardingStrategyConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/AlterDatabaseShardingStrategyConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/AlterDatabaseShardingStrategyConfigurationEvent.java
index d2737e06e7b..291c0a6cc29 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/AlterDatabaseShardingStrategyConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/AlterDatabaseShardingStrategyConfigurationEvent.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.event.strategy.database;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
/**
* Alter default database sharding strategy configuration event.
@@ -31,8 +30,6 @@ public final class AlterDatabaseShardingStrategyConfigurationEvent implements Go
private final String databaseName;
- private final ShardingStrategyConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/DeleteDatabaseShardingStrategyConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/DeleteDatabaseShardingStrategyConfigurationEvent.java
index 9ec3d1c125d..a6043d15ad9 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/DeleteDatabaseShardingStrategyConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/DeleteDatabaseShardingStrategyConfigurationEvent.java
@@ -29,8 +29,4 @@ import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
public final class DeleteDatabaseShardingStrategyConfigurationEvent implements GovernanceEvent {
private final String databaseName;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/AddKeyGenerateStrategyConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/AddKeyGenerateStrategyConfigurationEvent.java
index 0b5f24122be..147be6d6884 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/AddKeyGenerateStrategyConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/AddKeyGenerateStrategyConfigurationEvent.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.event.strategy.keygenerate;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
/**
* Add default key generate strategy configuration event.
@@ -31,8 +30,6 @@ public final class AddKeyGenerateStrategyConfigurationEvent implements Governanc
private final String databaseName;
- private final KeyGenerateStrategyConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/AlterKeyGenerateStrategyConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/AlterKeyGenerateStrategyConfigurationEvent.java
index e45737c78d1..724faa81a2a 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/AlterKeyGenerateStrategyConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/AlterKeyGenerateStrategyConfigurationEvent.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.event.strategy.keygenerate;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
/**
* Alter default key generate strategy configuration event.
@@ -31,8 +30,6 @@ public final class AlterKeyGenerateStrategyConfigurationEvent implements Governa
private final String databaseName;
- private final KeyGenerateStrategyConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/DeleteKeyGenerateStrategyConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/DeleteKeyGenerateStrategyConfigurationEvent.java
index af39402f41d..5ea261f2bdc 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/DeleteKeyGenerateStrategyConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/DeleteKeyGenerateStrategyConfigurationEvent.java
@@ -29,8 +29,4 @@ import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
public final class DeleteKeyGenerateStrategyConfigurationEvent implements GovernanceEvent {
private final String databaseName;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/AddDefaultShardingColumnEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/AddDefaultShardingColumnEvent.java
index 1bcc3c35f64..8093babd599 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/AddDefaultShardingColumnEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/AddDefaultShardingColumnEvent.java
@@ -30,8 +30,6 @@ public final class AddDefaultShardingColumnEvent implements GovernanceEvent {
private final String databaseName;
- private final String config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/AlterDefaultShardingColumnEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/AlterDefaultShardingColumnEvent.java
index 7b4524963f8..d542d57856d 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/AlterDefaultShardingColumnEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/AlterDefaultShardingColumnEvent.java
@@ -30,8 +30,6 @@ public final class AlterDefaultShardingColumnEvent implements GovernanceEvent {
private final String databaseName;
- private final String config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/DeleteDefaultShardingColumnEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/DeleteDefaultShardingColumnEvent.java
index d1eeb9edf06..5b68a6f910c 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/DeleteDefaultShardingColumnEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/DeleteDefaultShardingColumnEvent.java
@@ -29,8 +29,4 @@ import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
public final class DeleteDefaultShardingColumnEvent implements GovernanceEvent {
private final String databaseName;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/AddTableShardingStrategyConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/AddTableShardingStrategyConfigurationEvent.java
index 11f69ad1648..b51a9b3c627 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/AddTableShardingStrategyConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/AddTableShardingStrategyConfigurationEvent.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.event.strategy.table;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
/**
* Add default database sharding strategy configuration event.
@@ -31,8 +30,6 @@ public final class AddTableShardingStrategyConfigurationEvent implements Governa
private final String databaseName;
- private final ShardingStrategyConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/AlterTableShardingStrategyConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/AlterTableShardingStrategyConfigurationEvent.java
index 0357be66b12..bab4e5cca7c 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/AlterTableShardingStrategyConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/AlterTableShardingStrategyConfigurationEvent.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.event.strategy.table;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
/**
* Alter default database sharding strategy configuration event.
@@ -31,8 +30,6 @@ public final class AlterTableShardingStrategyConfigurationEvent implements Gover
private final String databaseName;
- private final ShardingStrategyConfiguration config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/DeleteTableShardingStrategyConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/DeleteTableShardingStrategyConfigurationEvent.java
index 29439ba5ac1..146b9445aeb 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/DeleteTableShardingStrategyConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/DeleteTableShardingStrategyConfigurationEvent.java
@@ -29,8 +29,4 @@ import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
public final class DeleteTableShardingStrategyConfigurationEvent implements GovernanceEvent {
private final String databaseName;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/AddShardingAutoTableConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/AddShardingAutoTableConfigurationEvent.java
index c72b39d97bc..daa0bee68d0 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/AddShardingAutoTableConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/AddShardingAutoTableConfigurationEvent.java
@@ -23,17 +23,13 @@ import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
* Add sharding auto table configuration event.
- *
- * @param <T> sharding auto table configuration
*/
@RequiredArgsConstructor
@Getter
-public final class AddShardingAutoTableConfigurationEvent<T> implements GovernanceEvent {
+public final class AddShardingAutoTableConfigurationEvent implements GovernanceEvent {
private final String databaseName;
- private final T config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/AlterShardingAutoTableConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/AlterShardingAutoTableConfigurationEvent.java
index d4f4b6c77b4..f30b2639c83 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/AlterShardingAutoTableConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/AlterShardingAutoTableConfigurationEvent.java
@@ -23,19 +23,15 @@ import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
* Alter sharding auto table configuration event.
- *
- * @param <T> sharding auto table configuration
*/
@RequiredArgsConstructor
@Getter
-public final class AlterShardingAutoTableConfigurationEvent<T> implements GovernanceEvent {
+public final class AlterShardingAutoTableConfigurationEvent implements GovernanceEvent {
private final String databaseName;
private final String tableName;
- private final T config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/DeleteShardingAutoTableConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/DeleteShardingAutoTableConfigurationEvent.java
index efd9cf3be81..b41ff63eb70 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/DeleteShardingAutoTableConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/DeleteShardingAutoTableConfigurationEvent.java
@@ -31,8 +31,4 @@ public final class DeleteShardingAutoTableConfigurationEvent implements Governan
private final String databaseName;
private final String tableName;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/binding/AddShardingTableReferenceConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/binding/AddShardingTableReferenceConfigurationEvent.java
index fe6c7b2c00b..3e32f47c824 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/binding/AddShardingTableReferenceConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/binding/AddShardingTableReferenceConfigurationEvent.java
@@ -23,14 +23,14 @@ import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
* Add sharding binding table configuration event.
- *
- * @param <T> sharding binding table configuration
*/
@RequiredArgsConstructor
@Getter
-public final class AddShardingTableReferenceConfigurationEvent<T> implements GovernanceEvent {
+public final class AddShardingTableReferenceConfigurationEvent implements GovernanceEvent {
private final String databaseName;
- private final T config;
+ private final String activeVersionKey;
+
+ private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/binding/AlterShardingTableReferenceConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/binding/AlterShardingTableReferenceConfigurationEvent.java
index b4f9e19f9d3..a401c023313 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/binding/AlterShardingTableReferenceConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/binding/AlterShardingTableReferenceConfigurationEvent.java
@@ -23,16 +23,16 @@ import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
* Alter sharding binding table configuration event.
- *
- * @param <T> sharding binding table configuration
*/
@RequiredArgsConstructor
@Getter
-public final class AlterShardingTableReferenceConfigurationEvent<T> implements GovernanceEvent {
+public final class AlterShardingTableReferenceConfigurationEvent implements GovernanceEvent {
private final String databaseName;
private final String tableName;
- private final T config;
+ private final String activeVersionKey;
+
+ private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/broadcast/AddBroadcastTableConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/broadcast/AddBroadcastTableConfigurationEvent.java
deleted file mode 100644
index d2ba149500a..00000000000
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/broadcast/AddBroadcastTableConfigurationEvent.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sharding.event.table.broadcast;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-import java.util.Collection;
-
-/**
- * Add broadcast table configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AddBroadcastTableConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final Collection<String> config;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
-}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/broadcast/AlterBroadcastTableConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/broadcast/AlterBroadcastTableConfigurationEvent.java
deleted file mode 100644
index 11573ecedba..00000000000
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/broadcast/AlterBroadcastTableConfigurationEvent.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sharding.event.table.broadcast;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-import java.util.Collection;
-
-/**
- * Alter broadcast table configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AlterBroadcastTableConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final Collection<String> config;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
-}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/broadcast/DeleteBroadcastTableConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/broadcast/DeleteBroadcastTableConfigurationEvent.java
deleted file mode 100644
index fef0f3e094b..00000000000
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/broadcast/DeleteBroadcastTableConfigurationEvent.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sharding.event.table.broadcast;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Delete broadcast table configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class DeleteBroadcastTableConfigurationEvent implements GovernanceEvent {
-
- private final String databaseName;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
-}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/AddShardingTableConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/AddShardingTableConfigurationEvent.java
index d2ec2bfea95..a90fe33d8d4 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/AddShardingTableConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/AddShardingTableConfigurationEvent.java
@@ -23,17 +23,13 @@ import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
* Add sharding table configuration event.
- *
- * @param <T> sharding table configuration
*/
@RequiredArgsConstructor
@Getter
-public final class AddShardingTableConfigurationEvent<T> implements GovernanceEvent {
+public final class AddShardingTableConfigurationEvent implements GovernanceEvent {
private final String databaseName;
- private final T config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/AlterShardingTableConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/AlterShardingTableConfigurationEvent.java
index 5d6b77d01af..959f5ebd332 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/AlterShardingTableConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/AlterShardingTableConfigurationEvent.java
@@ -23,19 +23,15 @@ import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
* Alter sharding table configuration event.
- *
- * @param <T> sharding table configuration
*/
@RequiredArgsConstructor
@Getter
-public final class AlterShardingTableConfigurationEvent<T> implements GovernanceEvent {
+public final class AlterShardingTableConfigurationEvent implements GovernanceEvent {
private final String databaseName;
private final String tableName;
- private final T config;
-
private final String activeVersionKey;
private final String activeVersion;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/DeleteShardingTableConfigurationEvent.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/DeleteShardingTableConfigurationEvent.java
index cf865f50bcb..53ed30de9af 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/DeleteShardingTableConfigurationEvent.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/DeleteShardingTableConfigurationEvent.java
@@ -31,8 +31,4 @@ public final class DeleteShardingTableConfigurationEvent implements GovernanceEv
private final String databaseName;
private final String tableName;
-
- private final String activeVersionKey;
-
- private final String activeVersion;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/converter/ShardingNodeConverter.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/converter/ShardingNodeConverter.java
index f19297654ab..acf45795c1f 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/converter/ShardingNodeConverter.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/converter/ShardingNodeConverter.java
@@ -62,7 +62,9 @@ public final class ShardingNodeConverter {
private static final String RULE_NAME_PATTERN = "/([\\w\\-]+)?";
- private static final String RULE_VERSION = "/([\\w\\-]+)/versions/([\\w\\-]+)$";
+ private static final String RULE_ACTIVE_VERSION = "/([\\w\\-]+)?/active_version$";
+
+ private static final String ACTIVE_VERSION = "/active_version$";
/**
* Get table name path.
@@ -407,147 +409,146 @@ public final class ShardingNodeConverter {
}
/**
- * Get table name version.
+ * Get table name by active version path.
*
- * @param rulePath rule path
+ * @param activeVersionPath active version path
* @return table name version
*/
- public static Optional<String> getTableNameVersion(final String rulePath) {
- Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + TABLES_NODE + RULE_VERSION, Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(rulePath);
- return matcher.find() ? Optional.of(matcher.group(4)) : Optional.empty();
+ public static Optional<String> getTableNameByActiveVersionPath(final String activeVersionPath) {
+ Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + TABLES_NODE + RULE_ACTIVE_VERSION, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(activeVersionPath);
+ return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
}
/**
- * Get auto table name version.
+ * Get auto table name by active version path.
*
- * @param rulePath rule path
+ * @param activeVersionPath active version path
* @return auto table name version
*/
- public static Optional<String> getAutoTableNameVersion(final String rulePath) {
- Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + AUTO_TABLES_NODE + RULE_VERSION, Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(rulePath);
- return matcher.find() ? Optional.of(matcher.group(4)) : Optional.empty();
+ public static Optional<String> getAutoTableNameByActiveVersionPath(final String activeVersionPath) {
+ Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + AUTO_TABLES_NODE + RULE_ACTIVE_VERSION, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(activeVersionPath);
+ return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
}
/**
- * Get binding table name version.
+ * Get binding table name by active version path.
*
- * @param rulePath rule path
+ * @param activeVersionPath active version path
* @return binding table name version
*/
- public static Optional<String> getBindingTableNameVersion(final String rulePath) {
- Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + BINDING_TABLES_NODE + RULE_VERSION, Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(rulePath);
- return matcher.find() ? Optional.of(matcher.group(4)) : Optional.empty();
+ public static Optional<String> getBindingTableNameByActiveVersionPath(final String activeVersionPath) {
+ Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + BINDING_TABLES_NODE + RULE_ACTIVE_VERSION, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(activeVersionPath);
+ return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
}
/**
- * Get sharding algorithm version.
+ * Is sharding algorithm with active version path.
*
- * @param rulePath rule path
- * @return sharding algorithm version
+ * @param activeVersionPath active version path
+ * @return true or false
*/
- public static Optional<String> getDefaultDatabaseStrategyVersion(final String rulePath) {
- Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + DEFAULT_STRATEGIES_NODE + "/" + DEFAULT_DATABASE_STRATEGY_NODE + "/versions/([\\w\\-]+)$", Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(rulePath);
- return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
+ public static boolean isDefaultDatabaseStrategyWithActiveVersionPath(final String activeVersionPath) {
+ Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + DEFAULT_STRATEGIES_NODE + "/" + DEFAULT_DATABASE_STRATEGY_NODE + ACTIVE_VERSION, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(activeVersionPath);
+ return matcher.find();
}
/**
- * Get default table strategy version.
+ * Is default table strategy with active version path.
*
- * @param rulePath rule path
- * @return default table strategy version
+ * @param activeVersionPath active version path
+ * @return true or false
*/
- public static Optional<String> getDefaultTableStrategyVersion(final String rulePath) {
- Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + DEFAULT_STRATEGIES_NODE + "/" + DEFAULT_TABLE_STRATEGY_NODE + "/versions/([\\w\\-]+)$", Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(rulePath);
- return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
+ public static boolean isDefaultTableStrategyWithActiveVersionPath(final String activeVersionPath) {
+ Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + DEFAULT_STRATEGIES_NODE + "/" + DEFAULT_TABLE_STRATEGY_NODE + ACTIVE_VERSION, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(activeVersionPath);
+ return matcher.find();
}
/**
- * Get default key generate strategy version.
+ * Is default key generate strategy with active version path.
*
- * @param rulePath rule path
- * @return default key generate strategy version
+ * @param activeVersionPath active version path
+ * @return true or false
*/
- public static Optional<String> getDefaultKeyGenerateStrategyVersion(final String rulePath) {
- Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + DEFAULT_STRATEGIES_NODE + "/" + DEFAULT_KEY_GENERATE_STRATEGY_NODE + "/versions/([\\w\\-]+)$",
- Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(rulePath);
- return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
+ public static boolean isDefaultKeyGenerateStrategyWithActiveVersionPath(final String activeVersionPath) {
+ Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + DEFAULT_STRATEGIES_NODE + "/" + DEFAULT_KEY_GENERATE_STRATEGY_NODE + ACTIVE_VERSION, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(activeVersionPath);
+ return matcher.find();
}
/**
- * Get default audit strategy version.
+ * Is default audit strategy with active version path.
*
- * @param rulePath rule path
- * @return default audit strategy version
+ * @param activeVersionPath active version path
+ * @return true or false
*/
- public static Optional<String> getDefaultAuditStrategyVersion(final String rulePath) {
- Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + DEFAULT_STRATEGIES_NODE + "/" + DEFAULT_AUDIT_STRATEGY_NODE + "/versions/([\\w\\-]+)$", Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(rulePath);
- return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
+ public static boolean isDefaultAuditStrategyWithActiveVersionPath(final String activeVersionPath) {
+ Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + DEFAULT_STRATEGIES_NODE + "/" + DEFAULT_AUDIT_STRATEGY_NODE + ACTIVE_VERSION, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(activeVersionPath);
+ return matcher.find();
}
/**
- * Get default sharding column version.
+ * Is default sharding column with active version path.
*
- * @param rulePath rule path
- * @return default sharding column version
+ * @param activeVersionPath active version path
+ * @return true or false
*/
- public static Optional<String> getDefaultShardingColumnVersion(final String rulePath) {
- Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + DEFAULT_STRATEGIES_NODE + "/" + DEFAULT_SHARDING_COLUMN_NODE + "/versions/([\\w\\-]+)$", Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(rulePath);
- return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
+ public static boolean isDefaultShardingColumnWithActiveVersionPath(final String activeVersionPath) {
+ Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + DEFAULT_STRATEGIES_NODE + "/" + DEFAULT_SHARDING_COLUMN_NODE + ACTIVE_VERSION, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(activeVersionPath);
+ return matcher.find();
}
/**
- * Get sharding algorithm version.
+ * Get sharding algorithm by active version path.
*
- * @param rulePath rule path
+ * @param activeVersionPath active version path
* @return sharding algorithm version
*/
- public static Optional<String> getShardingAlgorithmVersion(final String rulePath) {
- Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + SHARDING_ALGORITHMS_NODE + RULE_VERSION, Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(rulePath);
- return matcher.find() ? Optional.of(matcher.group(4)) : Optional.empty();
+ public static Optional<String> getShardingAlgorithmByActiveVersionPath(final String activeVersionPath) {
+ Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + SHARDING_ALGORITHMS_NODE + RULE_ACTIVE_VERSION, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(activeVersionPath);
+ return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
}
/**
- * Get key generator version.
+ * Get key generator by active version path.
*
- * @param rulePath rule path
+ * @param activeVersionPath active version path
* @return key generator version
*/
- public static Optional<String> getKeyGeneratorVersion(final String rulePath) {
- Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + KEY_GENERATORS_NODE + RULE_VERSION, Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(rulePath);
- return matcher.find() ? Optional.of(matcher.group(4)) : Optional.empty();
+ public static Optional<String> getKeyGeneratorByActiveVersionPath(final String activeVersionPath) {
+ Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + KEY_GENERATORS_NODE + RULE_ACTIVE_VERSION, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(activeVersionPath);
+ return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
}
/**
- * Get auditor version.
+ * Get auditor by active version path.
*
- * @param rulePath rule path
+ * @param activeVersionPath active version path
* @return auditor version
*/
- public static Optional<String> getAuditorVersion(final String rulePath) {
- Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + AUDITORS_NODE + RULE_VERSION, Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(rulePath);
- return matcher.find() ? Optional.of(matcher.group(4)) : Optional.empty();
+ public static Optional<String> getAuditorByActiveVersionPath(final String activeVersionPath) {
+ Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + AUDITORS_NODE + RULE_ACTIVE_VERSION, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(activeVersionPath);
+ return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
}
/**
- * Get sharding cache version.
+ * Is sharding cache with active version path.
*
- * @param rulePath rule path
- * @return sharding cache version
+ * @param activeVersionPath active version path
+ * @return true or false
*/
- public static Optional<String> getShardingCacheVersion(final String rulePath) {
- Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + SHARDING_CACHE_NODE + "/versions/([\\w\\-]+)$", Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(rulePath);
- return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
+ public static boolean isShardingCacheWithActiveVersionPath(final String activeVersionPath) {
+ Pattern pattern = Pattern.compile(RULES_NODE_PREFIX + ROOT_NODE + "/" + SHARDING_CACHE_NODE + ACTIVE_VERSION, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(activeVersionPath);
+ return matcher.find();
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingAlgorithmSubscriber.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingAlgorithmSubscriber.java
index cb265bd2905..facc37c657a 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingAlgorithmSubscriber.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingAlgorithmSubscriber.java
@@ -19,9 +19,13 @@ package org.apache.shardingsphere.sharding.subscriber;
import com.google.common.eventbus.Subscribe;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
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.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.config.DatabaseRuleConfigurationChangedEvent;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.event.algorithm.auditor.AlterAuditorEvent;
@@ -61,7 +65,8 @@ public final class ShardingAlgorithmSubscriber implements RuleConfigurationSubsc
public synchronized void renew(final AlterShardingAlgorithmEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
- config.getShardingAlgorithms().put(event.getAlgorithmName(), event.getConfig());
+ config.getShardingAlgorithms().put(event.getAlgorithmName(), swapToAlgorithmConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
}
/**
@@ -73,7 +78,8 @@ public final class ShardingAlgorithmSubscriber implements RuleConfigurationSubsc
public synchronized void renew(final AlterKeyGeneratorEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
- config.getKeyGenerators().put(event.getKeyGeneratorName(), event.getConfig());
+ config.getKeyGenerators().put(event.getKeyGeneratorName(), swapToAlgorithmConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
}
/**
@@ -85,7 +91,8 @@ public final class ShardingAlgorithmSubscriber implements RuleConfigurationSubsc
public synchronized void renew(final AlterAuditorEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
- config.getAuditors().put(event.getAuditorName(), event.getConfig());
+ config.getAuditors().put(event.getAuditorName(), swapToAlgorithmConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
}
/**
@@ -125,4 +132,8 @@ public final class ShardingAlgorithmSubscriber implements RuleConfigurationSubsc
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
config.getAuditors().remove(event.getAuditorName());
}
+
+ private AlgorithmConfiguration swapToAlgorithmConfig(final String yamlContext) {
+ return new YamlAlgorithmConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlAlgorithmConfiguration.class));
+ }
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingCacheConfigurationSubscriber.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingCacheConfigurationSubscriber.java
index 76c589c4bca..4b488385062 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingCacheConfigurationSubscriber.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingCacheConfigurationSubscriber.java
@@ -22,6 +22,7 @@ import lombok.RequiredArgsConstructor;
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.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheConfiguration;
@@ -29,6 +30,8 @@ import org.apache.shardingsphere.sharding.event.cache.AddShardingCacheConfigurat
import org.apache.shardingsphere.sharding.event.cache.AlterShardingCacheConfigurationEvent;
import org.apache.shardingsphere.sharding.event.cache.DeleteShardingCacheConfigurationEvent;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheConfiguration;
+import org.apache.shardingsphere.sharding.yaml.swapper.cache.YamlShardingCacheConfigurationSwapper;
import java.util.Map;
@@ -57,7 +60,8 @@ public final class ShardingCacheConfigurationSubscriber implements RuleConfigura
*/
@Subscribe
public synchronized void renew(final AddShardingCacheConfigurationEvent event) {
- renewShardingCacheConfig(event.getDatabaseName(), event.getConfig());
+ renewShardingCacheConfig(event.getDatabaseName(), swapToShardingCacheConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
}
/**
@@ -67,7 +71,8 @@ public final class ShardingCacheConfigurationSubscriber implements RuleConfigura
*/
@Subscribe
public synchronized void renew(final AlterShardingCacheConfigurationEvent event) {
- renewShardingCacheConfig(event.getDatabaseName(), event.getConfig());
+ renewShardingCacheConfig(event.getDatabaseName(), swapToShardingCacheConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
}
/**
@@ -89,4 +94,9 @@ public final class ShardingCacheConfigurationSubscriber implements RuleConfigura
config.setShardingCache(shardingCacheConfiguration);
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(databaseName, config));
}
+
+ private ShardingCacheConfiguration swapToShardingCacheConfig(final String yamlContext) {
+ return new YamlShardingCacheConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlShardingCacheConfiguration.class));
+ }
+
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingStrategyConfigurationSubscriber.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingStrategyConfigurationSubscriber.java
index 673ce702464..eb1f60743c9 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingStrategyConfigurationSubscriber.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingStrategyConfigurationSubscriber.java
@@ -22,6 +22,7 @@ import lombok.RequiredArgsConstructor;
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.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
@@ -43,6 +44,12 @@ import org.apache.shardingsphere.sharding.event.strategy.table.AddTableShardingS
import org.apache.shardingsphere.sharding.event.strategy.table.AlterTableShardingStrategyConfigurationEvent;
import org.apache.shardingsphere.sharding.event.strategy.table.DeleteTableShardingStrategyConfigurationEvent;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
+import org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
+import org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
+import org.apache.shardingsphere.sharding.yaml.swapper.strategy.YamlKeyGenerateStrategyConfigurationSwapper;
+import org.apache.shardingsphere.sharding.yaml.swapper.strategy.YamlShardingAuditStrategyConfigurationSwapper;
+import org.apache.shardingsphere.sharding.yaml.swapper.strategy.YamlShardingStrategyConfigurationSwapper;
import java.util.Map;
import java.util.Optional;
@@ -73,7 +80,8 @@ public final class ShardingStrategyConfigurationSubscriber implements RuleConfig
@Subscribe
public synchronized void renew(final AddDatabaseShardingStrategyConfigurationEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingStrategyConfiguration needToAddedConfig = event.getConfig();
+ ShardingStrategyConfiguration needToAddedConfig = swapShardingStrategyConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
Optional<ShardingRule> rule = database.getRuleMetaData().findSingleRule(ShardingRule.class);
ShardingRuleConfiguration config;
if (rule.isPresent()) {
@@ -94,7 +102,8 @@ public final class ShardingStrategyConfigurationSubscriber implements RuleConfig
@Subscribe
public synchronized void renew(final AddTableShardingStrategyConfigurationEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingStrategyConfiguration needToAddedConfig = event.getConfig();
+ ShardingStrategyConfiguration needToAddedConfig = swapShardingStrategyConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
Optional<ShardingRule> rule = database.getRuleMetaData().findSingleRule(ShardingRule.class);
ShardingRuleConfiguration config;
if (rule.isPresent()) {
@@ -115,7 +124,8 @@ public final class ShardingStrategyConfigurationSubscriber implements RuleConfig
@Subscribe
public synchronized void renew(final AddKeyGenerateStrategyConfigurationEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- KeyGenerateStrategyConfiguration needToAddedConfig = event.getConfig();
+ KeyGenerateStrategyConfiguration needToAddedConfig = swapKeyGenerateStrategyConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
Optional<ShardingRule> rule = database.getRuleMetaData().findSingleRule(ShardingRule.class);
ShardingRuleConfiguration config;
if (rule.isPresent()) {
@@ -136,7 +146,8 @@ public final class ShardingStrategyConfigurationSubscriber implements RuleConfig
@Subscribe
public synchronized void renew(final AddShardingAuditorStrategyConfigurationEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingAuditStrategyConfiguration needToAddedConfig = event.getConfig();
+ ShardingAuditStrategyConfiguration needToAddedConfig = swapShardingAuditorStrategyConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
Optional<ShardingRule> rule = database.getRuleMetaData().findSingleRule(ShardingRule.class);
ShardingRuleConfiguration config;
if (rule.isPresent()) {
@@ -157,7 +168,7 @@ public final class ShardingStrategyConfigurationSubscriber implements RuleConfig
@Subscribe
public synchronized void renew(final AddDefaultShardingColumnEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- String needToAddedConfig = event.getConfig();
+ String needToAddedConfig = instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion());
Optional<ShardingRule> rule = database.getRuleMetaData().findSingleRule(ShardingRule.class);
ShardingRuleConfiguration config;
if (rule.isPresent()) {
@@ -178,7 +189,8 @@ public final class ShardingStrategyConfigurationSubscriber implements RuleConfig
@Subscribe
public synchronized void renew(final AlterDatabaseShardingStrategyConfigurationEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingStrategyConfiguration needToAlteredConfig = event.getConfig();
+ ShardingStrategyConfiguration needToAlteredConfig = swapShardingStrategyConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
config.setDefaultDatabaseShardingStrategy(needToAlteredConfig);
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
@@ -192,7 +204,8 @@ public final class ShardingStrategyConfigurationSubscriber implements RuleConfig
@Subscribe
public synchronized void renew(final AlterTableShardingStrategyConfigurationEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingStrategyConfiguration needToAlteredConfig = event.getConfig();
+ ShardingStrategyConfiguration needToAlteredConfig = swapShardingStrategyConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
config.setDefaultTableShardingStrategy(needToAlteredConfig);
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
@@ -206,7 +219,8 @@ public final class ShardingStrategyConfigurationSubscriber implements RuleConfig
@Subscribe
public synchronized void renew(final AlterKeyGenerateStrategyConfigurationEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- KeyGenerateStrategyConfiguration needToAlteredConfig = event.getConfig();
+ KeyGenerateStrategyConfiguration needToAlteredConfig = swapKeyGenerateStrategyConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
config.setDefaultKeyGenerateStrategy(needToAlteredConfig);
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
@@ -220,7 +234,8 @@ public final class ShardingStrategyConfigurationSubscriber implements RuleConfig
@Subscribe
public synchronized void renew(final AlterShardingAuditorStrategyConfigurationEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingAuditStrategyConfiguration needToAlteredConfig = event.getConfig();
+ ShardingAuditStrategyConfiguration needToAlteredConfig = swapShardingAuditorStrategyConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
config.setDefaultAuditStrategy(needToAlteredConfig);
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
@@ -234,7 +249,7 @@ public final class ShardingStrategyConfigurationSubscriber implements RuleConfig
@Subscribe
public synchronized void renew(final AlterDefaultShardingColumnEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- String needToAlteredConfig = event.getConfig();
+ String needToAlteredConfig = instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion());
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
config.setDefaultShardingColumn(needToAlteredConfig);
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
@@ -304,4 +319,16 @@ public final class ShardingStrategyConfigurationSubscriber implements RuleConfig
config.setDefaultAuditStrategy(null);
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
+
+ private ShardingStrategyConfiguration swapShardingStrategyConfig(final String yamlContext) {
+ return new YamlShardingStrategyConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlShardingStrategyConfiguration.class));
+ }
+
+ private KeyGenerateStrategyConfiguration swapKeyGenerateStrategyConfig(final String yamlContext) {
+ return new YamlKeyGenerateStrategyConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlKeyGenerateStrategyConfiguration.class));
+ }
+
+ private ShardingAuditStrategyConfiguration swapShardingAuditorStrategyConfig(final String yamlContext) {
+ return new YamlShardingAuditStrategyConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlShardingAuditStrategyConfiguration.class));
+ }
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingTableConfigurationSubscriber.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingTableConfigurationSubscriber.java
index 8d4b22125f0..505982ff890 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingTableConfigurationSubscriber.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/subscriber/ShardingTableConfigurationSubscriber.java
@@ -22,6 +22,7 @@ import lombok.RequiredArgsConstructor;
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.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -33,13 +34,15 @@ import org.apache.shardingsphere.sharding.event.table.auto.DeleteShardingAutoTab
import org.apache.shardingsphere.sharding.event.table.binding.AddShardingTableReferenceConfigurationEvent;
import org.apache.shardingsphere.sharding.event.table.binding.AlterShardingTableReferenceConfigurationEvent;
import org.apache.shardingsphere.sharding.event.table.binding.DeleteShardingTableReferenceConfigurationEvent;
-import org.apache.shardingsphere.sharding.event.table.broadcast.AddBroadcastTableConfigurationEvent;
-import org.apache.shardingsphere.sharding.event.table.broadcast.AlterBroadcastTableConfigurationEvent;
-import org.apache.shardingsphere.sharding.event.table.broadcast.DeleteBroadcastTableConfigurationEvent;
import org.apache.shardingsphere.sharding.event.table.sharding.AddShardingTableConfigurationEvent;
import org.apache.shardingsphere.sharding.event.table.sharding.AlterShardingTableConfigurationEvent;
import org.apache.shardingsphere.sharding.event.table.sharding.DeleteShardingTableConfigurationEvent;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.apache.shardingsphere.sharding.yaml.config.rule.YamlShardingAutoTableRuleConfiguration;
+import org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
+import org.apache.shardingsphere.sharding.yaml.swapper.rule.YamlShardingAutoTableRuleConfigurationSwapper;
+import org.apache.shardingsphere.sharding.yaml.swapper.rule.YamlShardingTableReferenceRuleConfigurationConverter;
+import org.apache.shardingsphere.sharding.yaml.swapper.rule.YamlShardingTableRuleConfigurationSwapper;
import java.util.Map;
import java.util.Optional;
@@ -68,12 +71,13 @@ public final class ShardingTableConfigurationSubscriber implements RuleConfigura
* @param event add sharding table configuration event
*/
@Subscribe
- public synchronized void renew(final AddShardingTableConfigurationEvent<ShardingTableRuleConfiguration> event) {
+ public synchronized void renew(final AddShardingTableConfigurationEvent event) {
if (!event.getActiveVersion().equals(instanceContext.getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
}
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingTableRuleConfiguration needToAddedConfig = event.getConfig();
+ ShardingTableRuleConfiguration needToAddedConfig = swapShardingTableRuleConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
Optional<ShardingRule> rule = database.getRuleMetaData().findSingleRule(ShardingRule.class);
ShardingRuleConfiguration config;
if (rule.isPresent()) {
@@ -93,12 +97,13 @@ public final class ShardingTableConfigurationSubscriber implements RuleConfigura
* @param event add sharding auto table configuration event
*/
@Subscribe
- public synchronized void renew(final AddShardingAutoTableConfigurationEvent<ShardingAutoTableRuleConfiguration> event) {
+ public synchronized void renew(final AddShardingAutoTableConfigurationEvent event) {
if (!event.getActiveVersion().equals(instanceContext.getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
}
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingAutoTableRuleConfiguration needToAddedConfig = event.getConfig();
+ ShardingAutoTableRuleConfiguration needToAddedConfig = swapShardingAutoTableRuleConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
Optional<ShardingRule> rule = database.getRuleMetaData().findSingleRule(ShardingRule.class);
ShardingRuleConfiguration config;
if (rule.isPresent()) {
@@ -118,9 +123,10 @@ public final class ShardingTableConfigurationSubscriber implements RuleConfigura
* @param event add sharding auto table configuration event
*/
@Subscribe
- public synchronized void renew(final AddShardingTableReferenceConfigurationEvent<ShardingTableReferenceRuleConfiguration> event) {
+ public synchronized void renew(final AddShardingTableReferenceConfigurationEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingTableReferenceRuleConfiguration needToAddedConfig = event.getConfig();
+ ShardingTableReferenceRuleConfiguration needToAddedConfig = swapShardingTableReferenceRuleConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
Optional<ShardingRule> rule = database.getRuleMetaData().findSingleRule(ShardingRule.class);
ShardingRuleConfiguration config;
if (rule.isPresent()) {
@@ -134,39 +140,19 @@ public final class ShardingTableConfigurationSubscriber implements RuleConfigura
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
- /**
- * Renew with add broadcast table configuration.
- *
- * @param event add broadcast table configuration event
- */
- @Subscribe
- public synchronized void renew(final AddBroadcastTableConfigurationEvent event) {
- if (!event.getActiveVersion().equals(instanceContext.getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
- return;
- }
- ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- Optional<ShardingRule> rule = database.getRuleMetaData().findSingleRule(ShardingRule.class);
- ShardingRuleConfiguration config;
- if (rule.isPresent()) {
- config = (ShardingRuleConfiguration) rule.get().getConfiguration();
- } else {
- config = new ShardingRuleConfiguration();
- }
- instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
- }
-
/**
* Renew with alter sharding table configuration.
*
* @param event alter sharding table configuration event
*/
@Subscribe
- public synchronized void renew(final AlterShardingTableConfigurationEvent<ShardingTableRuleConfiguration> event) {
+ public synchronized void renew(final AlterShardingTableConfigurationEvent event) {
if (!event.getActiveVersion().equals(instanceContext.getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
}
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingTableRuleConfiguration needToAlteredConfig = event.getConfig();
+ ShardingTableRuleConfiguration needToAlteredConfig = swapShardingTableRuleConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
config.getTables().removeIf(each -> each.getLogicTable().equals(event.getTableName()));
config.getTables().add(needToAlteredConfig);
@@ -179,12 +165,13 @@ public final class ShardingTableConfigurationSubscriber implements RuleConfigura
* @param event alter sharding auto table configuration event
*/
@Subscribe
- public synchronized void renew(final AlterShardingAutoTableConfigurationEvent<ShardingAutoTableRuleConfiguration> event) {
+ public synchronized void renew(final AlterShardingAutoTableConfigurationEvent event) {
if (!event.getActiveVersion().equals(instanceContext.getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
}
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingAutoTableRuleConfiguration needToAlteredConfig = event.getConfig();
+ ShardingAutoTableRuleConfiguration needToAlteredConfig = swapShardingAutoTableRuleConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
config.getAutoTables().removeIf(each -> each.getLogicTable().equals(event.getTableName()));
config.getAutoTables().add(needToAlteredConfig);
@@ -197,30 +184,16 @@ public final class ShardingTableConfigurationSubscriber implements RuleConfigura
* @param event alter sharding table reference configuration event
*/
@Subscribe
- public synchronized void renew(final AlterShardingTableReferenceConfigurationEvent<ShardingTableReferenceRuleConfiguration> event) {
+ public synchronized void renew(final AlterShardingTableReferenceConfigurationEvent event) {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingTableReferenceRuleConfiguration needToAlteredConfig = event.getConfig();
+ ShardingTableReferenceRuleConfiguration needToAlteredConfig = swapShardingTableReferenceRuleConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
config.getBindingTableGroups().removeIf(each -> each.getName().equals(event.getTableName()));
config.getBindingTableGroups().add(needToAlteredConfig);
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
- /**
- * Renew with alter broadcast table configuration.
- *
- * @param event alter broadcast table configuration event
- */
- @Subscribe
- public synchronized void renew(final AlterBroadcastTableConfigurationEvent event) {
- if (!event.getActiveVersion().equals(instanceContext.getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
- return;
- }
- ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
- instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
- }
-
/**
* Renew with delete sharding table configuration.
*
@@ -228,9 +201,6 @@ public final class ShardingTableConfigurationSubscriber implements RuleConfigura
*/
@Subscribe
public synchronized void renew(final DeleteShardingTableConfigurationEvent event) {
- if (!event.getActiveVersion().equals(instanceContext.getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
- return;
- }
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
config.getTables().removeIf(each -> each.getLogicTable().equals(event.getTableName()));
@@ -244,9 +214,6 @@ public final class ShardingTableConfigurationSubscriber implements RuleConfigura
*/
@Subscribe
public synchronized void renew(final DeleteShardingAutoTableConfigurationEvent event) {
- if (!event.getActiveVersion().equals(instanceContext.getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
- return;
- }
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
config.getAutoTables().removeIf(each -> each.getLogicTable().equals(event.getTableName()));
@@ -266,18 +233,15 @@ public final class ShardingTableConfigurationSubscriber implements RuleConfigura
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
- /**
- * Renew with delete broadcast table configuration.
- *
- * @param event delete broadcast table configuration event
- */
- @Subscribe
- public synchronized void renew(final DeleteBroadcastTableConfigurationEvent event) {
- if (!event.getActiveVersion().equals(instanceContext.getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
- return;
- }
- ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- ShardingRuleConfiguration config = (ShardingRuleConfiguration) database.getRuleMetaData().getSingleRule(ShardingRule.class).getConfiguration();
- instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ private ShardingTableRuleConfiguration swapShardingTableRuleConfig(final String yamlContext) {
+ return new YamlShardingTableRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlTableRuleConfiguration.class));
+ }
+
+ private ShardingAutoTableRuleConfiguration swapShardingAutoTableRuleConfig(final String yamlContext) {
+ return new YamlShardingAutoTableRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlShardingAutoTableRuleConfiguration.class));
+ }
+
+ private ShardingTableReferenceRuleConfiguration swapShardingTableReferenceRuleConfig(final String yamlContext) {
+ return YamlShardingTableReferenceRuleConfigurationConverter.convertToObject(yamlContext);
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/converter/ShardingNodeConverterTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/converter/ShardingNodeConverterTest.java
index 30708eaa0f8..51af7b819b0 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/converter/ShardingNodeConverterTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/converter/ShardingNodeConverterTest.java
@@ -161,86 +161,74 @@ class ShardingNodeConverterTest {
}
@Test
- void assertGetTableNameVersion() {
- Optional<String> actual = ShardingNodeConverter.getTableNameVersion("/metadata/foo_db/rules/sharding/tables/foo_table/versions/1");
+ void assertGetTableNameByActiveVersionPath() {
+ Optional<String> actual = ShardingNodeConverter.getTableNameByActiveVersionPath("/metadata/foo_db/rules/sharding/tables/foo_table/active_version");
assertTrue(actual.isPresent());
- assertThat(actual.get(), is("1"));
+ assertThat(actual.get(), is("foo_table"));
}
@Test
- void assertGetAutoTableNameVersion() {
- Optional<String> actual = ShardingNodeConverter.getAutoTableNameVersion("/metadata/foo_db/rules/sharding/auto_tables/foo_table/versions/1");
+ void assertGetAutoTableNameByActiveVersionPath() {
+ Optional<String> actual = ShardingNodeConverter.getAutoTableNameByActiveVersionPath("/metadata/foo_db/rules/sharding/auto_tables/foo_table/active_version");
assertTrue(actual.isPresent());
- assertThat(actual.get(), is("1"));
+ assertThat(actual.get(), is("foo_table"));
}
@Test
- void assertGetBindingTableNameVersion() {
- Optional<String> actual = ShardingNodeConverter.getBindingTableNameVersion("/metadata/foo_db/rules/sharding/binding_tables/c018fb3cd8e530dd/versions/1");
+ void assertGetBindingTableNameByActiveVersionPath() {
+ Optional<String> actual = ShardingNodeConverter.getBindingTableNameByActiveVersionPath("/metadata/foo_db/rules/sharding/binding_tables/c018fb3cd8e530dd/active_version");
assertTrue(actual.isPresent());
- assertThat(actual.get(), is("1"));
+ assertThat(actual.get(), is("c018fb3cd8e530dd"));
}
@Test
- void assertGetDefaultDatabaseStrategyVersion() {
- Optional<String> actual = ShardingNodeConverter.getDefaultDatabaseStrategyVersion("/metadata/foo_db/rules/sharding/default_strategies/default_database_strategy/versions/1");
- assertTrue(actual.isPresent());
- assertThat(actual.get(), is("1"));
+ void assertIsDefaultDatabaseStrategyByActiveVersionPath() {
+ assertTrue(ShardingNodeConverter.isDefaultDatabaseStrategyWithActiveVersionPath("/metadata/foo_db/rules/sharding/default_strategies/default_database_strategy/active_version"));
}
@Test
- void assertGetDefaultTableStrategyVersion() {
- Optional<String> actual = ShardingNodeConverter.getDefaultTableStrategyVersion("/metadata/foo_db/rules/sharding/default_strategies/default_table_strategy/versions/1");
- assertTrue(actual.isPresent());
- assertThat(actual.get(), is("1"));
+ void assertIsDefaultTableStrategyByActiveVersionPath() {
+ assertTrue(ShardingNodeConverter.isDefaultTableStrategyWithActiveVersionPath("/metadata/foo_db/rules/sharding/default_strategies/default_table_strategy/active_version"));
}
@Test
- void assertGetDefaultKeyGenerateStrategyVersion() {
- Optional<String> actual = ShardingNodeConverter.getDefaultKeyGenerateStrategyVersion("/metadata/foo_db/rules/sharding/default_strategies/default_key_generate_strategy/versions/1");
- assertTrue(actual.isPresent());
- assertThat(actual.get(), is("1"));
+ void assertIsDefaultKeyGenerateStrategyByActiveVersionPath() {
+ assertTrue(ShardingNodeConverter.isDefaultKeyGenerateStrategyWithActiveVersionPath("/metadata/foo_db/rules/sharding/default_strategies/default_key_generate_strategy/active_version"));
}
@Test
- void assertGetDefaultAuditStrategyVersion() {
- Optional<String> actual = ShardingNodeConverter.getDefaultAuditStrategyVersion("/metadata/foo_db/rules/sharding/default_strategies/default_audit_strategy/versions/1");
- assertTrue(actual.isPresent());
- assertThat(actual.get(), is("1"));
+ void assertIsDefaultAuditStrategyByActiveVersionPath() {
+ assertTrue(ShardingNodeConverter.isDefaultAuditStrategyWithActiveVersionPath("/metadata/foo_db/rules/sharding/default_strategies/default_audit_strategy/active_version"));
}
@Test
- void assertGetDefaultShardingColumnVersion() {
- Optional<String> actual = ShardingNodeConverter.getDefaultShardingColumnVersion("/metadata/foo_db/rules/sharding/default_strategies/default_sharding_column/versions/1");
- assertTrue(actual.isPresent());
- assertThat(actual.get(), is("1"));
+ void assertIsDefaultShardingColumnByActiveVersionPath() {
+ assertTrue(ShardingNodeConverter.isDefaultShardingColumnWithActiveVersionPath("/metadata/foo_db/rules/sharding/default_strategies/default_sharding_column/active_version"));
}
@Test
- void assertGetShardingAlgorithmVersion() {
- Optional<String> actual = ShardingNodeConverter.getShardingAlgorithmVersion("/metadata/foo_db/rules/sharding/algorithms/foo_table_algorithm/versions/1");
+ void assertGetShardingAlgorithmByActiveVersionPath() {
+ Optional<String> actual = ShardingNodeConverter.getShardingAlgorithmByActiveVersionPath("/metadata/foo_db/rules/sharding/algorithms/foo_table_algorithm/active_version");
assertTrue(actual.isPresent());
- assertThat(actual.get(), is("1"));
+ assertThat(actual.get(), is("foo_table_algorithm"));
}
@Test
- void assertGetKeyGeneratorVersion() {
- Optional<String> actual = ShardingNodeConverter.getKeyGeneratorVersion("/metadata/foo_db/rules/sharding/key_generators/foo_table_key_generator/versions/1");
+ void assertGetKeyGeneratorByActiveVersionPath() {
+ Optional<String> actual = ShardingNodeConverter.getKeyGeneratorByActiveVersionPath("/metadata/foo_db/rules/sharding/key_generators/foo_table_key_generator/active_version");
assertTrue(actual.isPresent());
- assertThat(actual.get(), is("1"));
+ assertThat(actual.get(), is("foo_table_key_generator"));
}
@Test
- void assertGetAuditorVersion() {
- Optional<String> actual = ShardingNodeConverter.getAuditorVersion("/metadata/foo_db/rules/sharding/auditors/foo_table_auditor/versions/1");
+ void assertGetAuditorByActiveVersionPath() {
+ Optional<String> actual = ShardingNodeConverter.getAuditorByActiveVersionPath("/metadata/foo_db/rules/sharding/auditors/foo_table_auditor/active_version");
assertTrue(actual.isPresent());
- assertThat(actual.get(), is("1"));
+ assertThat(actual.get(), is("foo_table_auditor"));
}
@Test
- void assertGetShardingCacheVersion() {
- Optional<String> actual = ShardingNodeConverter.getShardingCacheVersion("/metadata/foo_db/rules/sharding/sharding_cache/versions/1");
- assertTrue(actual.isPresent());
- assertThat(actual.get(), is("1"));
+ void assertGetShardingCacheByActiveVersionPath() {
+ assertTrue(ShardingNodeConverter.isShardingCacheWithActiveVersionPath("/metadata/foo_db/rules/sharding/sharding_cache/active_version"));
}
}