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 0e27951 Rename QualifiedSchema and move to infra module (#12584)
0e27951 is described below
commit 0e2795157ba5812fb5e9fe030ad0fd8e6090763e
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Sep 20 12:48:11 2021 +0800
Rename QualifiedSchema and move to infra module (#12584)
---
.../infra/metadata/schema/QualifiedSchema.java | 16 +++++++++-------
.../infra/metadata/schema/QualifiedSchemaTest.java | 12 ++++++------
.../manager/cluster/ClusterContextManagerBuilder.java | 4 ++--
.../coordinator/ClusterContextManagerCoordinator.java | 14 +++++++-------
.../status/storage/event/DisabledStateChangedEvent.java | 4 ++--
.../status/storage/event/PrimaryStateChangedEvent.java | 4 ++--
.../registry/status/storage/node/StorageStatusNode.java | 12 ++++++------
.../status/storage/service/StorageNodeStatusService.java | 4 ++--
.../storage/subscriber/StorageNodeStatusSubscriber.java | 8 ++++----
.../storage/watcher/StorageNodeStateChangedWatcher.java | 4 ++--
.../ClusterContextManagerCoordinatorTest.java | 4 ++--
.../status/storage/node/StorageStatusNodeTest.java | 8 ++++----
.../subscriber/StorageNodeStatusSubscriberTest.java | 8 ++++----
.../watcher/StorageNodeStateChangedWatcherTest.java | 12 ++++++------
14 files changed, 58 insertions(+), 56 deletions(-)
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/schema/ClusterSchema.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/QualifiedSchema.java
similarity index 77%
rename from
shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/schema/ClusterSchema.java
rename to
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/QualifiedSchema.java
index 68a75f0..cf0cc86 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/schema/ClusterSchema.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/QualifiedSchema.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.manager.cluster.coordinator.schema;
+package org.apache.shardingsphere.infra.metadata.schema;
import com.google.common.base.Splitter;
import lombok.Getter;
@@ -25,19 +25,21 @@ import
org.apache.shardingsphere.infra.database.DefaultSchema;
import java.util.List;
/**
- * Cluster schema.
+ * Qualified schema.
*/
@RequiredArgsConstructor
@Getter
-public final class ClusterSchema {
+public final class QualifiedSchema {
+
+ private static final String DELIMITER = ".";
private final String schemaName;
private final String dataSourceName;
- public ClusterSchema(final String value) {
- if (value.contains(".")) {
- List<String> values = Splitter.on(".").splitToList(value);
+ public QualifiedSchema(final String value) {
+ if (value.contains(DELIMITER)) {
+ List<String> values = Splitter.on(DELIMITER).splitToList(value);
schemaName = values.get(0);
dataSourceName = values.get(1);
} else {
@@ -48,6 +50,6 @@ public final class ClusterSchema {
@Override
public String toString() {
- return String.join(".", schemaName, dataSourceName);
+ return String.join(DELIMITER, schemaName, dataSourceName);
}
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/schema/ClusterSchemaTest.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/QualifiedSchemaTest.java
similarity index 76%
rename from
shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/schema/ClusterSchemaTest.java
rename to
shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/QualifiedSchemaTest.java
index 0419e21..b6152d0 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/schema/ClusterSchemaTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/QualifiedSchemaTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.manager.cluster.coordinator.schema;
+package org.apache.shardingsphere.infra.metadata.schema;
import org.apache.shardingsphere.infra.database.DefaultSchema;
import org.junit.Test;
@@ -23,18 +23,18 @@ import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class ClusterSchemaTest {
+public final class QualifiedSchemaTest {
@Test
- public void assertNewClusterSchemaWithDataSourceNameOnly() {
- ClusterSchema actual = new ClusterSchema("test_ds");
+ public void assertNewQualifiedSchemaWithDataSourceNameOnly() {
+ QualifiedSchema actual = new QualifiedSchema("test_ds");
assertThat(actual.getSchemaName(), is(DefaultSchema.LOGIC_NAME));
assertThat(actual.getDataSourceName(), is("test_ds"));
}
@Test
- public void assertNewClusterSchemaWithSchemaNameAndDataSourceName() {
- ClusterSchema actual = new ClusterSchema("test_schema.test_ds");
+ public void assertNewQualifiedSchemaWithSchemaNameAndDataSourceName() {
+ QualifiedSchema actual = new QualifiedSchema("test_schema.test_ds");
assertThat(actual.getSchemaName(), is("test_schema"));
assertThat(actual.getDataSourceName(), is("test_ds"));
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index 7004bec..b7e7ab1 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -30,7 +30,7 @@ import
org.apache.shardingsphere.mode.manager.ContextManagerBuilder;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.ClusterContextManagerCoordinator;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.RegistryCenter;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.StorageNodeStatus;
-import
org.apache.shardingsphere.mode.manager.cluster.coordinator.schema.ClusterSchema;
+import org.apache.shardingsphere.infra.metadata.schema.QualifiedSchema;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.MetaDataContextsBuilder;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
@@ -231,7 +231,7 @@ public final class ClusterContextManagerBuilder implements
ContextManagerBuilder
}
private String getDataSourceName(final String disabledDataSource) {
- return new ClusterSchema(disabledDataSource).getDataSourceName();
+ return new QualifiedSchema(disabledDataSource).getDataSourceName();
}
private void persistMetaData() {
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
index 1827753..d98b17b 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
@@ -52,7 +52,7 @@ import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metad
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.SchemaDeletedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.event.DisabledStateChangedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.event.PrimaryStateChangedEvent;
-import
org.apache.shardingsphere.mode.manager.cluster.coordinator.schema.ClusterSchema;
+import org.apache.shardingsphere.infra.metadata.schema.QualifiedSchema;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.MetaDataContextsBuilder;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
@@ -209,11 +209,11 @@ public final class ClusterContextManagerCoordinator {
*/
@Subscribe
public synchronized void renew(final DisabledStateChangedEvent event) {
- ClusterSchema clusterSchema = event.getClusterSchema();
- Collection<ShardingSphereRule> rules =
contextManager.getMetaDataContexts().getMetaDataMap().get(clusterSchema.getSchemaName()).getRuleMetaData().getRules();
+ QualifiedSchema qualifiedSchema = event.getQualifiedSchema();
+ Collection<ShardingSphereRule> rules =
contextManager.getMetaDataContexts().getMetaDataMap().get(qualifiedSchema.getSchemaName()).getRuleMetaData().getRules();
for (ShardingSphereRule each : rules) {
if (each instanceof StatusContainedRule) {
- ((StatusContainedRule) each).updateStatus(new
DataSourceNameDisabledEvent(clusterSchema.getDataSourceName(),
event.isDisabled()));
+ ((StatusContainedRule) each).updateStatus(new
DataSourceNameDisabledEvent(qualifiedSchema.getDataSourceName(),
event.isDisabled()));
}
}
}
@@ -225,11 +225,11 @@ public final class ClusterContextManagerCoordinator {
*/
@Subscribe
public synchronized void renew(final PrimaryStateChangedEvent event) {
- ClusterSchema clusterSchema = event.getClusterSchema();
- Collection<ShardingSphereRule> rules =
contextManager.getMetaDataContexts().getMetaDataMap().get(clusterSchema.getSchemaName()).getRuleMetaData().getRules();
+ QualifiedSchema qualifiedSchema = event.getQualifiedSchema();
+ Collection<ShardingSphereRule> rules =
contextManager.getMetaDataContexts().getMetaDataMap().get(qualifiedSchema.getSchemaName()).getRuleMetaData().getRules();
for (ShardingSphereRule each : rules) {
if (each instanceof StatusContainedRule) {
- ((StatusContainedRule) each).updateStatus(new
PrimaryDataSourceChangedEvent(clusterSchema.getSchemaName(),
clusterSchema.getDataSourceName(), event.getPrimaryDataSourceName()));
+ ((StatusContainedRule) each).updateStatus(new
PrimaryDataSourceChangedEvent(qualifiedSchema.getSchemaName(),
qualifiedSchema.getDataSourceName(), event.getPrimaryDataSourceName()));
}
}
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/event/DisabledStateChangedEvent.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/event/DisabledStateChangedEvent.java
index c92ec72..11e1b00 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/event/DisabledStateChangedEvent.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/event/DisabledStateChangedEvent.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.stat
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceEvent;
-import
org.apache.shardingsphere.mode.manager.cluster.coordinator.schema.ClusterSchema;
+import org.apache.shardingsphere.infra.metadata.schema.QualifiedSchema;
/**
* Disabled state event.
@@ -29,7 +29,7 @@ import
org.apache.shardingsphere.mode.manager.cluster.coordinator.schema.Cluster
@Getter
public final class DisabledStateChangedEvent implements GovernanceEvent {
- private final ClusterSchema clusterSchema;
+ private final QualifiedSchema qualifiedSchema;
private final boolean disabled;
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/event/PrimaryStateChangedEvent.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/event/PrimaryStateChangedEvent.java
index 9f2ff44..3f39190 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/event/PrimaryStateChangedEvent.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/event/PrimaryStateChangedEvent.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.stat
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceEvent;
-import
org.apache.shardingsphere.mode.manager.cluster.coordinator.schema.ClusterSchema;
+import org.apache.shardingsphere.infra.metadata.schema.QualifiedSchema;
/**
* Primary state event.
@@ -29,7 +29,7 @@ import
org.apache.shardingsphere.mode.manager.cluster.coordinator.schema.Cluster
@Getter
public final class PrimaryStateChangedEvent implements GovernanceEvent {
- private final ClusterSchema clusterSchema;
+ private final QualifiedSchema qualifiedSchema;
private final String primaryDataSourceName;
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/node/StorageStatusNode.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/node/StorageStatusNode.java
index b2a9d78..dec9576 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/node/StorageStatusNode.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/node/StorageStatusNode.java
@@ -21,7 +21,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.StatusNode;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.StorageNodeStatus;
-import
org.apache.shardingsphere.mode.manager.cluster.coordinator.schema.ClusterSchema;
+import org.apache.shardingsphere.infra.metadata.schema.QualifiedSchema;
import java.util.Optional;
import java.util.regex.Matcher;
@@ -61,20 +61,20 @@ public final class StorageStatusNode {
* @param schema cluster schema
* @return status path of storage node
*/
- public static String getStatusPath(final StorageNodeStatus status, final
ClusterSchema schema) {
+ public static String getStatusPath(final StorageNodeStatus status, final
QualifiedSchema schema) {
return String.join("/", "", StatusNode.ROOT_NODE, STORAGE_NODES,
status.name().toLowerCase(), schema.toString());
}
/**
- * Extract cluster schema.
+ * Extract qualified schema.
*
* @param status storage node status
* @param storageNodePath storage node path
- * @return extracted cluster schema
+ * @return extracted qualified schema
*/
- public static Optional<ClusterSchema> extractClusterSchema(final
StorageNodeStatus status, final String storageNodePath) {
+ public static Optional<QualifiedSchema> extractQualifiedSchema(final
StorageNodeStatus status, final String storageNodePath) {
Pattern pattern = Pattern.compile(getRootPath() + "/" +
status.name().toLowerCase() + "/(\\S+)$", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(storageNodePath);
- return matcher.find() ? Optional.of(new
ClusterSchema(matcher.group(1))) : Optional.empty();
+ return matcher.find() ? Optional.of(new
QualifiedSchema(matcher.group(1))) : Optional.empty();
}
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/service/StorageNodeStatusService.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/service/StorageNodeStatusService.java
index 7e15187..fbb241d 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/service/StorageNodeStatusService.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/service/StorageNodeStatusService.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.stat
import lombok.RequiredArgsConstructor;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.StorageNodeStatus;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.node.StorageStatusNode;
-import
org.apache.shardingsphere.mode.manager.cluster.coordinator.schema.ClusterSchema;
+import org.apache.shardingsphere.infra.metadata.schema.QualifiedSchema;
import
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
import java.util.Collection;
@@ -43,6 +43,6 @@ public final class StorageNodeStatusService {
*/
public Collection<String> loadStorageNodes(final String schemaName, final
StorageNodeStatus status) {
Collection<String> disabledStorageNodes =
repository.getChildrenKeys(StorageStatusNode.getStatusPath(status));
- return
disabledStorageNodes.stream().map(ClusterSchema::new).filter(each ->
each.getSchemaName().equals(schemaName)).map(ClusterSchema::getDataSourceName).collect(Collectors.toList());
+ return
disabledStorageNodes.stream().map(QualifiedSchema::new).filter(each ->
each.getSchemaName().equals(schemaName)).map(QualifiedSchema::getDataSourceName).collect(Collectors.toList());
}
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/subscriber/StorageNodeStatusSubscriber.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/subscriber/StorageNodeStatus
[...]
index d078188..6188a4e 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/subscriber/StorageNodeStatusSubscriber.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/subscriber/StorageNodeStatusSubscriber.java
@@ -23,7 +23,7 @@ import
org.apache.shardingsphere.infra.rule.event.impl.DataSourceDisabledEvent;
import
org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceChangedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.StorageNodeStatus;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.node.StorageStatusNode;
-import
org.apache.shardingsphere.mode.manager.cluster.coordinator.schema.ClusterSchema;
+import org.apache.shardingsphere.infra.metadata.schema.QualifiedSchema;
import
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
/**
@@ -46,9 +46,9 @@ public final class StorageNodeStatusSubscriber {
@Subscribe
public void update(final DataSourceDisabledEvent event) {
if (event.isDisabled()) {
-
repository.persist(StorageStatusNode.getStatusPath(StorageNodeStatus.DISABLE,
new ClusterSchema(event.getSchemaName(), event.getDataSourceName())), "");
+
repository.persist(StorageStatusNode.getStatusPath(StorageNodeStatus.DISABLE,
new QualifiedSchema(event.getSchemaName(), event.getDataSourceName())), "");
} else {
-
repository.delete(StorageStatusNode.getStatusPath(StorageNodeStatus.DISABLE,
new ClusterSchema(event.getSchemaName(), event.getDataSourceName())));
+
repository.delete(StorageStatusNode.getStatusPath(StorageNodeStatus.DISABLE,
new QualifiedSchema(event.getSchemaName(), event.getDataSourceName())));
}
}
@@ -59,6 +59,6 @@ public final class StorageNodeStatusSubscriber {
*/
@Subscribe
public void update(final PrimaryDataSourceChangedEvent event) {
-
repository.persist(StorageStatusNode.getStatusPath(StorageNodeStatus.PRIMARY,
new ClusterSchema(event.getSchemaName(), event.getGroupName())),
event.getDataSourceName());
+
repository.persist(StorageStatusNode.getStatusPath(StorageNodeStatus.PRIMARY,
new QualifiedSchema(event.getSchemaName(), event.getGroupName())),
event.getDataSourceName());
}
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/watcher/StorageNodeStateChangedWatcher.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/watcher/StorageNodeStateChan
[...]
index 20a68de..1eb9c8a 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/watcher/StorageNodeStateChangedWatcher.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/watcher/StorageNodeStateChangedWatcher.java
@@ -48,11 +48,11 @@ public final class StorageNodeStateChangedWatcher
implements GovernanceWatcher<G
@Override
public Optional<GovernanceEvent> createGovernanceEvent(final
DataChangedEvent event) {
- Optional<GovernanceEvent> primaryStateChangedEvent =
StorageStatusNode.extractClusterSchema(
+ Optional<GovernanceEvent> primaryStateChangedEvent =
StorageStatusNode.extractQualifiedSchema(
StorageNodeStatus.PRIMARY, event.getKey()).map(schema -> new
PrimaryStateChangedEvent(schema, event.getValue()));
if (primaryStateChangedEvent.isPresent()) {
return primaryStateChangedEvent;
}
- return
StorageStatusNode.extractClusterSchema(StorageNodeStatus.DISABLE,
event.getKey()).map(schema -> new DisabledStateChangedEvent(schema, Type.ADDED
== event.getType()));
+ return
StorageStatusNode.extractQualifiedSchema(StorageNodeStatus.DISABLE,
event.getKey()).map(schema -> new DisabledStateChangedEvent(schema, Type.ADDED
== event.getType()));
}
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
index 0b4ec22..9031935 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
@@ -51,7 +51,7 @@ import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.confi
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.SchemaAddedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.SchemaDeletedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.event.DisabledStateChangedEvent;
-import
org.apache.shardingsphere.mode.manager.cluster.coordinator.schema.ClusterSchema;
+import org.apache.shardingsphere.infra.metadata.schema.QualifiedSchema;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
import
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration;
@@ -185,7 +185,7 @@ public final class ClusterContextManagerCoordinatorTest {
@Test
public void assertDisableStateChanged() {
- DisabledStateChangedEvent event = new DisabledStateChangedEvent(new
ClusterSchema("schema.ds_0"), true);
+ DisabledStateChangedEvent event = new DisabledStateChangedEvent(new
QualifiedSchema("schema.ds_0"), true);
coordinator.renew(event);
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/node/StorageStatusNodeTest.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/node/StorageStatusNodeTest.java
index c7d3ffe..10e8704 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/node/StorageStatusNodeTest.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/node/StorageStatusNodeTest.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.node;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.StorageNodeStatus;
-import
org.apache.shardingsphere.mode.manager.cluster.coordinator.schema.ClusterSchema;
+import org.apache.shardingsphere.infra.metadata.schema.QualifiedSchema;
import org.junit.Test;
import java.util.Optional;
@@ -41,13 +41,13 @@ public final class StorageStatusNodeTest {
@Test
public void assertGetStatusPathWithSchema() {
- assertThat(StorageStatusNode.getStatusPath(StorageNodeStatus.PRIMARY,
new ClusterSchema("replica_query_db.replica_ds_0")),
+ assertThat(StorageStatusNode.getStatusPath(StorageNodeStatus.PRIMARY,
new QualifiedSchema("replica_query_db.replica_ds_0")),
is("/status/storage_nodes/primary/replica_query_db.replica_ds_0"));
}
@Test
- public void assertExtractClusterSchema() {
- Optional<ClusterSchema> actual =
StorageStatusNode.extractClusterSchema(StorageNodeStatus.DISABLE,
"/status/storage_nodes/disable/replica_query_db.replica_ds_0");
+ public void assertExtractQualifiedSchema() {
+ Optional<QualifiedSchema> actual =
StorageStatusNode.extractQualifiedSchema(StorageNodeStatus.DISABLE,
"/status/storage_nodes/disable/replica_query_db.replica_ds_0");
assertTrue(actual.isPresent());
assertThat(actual.get().getSchemaName(), is("replica_query_db"));
assertThat(actual.get().getDataSourceName(), is("replica_ds_0"));
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/subscriber/StorageNodeStatusSubscriberTest.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/subscriber/StorageNodeSt
[...]
index 9740896..3240c83 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/subscriber/StorageNodeStatusSubscriberTest.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/subscriber/StorageNodeStatusSubscriberTest.java
@@ -21,7 +21,7 @@ import
org.apache.shardingsphere.infra.rule.event.impl.DataSourceDisabledEvent;
import
org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceChangedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.StorageNodeStatus;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.node.StorageStatusNode;
-import
org.apache.shardingsphere.mode.manager.cluster.coordinator.schema.ClusterSchema;
+import org.apache.shardingsphere.infra.metadata.schema.QualifiedSchema;
import
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -42,7 +42,7 @@ public final class StorageNodeStatusSubscriberTest {
String dataSourceName = "replica_ds_0";
DataSourceDisabledEvent dataSourceDisabledEvent = new
DataSourceDisabledEvent(schemaName, dataSourceName, true);
new
StorageNodeStatusSubscriber(repository).update(dataSourceDisabledEvent);
-
verify(repository).persist(StorageStatusNode.getStatusPath(StorageNodeStatus.DISABLE,
new ClusterSchema(schemaName, dataSourceName)), "");
+
verify(repository).persist(StorageStatusNode.getStatusPath(StorageNodeStatus.DISABLE,
new QualifiedSchema(schemaName, dataSourceName)), "");
}
@Test
@@ -51,7 +51,7 @@ public final class StorageNodeStatusSubscriberTest {
String dataSourceName = "replica_ds_0";
DataSourceDisabledEvent dataSourceDisabledEvent = new
DataSourceDisabledEvent(schemaName, dataSourceName, false);
new
StorageNodeStatusSubscriber(repository).update(dataSourceDisabledEvent);
-
verify(repository).delete(StorageStatusNode.getStatusPath(StorageNodeStatus.DISABLE,
new ClusterSchema(schemaName, dataSourceName)));
+
verify(repository).delete(StorageStatusNode.getStatusPath(StorageNodeStatus.DISABLE,
new QualifiedSchema(schemaName, dataSourceName)));
}
@Test
@@ -61,6 +61,6 @@ public final class StorageNodeStatusSubscriberTest {
String dataSourceName = "replica_ds_0";
PrimaryDataSourceChangedEvent event = new
PrimaryDataSourceChangedEvent(schemaName, groupName, dataSourceName);
new StorageNodeStatusSubscriber(repository).update(event);
-
verify(repository).persist(StorageStatusNode.getStatusPath(StorageNodeStatus.PRIMARY,
new ClusterSchema(schemaName, groupName)), dataSourceName);
+
verify(repository).persist(StorageStatusNode.getStatusPath(StorageNodeStatus.PRIMARY,
new QualifiedSchema(schemaName, groupName)), dataSourceName);
}
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/watcher/StorageNodeStateChangedWatcherTest.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/watcher/StorageNodeState
[...]
index dddd978..7c5e9ec 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/watcher/StorageNodeStateChangedWatcherTest.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/watcher/StorageNodeStateChangedWatcherTest.java
@@ -39,8 +39,8 @@ public final class StorageNodeStateChangedWatcherTest {
new
DataChangedEvent("/status/storage_nodes/primary/replica_query_db.replica_ds_0",
"new_db", Type.ADDED));
assertTrue(actual.isPresent());
PrimaryStateChangedEvent actualEvent = (PrimaryStateChangedEvent)
actual.get();
- assertThat(actualEvent.getClusterSchema().getSchemaName(),
is("replica_query_db"));
- assertThat(actualEvent.getClusterSchema().getDataSourceName(),
is("replica_ds_0"));
+ assertThat(actualEvent.getQualifiedSchema().getSchemaName(),
is("replica_query_db"));
+ assertThat(actualEvent.getQualifiedSchema().getDataSourceName(),
is("replica_ds_0"));
assertThat(actualEvent.getPrimaryDataSourceName(), is("new_db"));
}
@@ -50,8 +50,8 @@ public final class StorageNodeStateChangedWatcherTest {
new
DataChangedEvent("/status/storage_nodes/disable/replica_query_db.replica_ds_0",
"", Type.ADDED));
assertTrue(actual.isPresent());
DisabledStateChangedEvent actualEvent = (DisabledStateChangedEvent)
actual.get();
- assertThat(actualEvent.getClusterSchema().getSchemaName(),
is("replica_query_db"));
- assertThat(actualEvent.getClusterSchema().getDataSourceName(),
is("replica_ds_0"));
+ assertThat(actualEvent.getQualifiedSchema().getSchemaName(),
is("replica_query_db"));
+ assertThat(actualEvent.getQualifiedSchema().getDataSourceName(),
is("replica_ds_0"));
assertTrue(actualEvent.isDisabled());
}
@@ -61,8 +61,8 @@ public final class StorageNodeStateChangedWatcherTest {
new
DataChangedEvent("/status/storage_nodes/disable/replica_query_db.replica_ds_0",
"", Type.DELETED));
assertTrue(actual.isPresent());
DisabledStateChangedEvent actualEvent = (DisabledStateChangedEvent)
actual.get();
- assertThat(actualEvent.getClusterSchema().getSchemaName(),
is("replica_query_db"));
- assertThat(actualEvent.getClusterSchema().getDataSourceName(),
is("replica_ds_0"));
+ assertThat(actualEvent.getQualifiedSchema().getSchemaName(),
is("replica_query_db"));
+ assertThat(actualEvent.getQualifiedSchema().getDataSourceName(),
is("replica_ds_0"));
assertFalse(actualEvent.isDisabled());
}