This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 2af600dbf4f Add PartialRuleUpdateSupported on MaskRule (#31189)
2af600dbf4f is described below
commit 2af600dbf4fb1205c3a08972fb95e95f02b896fe
Author: Liang Zhang <[email protected]>
AuthorDate: Fri May 10 11:26:06 2024 +0800
Add PartialRuleUpdateSupported on MaskRule (#31189)
* Rename CreateOrAlterTableEvent
* Rename CreateOrAlterViewEvent
* Refactor MetaDataVersion
* Refactor PartialRuleUpdateSupported
* Add PartialRuleUpdateSupported on MaskRule
* Update todo
* Fix test cases
* Fix test cases
---
.../shardingsphere/encrypt/rule/EncryptRule.java | 24 +++---
.../attribute/EncryptTableMapperRuleAttribute.java | 6 +-
.../EncryptTableMapperRuleAttributeTest.java | 3 +-
.../apache/shardingsphere/mask/rule/MaskRule.java | 85 ++++++++++++++++++----
.../attribute/MaskTableMapperRuleAttribute.java | 6 +-
.../MaskTableMapperRuleAttributeTest.java | 3 +-
.../infra/metadata/version/MetaDataVersion.java | 4 +-
.../infra/rule/PartialRuleUpdateSupported.java | 2 +-
.../update/AlterSQLFederationRuleExecutorTest.java | 4 +-
...ableEvent.java => CreateOrAlterTableEvent.java} | 4 +-
...rViewEvent.java => CreateOrAlterViewEvent.java} | 4 +-
.../context/ConfigurationContextManager.java | 4 +-
.../metadata/watcher/MetaDataChangedWatcher.java | 8 +-
.../ResourceMetaDataChangedSubscriber.java | 12 +--
14 files changed, 112 insertions(+), 57 deletions(-)
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
index c538eaec53a..ff2ad2c373a 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.encrypt.rule;
import com.google.common.base.Preconditions;
-import lombok.Getter;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
@@ -35,7 +34,6 @@ import
org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
@@ -51,12 +49,11 @@ public final class EncryptRule implements DatabaseRule,
PartialRuleUpdateSupport
private final AtomicReference<EncryptRuleConfiguration> ruleConfig = new
AtomicReference<>();
- private final Map<String, EncryptTable> tables;
-
private final ConcurrentHashMap<String, EncryptAlgorithm> encryptors;
- @Getter
- private final RuleAttributes attributes;
+ private final ConcurrentHashMap<String, EncryptTable> tables;
+
+ private final AtomicReference<RuleAttributes> attributes = new
AtomicReference<>();
public EncryptRule(final String databaseName, final
EncryptRuleConfiguration ruleConfig) {
this.databaseName = databaseName;
@@ -67,7 +64,7 @@ public final class EncryptRule implements DatabaseRule,
PartialRuleUpdateSupport
each.getColumns().forEach(this::checkEncryptorType);
tables.put(each.getName().toLowerCase(), new EncryptTable(each,
encryptors));
}
- attributes = new RuleAttributes(new
EncryptTableMapperRuleAttribute(ruleConfig.getTables()));
+ attributes.set(new RuleAttributes(new
EncryptTableMapperRuleAttribute(tables.keySet())));
}
private ConcurrentHashMap<String, EncryptAlgorithm> createEncryptors(final
EncryptRuleConfiguration ruleConfig) {
@@ -122,6 +119,11 @@ public final class EncryptRule implements DatabaseRule,
PartialRuleUpdateSupport
return encryptTable.get();
}
+ @Override
+ public RuleAttributes getAttributes() {
+ return attributes.get();
+ }
+
@Override
public EncryptRuleConfiguration getConfiguration() {
return ruleConfig.get();
@@ -133,22 +135,24 @@ public final class EncryptRule implements DatabaseRule,
PartialRuleUpdateSupport
}
@Override
- public boolean partialUpdateRule(final EncryptRuleConfiguration
toBeUpdatedRuleConfig) {
+ public boolean partialUpdate(final EncryptRuleConfiguration
toBeUpdatedRuleConfig) {
Collection<String> toBeAddedTableNames =
toBeUpdatedRuleConfig.getTables().stream().map(EncryptTableRuleConfiguration::getName).collect(Collectors.toList());
toBeAddedTableNames.removeAll(tables.keySet());
if (!toBeAddedTableNames.isEmpty()) {
toBeAddedTableNames.forEach(each -> addTableRule(each,
toBeUpdatedRuleConfig));
+ attributes.set(new RuleAttributes(new
EncryptTableMapperRuleAttribute(tables.keySet())));
return true;
}
Collection<String> toBeRemovedTableNames = new
HashSet<>(tables.keySet());
toBeRemovedTableNames.removeAll(toBeUpdatedRuleConfig.getTables().stream().map(EncryptTableRuleConfiguration::getName).collect(Collectors.toList()));
if (!toBeRemovedTableNames.isEmpty()) {
toBeRemovedTableNames.stream().map(String::toLowerCase).forEach(tables::remove);
- // TODO check and remove unused encryptors
+ attributes.set(new RuleAttributes(new
EncryptTableMapperRuleAttribute(tables.keySet())));
+ // TODO check and remove unused INLINE encryptors
return true;
}
// TODO Process update table
- // TODO Process update encryptors
+ // TODO Process CRUD encryptors
return false;
}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/attribute/EncryptTableMapperRuleAttribute.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/attribute/EncryptTableMapperRuleAttribute.java
index 835400a8308..9b6edde3d63 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/attribute/EncryptTableMapperRuleAttribute.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/attribute/EncryptTableMapperRuleAttribute.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.encrypt.rule.attribute;
import com.cedarsoftware.util.CaseInsensitiveSet;
-import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import
org.apache.shardingsphere.infra.rule.attribute.table.TableMapperRuleAttribute;
import java.util.Collection;
@@ -31,9 +30,8 @@ public final class EncryptTableMapperRuleAttribute implements
TableMapperRuleAtt
private final CaseInsensitiveSet<String> logicalTableMapper;
- public EncryptTableMapperRuleAttribute(final
Collection<EncryptTableRuleConfiguration> tables) {
- logicalTableMapper = new CaseInsensitiveSet<>();
-
tables.stream().map(EncryptTableRuleConfiguration::getName).forEach(logicalTableMapper::add);
+ public EncryptTableMapperRuleAttribute(final Collection<String>
encryptTableNames) {
+ logicalTableMapper = new CaseInsensitiveSet<>(encryptTableNames);
}
@Override
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/attribute/EncryptTableMapperRuleAttributeTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/attribute/EncryptTableMapperRuleAttributeTest.java
index b6aaf583978..4f42cedb6ab 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/attribute/EncryptTableMapperRuleAttributeTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/attribute/EncryptTableMapperRuleAttributeTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.encrypt.rule.attribute;
-import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.junit.jupiter.api.Test;
import java.util.Collections;
@@ -28,7 +27,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
class EncryptTableMapperRuleAttributeTest {
- private final EncryptTableMapperRuleAttribute ruleAttribute = new
EncryptTableMapperRuleAttribute(Collections.singleton(new
EncryptTableRuleConfiguration("foo_tbl", Collections.emptyList())));
+ private final EncryptTableMapperRuleAttribute ruleAttribute = new
EncryptTableMapperRuleAttribute(Collections.singleton("foo_tbl"));
@Test
void assertGetLogicTableMapper() {
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskRule.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskRule.java
index b0439e2ff17..560eeb4002f 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskRule.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskRule.java
@@ -17,41 +17,47 @@
package org.apache.shardingsphere.mask.rule;
-import com.cedarsoftware.util.CaseInsensitiveMap;
-import lombok.Getter;
+import com.google.common.base.Preconditions;
+import
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
+import org.apache.shardingsphere.infra.rule.PartialRuleUpdateSupported;
import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes;
import org.apache.shardingsphere.infra.rule.scope.DatabaseRule;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
+import
org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
import
org.apache.shardingsphere.mask.rule.attribute.MaskTableMapperRuleAttribute;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
-import java.util.Map;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* Mask rule.
*/
-public final class MaskRule implements DatabaseRule {
+public final class MaskRule implements DatabaseRule,
PartialRuleUpdateSupported<MaskRuleConfiguration> {
- @Getter
- private final MaskRuleConfiguration configuration;
+ private final AtomicReference<MaskRuleConfiguration> configuration = new
AtomicReference<>();
- private final Map<String, MaskTable> tables;
+ private final ConcurrentHashMap<String, MaskAlgorithm<?, ?>>
maskAlgorithms;
- @Getter
- private final RuleAttributes attributes;
+ private final ConcurrentHashMap<String, MaskTable> tables;
+
+ private final AtomicReference<RuleAttributes> attributes = new
AtomicReference<>();
@SuppressWarnings("unchecked")
public MaskRule(final MaskRuleConfiguration ruleConfig) {
- configuration = ruleConfig;
- Map<String, MaskAlgorithm<?, ?>> maskAlgorithms =
ruleConfig.getMaskAlgorithms().entrySet().stream()
- .collect(Collectors.toMap(Entry::getKey, entry ->
TypedSPILoader.getService(MaskAlgorithm.class, entry.getValue().getType(),
entry.getValue().getProps())));
+ configuration.set(ruleConfig);
+ maskAlgorithms = ruleConfig.getMaskAlgorithms().entrySet().stream()
+ .collect(Collectors.toMap(Entry::getKey, entry ->
TypedSPILoader.getService(MaskAlgorithm.class, entry.getValue().getType(),
entry.getValue().getProps()),
+ (oldValue, currentValue) -> oldValue,
ConcurrentHashMap::new));
tables = ruleConfig.getTables().stream()
- .collect(Collectors.toMap(each ->
each.getName().toLowerCase(), each -> new MaskTable(each, maskAlgorithms),
(oldValue, currentValue) -> oldValue, CaseInsensitiveMap::new));
- attributes = new RuleAttributes(new
MaskTableMapperRuleAttribute(ruleConfig.getTables()));
+ .collect(Collectors.toMap(each ->
each.getName().toLowerCase(), each -> new MaskTable(each, maskAlgorithms),
(oldValue, currentValue) -> oldValue, ConcurrentHashMap::new));
+ attributes.set(new RuleAttributes(new
MaskTableMapperRuleAttribute(tables.keySet())));
}
/**
@@ -63,4 +69,55 @@ public final class MaskRule implements DatabaseRule {
public Optional<MaskTable> findMaskTable(final String tableName) {
return Optional.ofNullable(tables.get(tableName));
}
+
+ @Override
+ public RuleAttributes getAttributes() {
+ return attributes.get();
+ }
+
+ @Override
+ public MaskRuleConfiguration getConfiguration() {
+ return configuration.get();
+ }
+
+ @Override
+ public void updateConfiguration(final MaskRuleConfiguration
toBeUpdatedRuleConfig) {
+ configuration.set(toBeUpdatedRuleConfig);
+ }
+
+ @Override
+ public boolean partialUpdate(final MaskRuleConfiguration
toBeUpdatedRuleConfig) {
+ Collection<String> toBeAddedTableNames =
toBeUpdatedRuleConfig.getTables().stream().map(MaskTableRuleConfiguration::getName).collect(Collectors.toList());
+ toBeAddedTableNames.removeAll(tables.keySet());
+ if (!toBeAddedTableNames.isEmpty()) {
+ toBeAddedTableNames.forEach(each -> addTableRule(each,
toBeUpdatedRuleConfig));
+ attributes.set(new RuleAttributes(new
MaskTableMapperRuleAttribute(tables.keySet())));
+ return true;
+ }
+ Collection<String> toBeRemovedTableNames = new
HashSet<>(tables.keySet());
+
toBeRemovedTableNames.removeAll(toBeUpdatedRuleConfig.getTables().stream().map(MaskTableRuleConfiguration::getName).collect(Collectors.toList()));
+ if (!toBeRemovedTableNames.isEmpty()) {
+
toBeRemovedTableNames.stream().map(String::toLowerCase).forEach(tables::remove);
+ attributes.set(new RuleAttributes(new
MaskTableMapperRuleAttribute(tables.keySet())));
+ // TODO check and remove unused INLINE mask algorithms
+ return true;
+ }
+ // TODO Process update table
+ // TODO Process CRUD mask algorithms
+ return false;
+ }
+
+ private void addTableRule(final String tableName, final
MaskRuleConfiguration toBeUpdatedRuleConfig) {
+ MaskTableRuleConfiguration tableRuleConfig =
getTableRuleConfiguration(tableName, toBeUpdatedRuleConfig);
+ for (Entry<String, AlgorithmConfiguration> entry :
toBeUpdatedRuleConfig.getMaskAlgorithms().entrySet()) {
+ maskAlgorithms.computeIfAbsent(entry.getKey(), key ->
TypedSPILoader.getService(MaskAlgorithm.class, entry.getValue().getType(),
entry.getValue().getProps()));
+ }
+ tables.put(tableName.toLowerCase(), new MaskTable(tableRuleConfig,
maskAlgorithms));
+ }
+
+ private MaskTableRuleConfiguration getTableRuleConfiguration(final String
tableName, final MaskRuleConfiguration toBeUpdatedRuleConfig) {
+ Optional<MaskTableRuleConfiguration> result =
toBeUpdatedRuleConfig.getTables().stream().filter(table ->
table.getName().equals(tableName)).findFirst();
+ Preconditions.checkState(result.isPresent());
+ return result.get();
+ }
}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/attribute/MaskTableMapperRuleAttribute.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/attribute/MaskTableMapperRuleAttribute.java
index 9f7813bae42..f928926d87f 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/attribute/MaskTableMapperRuleAttribute.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/attribute/MaskTableMapperRuleAttribute.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.mask.rule.attribute;
import com.cedarsoftware.util.CaseInsensitiveSet;
import
org.apache.shardingsphere.infra.rule.attribute.table.TableMapperRuleAttribute;
-import
org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
import java.util.Collection;
import java.util.Collections;
@@ -31,9 +30,8 @@ public final class MaskTableMapperRuleAttribute implements
TableMapperRuleAttrib
private final CaseInsensitiveSet<String> logicalTableMapper;
- public MaskTableMapperRuleAttribute(final
Collection<MaskTableRuleConfiguration> tables) {
- logicalTableMapper = new CaseInsensitiveSet<>();
-
tables.stream().map(MaskTableRuleConfiguration::getName).forEach(logicalTableMapper::add);
+ public MaskTableMapperRuleAttribute(final Collection<String>
maskTableNames) {
+ logicalTableMapper = new CaseInsensitiveSet<>(maskTableNames);
}
@Override
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/attribute/MaskTableMapperRuleAttributeTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/attribute/MaskTableMapperRuleAttributeTest.java
index 692dc24e170..24c4ca203f6 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/attribute/MaskTableMapperRuleAttributeTest.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/attribute/MaskTableMapperRuleAttributeTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.mask.rule.attribute;
-import
org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
import org.junit.jupiter.api.Test;
import java.util.Collections;
@@ -28,7 +27,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
class MaskTableMapperRuleAttributeTest {
- private final MaskTableMapperRuleAttribute ruleAttribute = new
MaskTableMapperRuleAttribute(Collections.singleton(new
MaskTableRuleConfiguration("foo_tbl", Collections.emptyList())));
+ private final MaskTableMapperRuleAttribute ruleAttribute = new
MaskTableMapperRuleAttribute(Collections.singleton("foo_tbl"));
@Test
void assertGetLogicTableMapper() {
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/version/MetaDataVersion.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/version/MetaDataVersion.java
index 15b54c364a0..d2c7cae8296 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/version/MetaDataVersion.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/version/MetaDataVersion.java
@@ -40,8 +40,8 @@ public final class MetaDataVersion {
public MetaDataVersion(final String key) {
this.key = key;
- this.currentActiveVersion = "";
- this.nextActiveVersion = "";
+ currentActiveVersion = "";
+ nextActiveVersion = "";
}
/**
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/PartialRuleUpdateSupported.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/PartialRuleUpdateSupported.java
index 48b9773f997..cc861b4d130 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/PartialRuleUpdateSupported.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/PartialRuleUpdateSupported.java
@@ -40,5 +40,5 @@ public interface PartialRuleUpdateSupported<T extends
RuleConfiguration> {
* @return update success or not
*/
// TODO remove return value when support alter
- boolean partialUpdateRule(T toBeUpdatedRuleConfig);
+ boolean partialUpdate(T toBeUpdatedRuleConfig);
}
diff --git
a/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/update/AlterSQLFederationRuleExecutorTest.java
b/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/update/AlterSQLFederationRuleExecutorTest.java
index 0568c4491a7..aa7035a2df8 100644
---
a/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/update/AlterSQLFederationRuleExecutorTest.java
+++
b/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/update/AlterSQLFederationRuleExecutorTest.java
@@ -43,14 +43,14 @@ class AlterSQLFederationRuleExecutorTest {
}
@Test
- void testExecuteWithNullStatement() {
+ void assertExecuteWithNullStatement() {
AlterSQLFederationRuleStatement sqlStatement = new
AlterSQLFederationRuleStatement(null, null, null);
engine = new DistSQLUpdateExecuteEngine(sqlStatement, null,
mockContextManager());
assertDoesNotThrow(() -> engine.executeUpdate());
}
@Test
- void testExecuteWithNullCacheOptionSegment() {
+ void assertExecuteWithNullCacheOptionSegment() {
AlterSQLFederationRuleStatement sqlStatement = new
AlterSQLFederationRuleStatement(null, null, new CacheOptionSegment(null, null));
engine = new DistSQLUpdateExecuteEngine(sqlStatement, null,
mockContextManager());
assertDoesNotThrow(() -> engine.executeUpdate());
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/schema/table/AlterTableEvent.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/schema/table/CreateOrAlterTableEvent.java
similarity index 92%
rename from
mode/core/src/main/java/org/apache/shardingsphere/mode/event/schema/table/AlterTableEvent.java
rename to
mode/core/src/main/java/org/apache/shardingsphere/mode/event/schema/table/CreateOrAlterTableEvent.java
index 4012f7303be..35d2cf225fb 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/schema/table/AlterTableEvent.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/schema/table/CreateOrAlterTableEvent.java
@@ -22,11 +22,11 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Alter table event.
+ * Create or alter table event.
*/
@RequiredArgsConstructor
@Getter
-public final class AlterTableEvent implements GovernanceEvent {
+public final class CreateOrAlterTableEvent implements GovernanceEvent {
private final String databaseName;
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/schema/view/AlterViewEvent.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/schema/view/CreateOrAlterViewEvent.java
similarity index 92%
rename from
mode/core/src/main/java/org/apache/shardingsphere/mode/event/schema/view/AlterViewEvent.java
rename to
mode/core/src/main/java/org/apache/shardingsphere/mode/event/schema/view/CreateOrAlterViewEvent.java
index b4485ccca01..a003b3f4ee2 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/schema/view/AlterViewEvent.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/schema/view/CreateOrAlterViewEvent.java
@@ -22,11 +22,11 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
/**
- * Alter view event.
+ * Create or alter view event.
*/
@RequiredArgsConstructor
@Getter
-public final class AlterViewEvent implements GovernanceEvent {
+public final class CreateOrAlterViewEvent implements GovernanceEvent {
private final String databaseName;
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java
index 876b57a29da..f74ead222df 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java
@@ -160,7 +160,7 @@ public final class ConfigurationContextManager {
ShardingSphereDatabase database =
metaDataContexts.get().getMetaData().getDatabase(databaseName);
Collection<ShardingSphereRule> rules = new
LinkedList<>(database.getRuleMetaData().getRules());
Optional<ShardingSphereRule> toBeChangedRule =
rules.stream().filter(each ->
each.getConfiguration().getClass().equals(ruleConfig.getClass())).findFirst();
- if (toBeChangedRule.isPresent() && toBeChangedRule.get() instanceof
PartialRuleUpdateSupported && ((PartialRuleUpdateSupported)
toBeChangedRule.get()).partialUpdateRule(ruleConfig)) {
+ if (toBeChangedRule.isPresent() && toBeChangedRule.get() instanceof
PartialRuleUpdateSupported && ((PartialRuleUpdateSupported)
toBeChangedRule.get()).partialUpdate(ruleConfig)) {
((PartialRuleUpdateSupported)
toBeChangedRule.get()).updateConfiguration(ruleConfig);
return;
}
@@ -187,7 +187,7 @@ public final class ConfigurationContextManager {
ShardingSphereDatabase database =
metaDataContexts.get().getMetaData().getDatabase(databaseName);
Collection<ShardingSphereRule> rules = new
LinkedList<>(database.getRuleMetaData().getRules());
Optional<ShardingSphereRule> toBeChangedRule =
rules.stream().filter(each ->
each.getConfiguration().getClass().equals(ruleConfig.getClass())).findFirst();
- if (toBeChangedRule.isPresent() && toBeChangedRule.get() instanceof
PartialRuleUpdateSupported && ((PartialRuleUpdateSupported)
toBeChangedRule.get()).partialUpdateRule(ruleConfig)) {
+ if (toBeChangedRule.isPresent() && toBeChangedRule.get() instanceof
PartialRuleUpdateSupported && ((PartialRuleUpdateSupported)
toBeChangedRule.get()).partialUpdate(ruleConfig)) {
((PartialRuleUpdateSupported)
toBeChangedRule.get()).updateConfiguration(ruleConfig);
return;
}
diff --git
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/MetaDataChangedWatcher.java
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/MetaDataChangedWatcher.java
index 94b1728ab9b..ad2aac6d171 100644
---
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/MetaDataChangedWatcher.java
+++
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/MetaDataChangedWatcher.java
@@ -31,9 +31,9 @@ import
org.apache.shardingsphere.mode.event.datasource.nodes.UnregisterStorageNo
import
org.apache.shardingsphere.mode.event.datasource.unit.AlterStorageUnitEvent;
import
org.apache.shardingsphere.mode.event.datasource.unit.RegisterStorageUnitEvent;
import
org.apache.shardingsphere.mode.event.datasource.unit.UnregisterStorageUnitEvent;
-import org.apache.shardingsphere.mode.event.schema.table.AlterTableEvent;
+import
org.apache.shardingsphere.mode.event.schema.table.CreateOrAlterTableEvent;
import org.apache.shardingsphere.mode.event.schema.table.DropTableEvent;
-import org.apache.shardingsphere.mode.event.schema.view.AlterViewEvent;
+import org.apache.shardingsphere.mode.event.schema.view.CreateOrAlterViewEvent;
import org.apache.shardingsphere.mode.event.schema.view.DropViewEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcher;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.DatabaseAddedEvent;
@@ -124,7 +124,7 @@ public final class MetaDataChangedWatcher implements
GovernanceWatcher<Governanc
if ((Type.ADDED == event.getType() || Type.UPDATED == event.getType())
&& TableMetaDataNode.isTableActiveVersionNode(event.getKey())) {
Optional<String> tableName =
TableMetaDataNode.getTableNameByActiveVersionNode(event.getKey());
Preconditions.checkState(tableName.isPresent(), "Not found table
name.");
- return Optional.of(new AlterTableEvent(databaseName, schemaName,
tableName.get(), event.getKey(), event.getValue()));
+ return Optional.of(new CreateOrAlterTableEvent(databaseName,
schemaName, tableName.get(), event.getKey(), event.getValue()));
}
return Optional.empty();
}
@@ -138,7 +138,7 @@ public final class MetaDataChangedWatcher implements
GovernanceWatcher<Governanc
if ((Type.ADDED == event.getType() || Type.UPDATED == event.getType())
&& ViewMetaDataNode.isViewActiveVersionNode(event.getKey())) {
Optional<String> viewName =
ViewMetaDataNode.getViewNameByActiveVersionNode(event.getKey());
Preconditions.checkState(viewName.isPresent(), "Not found view
name.");
- return Optional.of(new AlterViewEvent(databaseName, schemaName,
viewName.get(), event.getKey(), event.getValue()));
+ return Optional.of(new CreateOrAlterViewEvent(databaseName,
schemaName, viewName.get(), event.getKey(), event.getValue()));
}
return Optional.empty();
}
diff --git
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ResourceMetaDataChangedSubscriber.java
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ResourceMetaDataChangedSubscriber.java
index 437dee21725..9d1d4909bf6 100644
---
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ResourceMetaDataChangedSubscriber.java
+++
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ResourceMetaDataChangedSubscriber.java
@@ -20,9 +20,9 @@ package
org.apache.shardingsphere.mode.manager.cluster.coordinator.subscriber;
import com.google.common.eventbus.Subscribe;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereView;
-import org.apache.shardingsphere.mode.event.schema.table.AlterTableEvent;
+import
org.apache.shardingsphere.mode.event.schema.table.CreateOrAlterTableEvent;
import org.apache.shardingsphere.mode.event.schema.table.DropTableEvent;
-import org.apache.shardingsphere.mode.event.schema.view.AlterViewEvent;
+import org.apache.shardingsphere.mode.event.schema.view.CreateOrAlterViewEvent;
import org.apache.shardingsphere.mode.event.schema.view.DropViewEvent;
import org.apache.shardingsphere.mode.manager.ContextManager;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.DatabaseAddedEvent;
@@ -88,10 +88,10 @@ public final class ResourceMetaDataChangedSubscriber {
/**
* Renew table.
*
- * @param event alter table event
+ * @param event create or alter table event
*/
@Subscribe
- public synchronized void renew(final AlterTableEvent event) {
+ public synchronized void renew(final CreateOrAlterTableEvent event) {
if
(!event.getActiveVersion().equals(contextManager.getMetaDataContexts().getPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getActiveVersionKey())))
{
return;
}
@@ -113,10 +113,10 @@ public final class ResourceMetaDataChangedSubscriber {
/**
* Renew view.
*
- * @param event alter view event
+ * @param event create or alter view event
*/
@Subscribe
- public synchronized void renew(final AlterViewEvent event) {
+ public synchronized void renew(final CreateOrAlterViewEvent event) {
if
(!event.getActiveVersion().equals(contextManager.getMetaDataContexts().getPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getActiveVersionKey())))
{
return;
}