diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/QualifiedDataSourceStatus.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/QualifiedDataSourceStatus.java index fdffe12439c00..2c9a9d2abc6ee 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/QualifiedDataSourceStatus.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/QualifiedDataSourceStatus.java @@ -28,15 +28,5 @@ @Getter public final class QualifiedDataSourceStatus { - private final Role role; - private final DataSourceState status; - - /** - * Storage node role. - */ - public enum Role { - - PRIMARY, MEMBER - } } diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/service/QualifiedDataSourceStatusService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/service/QualifiedDataSourceStatusService.java index 7f993b5616a92..a8e899da0fbf0 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/service/QualifiedDataSourceStatusService.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/service/QualifiedDataSourceStatusService.java @@ -24,7 +24,6 @@ import org.apache.shardingsphere.infra.util.yaml.YamlEngine; import org.apache.shardingsphere.mode.spi.PersistRepository; import org.apache.shardingsphere.mode.storage.QualifiedDataSourceStatus; -import org.apache.shardingsphere.mode.storage.QualifiedDataSourceStatus.Role; import org.apache.shardingsphere.mode.storage.node.QualifiedDataSourceNode; import org.apache.shardingsphere.mode.storage.yaml.YamlQualifiedDataSourceStatus; import org.apache.shardingsphere.mode.storage.yaml.YamlQualifiedDataSourceStatusSwapper; @@ -67,7 +66,7 @@ public Map loadQualifiedDataSourceStatus() { * @param dataSourceState data source state */ public void changeMemberQualifiedDataSourceStatus(final String databaseName, final String groupName, final String storageUnitName, final DataSourceState dataSourceState) { - QualifiedDataSourceStatus status = new QualifiedDataSourceStatus(Role.MEMBER, dataSourceState); + QualifiedDataSourceStatus status = new QualifiedDataSourceStatus(dataSourceState); repository.persist(QualifiedDataSourceNode.getQualifiedDataSourceNodePath(new QualifiedDataSource(databaseName, groupName, storageUnitName)), YamlEngine.marshal(new YamlQualifiedDataSourceStatusSwapper().swapToYamlConfiguration(status))); } diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/yaml/YamlQualifiedDataSourceStatus.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/yaml/YamlQualifiedDataSourceStatus.java index cfcfcba4e2ee0..0bc4c9201649f 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/yaml/YamlQualifiedDataSourceStatus.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/yaml/YamlQualifiedDataSourceStatus.java @@ -28,7 +28,5 @@ @Setter public final class YamlQualifiedDataSourceStatus implements YamlConfiguration { - private String role; - private String status; } diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/yaml/YamlQualifiedDataSourceStatusSwapper.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/yaml/YamlQualifiedDataSourceStatusSwapper.java index c8c12924755e9..4db8d95033bee 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/yaml/YamlQualifiedDataSourceStatusSwapper.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/yaml/YamlQualifiedDataSourceStatusSwapper.java @@ -20,7 +20,6 @@ import org.apache.shardingsphere.infra.state.datasource.DataSourceState; import org.apache.shardingsphere.infra.util.yaml.swapper.YamlConfigurationSwapper; import org.apache.shardingsphere.mode.storage.QualifiedDataSourceStatus; -import org.apache.shardingsphere.mode.storage.QualifiedDataSourceStatus.Role; /** * YAML qualified data source status swapper. @@ -30,13 +29,12 @@ public final class YamlQualifiedDataSourceStatusSwapper implements YamlConfigura @Override public YamlQualifiedDataSourceStatus swapToYamlConfiguration(final QualifiedDataSourceStatus data) { YamlQualifiedDataSourceStatus result = new YamlQualifiedDataSourceStatus(); - result.setRole(data.getRole().name()); result.setStatus(data.getStatus().name()); return result; } @Override public QualifiedDataSourceStatus swapToObject(final YamlQualifiedDataSourceStatus yamlConfig) { - return new QualifiedDataSourceStatus(Role.valueOf(yamlConfig.getRole()), DataSourceState.valueOf(yamlConfig.getStatus())); + return new QualifiedDataSourceStatus(DataSourceState.valueOf(yamlConfig.getStatus())); } } diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/node/QualifiedDataSourceNodeTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/node/QualifiedDataSourceNodeTest.java index de98a03f4dd02..5b691272735df 100644 --- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/node/QualifiedDataSourceNodeTest.java +++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/node/QualifiedDataSourceNodeTest.java @@ -31,18 +31,18 @@ class QualifiedDataSourceNodeTest { @Test void assertGetRootPath() { - assertThat(QualifiedDataSourceNode.getRootPath(), is("/nodes/storage_nodes")); + assertThat(QualifiedDataSourceNode.getRootPath(), is("/nodes/qualified_data_sources")); } @Test void assertGetQualifiedDataSourceNodePath() { assertThat(QualifiedDataSourceNode.getQualifiedDataSourceNodePath(new QualifiedDataSource("replica_query_db.readwrite_ds.replica_ds_0")), - is("/nodes/storage_nodes/replica_query_db.readwrite_ds.replica_ds_0")); + is("/nodes/qualified_data_sources/replica_query_db.readwrite_ds.replica_ds_0")); } @Test void assertExtractQualifiedDataSource() { - Optional actual = QualifiedDataSourceNode.extractQualifiedDataSource("/nodes/storage_nodes/replica_query_db.readwrite_ds.replica_ds_0"); + Optional actual = QualifiedDataSourceNode.extractQualifiedDataSource("/nodes/qualified_data_sources/replica_query_db.readwrite_ds.replica_ds_0"); assertTrue(actual.isPresent()); assertThat(actual.get().getDatabaseName(), is("replica_query_db")); assertThat(actual.get().getGroupName(), is("readwrite_ds")); diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/watcher/QualifiedDataSourceChangedWatcherTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/watcher/QualifiedDataSourceChangedWatcherTest.java index 94e16fc64ba65..79f2463444db0 100644 --- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/watcher/QualifiedDataSourceChangedWatcherTest.java +++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/watcher/QualifiedDataSourceChangedWatcherTest.java @@ -22,7 +22,6 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent; import org.apache.shardingsphere.mode.event.DataChangedEvent.Type; import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.event.StorageNodeChangedEvent; -import org.apache.shardingsphere.mode.storage.QualifiedDataSourceStatus.Role; import org.junit.jupiter.api.Test; import java.util.Optional; @@ -37,33 +36,31 @@ class QualifiedDataSourceChangedWatcherTest { @Test void assertCreateEnabledQualifiedDataSourceChangedEvent() { Optional actual = new QualifiedDataSourceChangedWatcher().createGovernanceEvent( - new DataChangedEvent("/nodes/storage_nodes/replica_query_db.readwrite_ds.replica_ds_0", "role: MEMBER\nstatus: ENABLED\n", Type.ADDED)); + new DataChangedEvent("/nodes/qualified_data_sources/replica_query_db.readwrite_ds.replica_ds_0", "status: ENABLED\n", Type.ADDED)); assertTrue(actual.isPresent()); StorageNodeChangedEvent actualEvent = (StorageNodeChangedEvent) actual.get(); assertThat(actualEvent.getQualifiedDataSource().getDatabaseName(), is("replica_query_db")); assertThat(actualEvent.getQualifiedDataSource().getGroupName(), is("readwrite_ds")); assertThat(actualEvent.getQualifiedDataSource().getDataSourceName(), is("replica_ds_0")); - assertThat(actualEvent.getStatus().getRole(), is(Role.MEMBER)); assertThat(actualEvent.getStatus().getStatus(), is(DataSourceState.ENABLED)); } @Test void assertCreateDisabledQualifiedDataSourceChangedEvent() { Optional actual = new QualifiedDataSourceChangedWatcher().createGovernanceEvent( - new DataChangedEvent("/nodes/storage_nodes/replica_query_db.readwrite_ds.replica_ds_0", "role: MEMBER\nstatus: DISABLED\n", Type.DELETED)); + new DataChangedEvent("/nodes/qualified_data_sources/replica_query_db.readwrite_ds.replica_ds_0", "status: DISABLED\n", Type.DELETED)); assertTrue(actual.isPresent()); StorageNodeChangedEvent actualEvent = (StorageNodeChangedEvent) actual.get(); assertThat(actualEvent.getQualifiedDataSource().getDatabaseName(), is("replica_query_db")); assertThat(actualEvent.getQualifiedDataSource().getGroupName(), is("readwrite_ds")); assertThat(actualEvent.getQualifiedDataSource().getDataSourceName(), is("replica_ds_0")); - assertThat(actualEvent.getStatus().getRole(), is(Role.MEMBER)); assertThat(actualEvent.getStatus().getStatus(), is(DataSourceState.DISABLED)); } @Test void assertCreateEmptyEvent() { Optional actual = new QualifiedDataSourceChangedWatcher().createGovernanceEvent( - new DataChangedEvent("/nodes/storage_nodes/replica_query_db.readwrite_ds.replica_ds_0", "", Type.ADDED)); + new DataChangedEvent("/nodes/qualified_data_sources/replica_query_db.readwrite_ds.replica_ds_0", "", Type.ADDED)); assertFalse(actual.isPresent()); } } diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriberTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriberTest.java index e910f01d05278..6526dd265efbf 100644 --- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriberTest.java +++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriberTest.java @@ -49,7 +49,6 @@ import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository; import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration; import org.apache.shardingsphere.mode.storage.QualifiedDataSourceStatus; -import org.apache.shardingsphere.mode.storage.QualifiedDataSourceStatus.Role; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -114,7 +113,7 @@ private Map createDatabases() { void assertRenewForDisableStateChanged() { StaticDataSourceRuleAttribute ruleAttribute = mock(StaticDataSourceRuleAttribute.class); when(database.getRuleMetaData().getAttributes(StaticDataSourceRuleAttribute.class)).thenReturn(Collections.singleton(ruleAttribute)); - StorageNodeChangedEvent event = new StorageNodeChangedEvent(new QualifiedDataSource("db.readwrite_ds.ds_0"), new QualifiedDataSourceStatus(Role.MEMBER, DataSourceState.DISABLED)); + StorageNodeChangedEvent event = new StorageNodeChangedEvent(new QualifiedDataSource("db.readwrite_ds.ds_0"), new QualifiedDataSourceStatus(DataSourceState.DISABLED)); subscriber.renew(event); verify(ruleAttribute).updateStatus( argThat(qualifiedDataSource -> Objects.equals(event.getQualifiedDataSource(), qualifiedDataSource)),