You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/04/22 06:48:44 UTC
[shardingsphere] branch master updated: Rename MGRDatabaseDiscoveryTypeFixture to FixtureDatabaseDiscoveryType (#17000)
This is an automated email from the ASF dual-hosted git repository.
panjuan 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 3727f887f7d Rename MGRDatabaseDiscoveryTypeFixture to FixtureDatabaseDiscoveryType (#17000)
3727f887f7d is described below
commit 3727f887f7dd339e6cf25a5f6483927cceab5c53
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Apr 22 14:48:38 2022 +0800
Rename MGRDatabaseDiscoveryTypeFixture to FixtureDatabaseDiscoveryType (#17000)
---
...ixture.java => FixtureDatabaseDiscoveryType.java} | 20 ++++++--------------
...terDatabaseDiscoveryTypeStatementUpdaterTest.java | 16 ++++++++--------
...ateDatabaseDiscoveryTypeStatementUpdaterTest.java | 12 ++++++------
...rdingsphere.dbdiscovery.spi.DatabaseDiscoveryType | 2 +-
4 files changed, 21 insertions(+), 29 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/MGRDatabaseDiscoveryTypeFixture.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/FixtureDatabaseDiscoveryT [...]
similarity index 88%
rename from shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/MGRDatabaseDiscoveryTypeFixture.java
rename to shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/FixtureDatabaseDiscoveryType.java
index 280671e0acf..17365fa319d 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/MGRDatabaseDiscoveryTypeFixture.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/FixtureDatabaseDiscoveryType.java
@@ -17,41 +17,33 @@
package org.apache.shardingsphere.dbdiscovery.distsql.handler.fixture;
-import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryType;
import javax.sql.DataSource;
import java.util.Collection;
import java.util.Map;
-/**
- * MGR database discovery type fixture.
- */
-@Slf4j
-public final class MGRDatabaseDiscoveryTypeFixture implements DatabaseDiscoveryType {
-
- @Override
- public String getType() {
- return "mgr";
- }
+public final class FixtureDatabaseDiscoveryType implements DatabaseDiscoveryType {
@Override
public void checkDatabaseDiscoveryConfiguration(final String databaseName, final Map<String, DataSource> dataSourceMap) {
-
}
@Override
public void updatePrimaryDataSource(final String databaseName, final Map<String, DataSource> dataSourceMap, final Collection<String> disabledDataSourceNames, final String groupName) {
-
}
@Override
public void updateMemberState(final String databaseName, final Map<String, DataSource> dataSourceMap, final String groupName) {
-
}
@Override
public String getPrimaryDataSource() {
return null;
}
+
+ @Override
+ public String getType() {
+ return "FIXTURE";
+ }
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryTypeStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabas [...]
index 4932ac787e3..fe4da28473b 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryTypeStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryTypeStatementUpdaterTest.java
@@ -62,8 +62,8 @@ public final class AlterDatabaseDiscoveryTypeStatementUpdaterTest {
public void assertCheckSQLStatementWithDuplicate() throws DistSQLException {
DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("readwrite_ds", Collections.emptyList(), "ha-heartbeat", "test");
List<DatabaseDiscoveryTypeSegment> databaseDiscoveryTypeSegments = Arrays.asList(
- new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("mgr", new Properties())),
- new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("mgr", new Properties())));
+ new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("FIXTURE", new Properties())),
+ new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("FIXTURE", new Properties())));
updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryTypeStatement(databaseDiscoveryTypeSegments),
new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceRuleConfig), Collections.emptyMap(), Collections.emptyMap()));
}
@@ -71,10 +71,10 @@ public final class AlterDatabaseDiscoveryTypeStatementUpdaterTest {
@Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithNotExist() throws DistSQLException {
List<DatabaseDiscoveryTypeSegment> databaseDiscoveryTypeSegments =
- Collections.singletonList(new DatabaseDiscoveryTypeSegment("discovery_type_1", new AlgorithmSegment("mgr", new Properties())));
+ Collections.singletonList(new DatabaseDiscoveryTypeSegment("discovery_type_1", new AlgorithmSegment("FIXTURE", new Properties())));
updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryTypeStatement(databaseDiscoveryTypeSegments),
new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap(),
- Collections.singletonMap("discovery_type", new ShardingSphereAlgorithmConfiguration("mgr", new Properties()))));
+ Collections.singletonMap("discovery_type", new ShardingSphereAlgorithmConfiguration("FIXTURE", new Properties()))));
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
@@ -82,7 +82,7 @@ public final class AlterDatabaseDiscoveryTypeStatementUpdaterTest {
Set<DatabaseDiscoveryTypeSegment> discoveryTypeSegments = Collections.singleton(new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("INVALID_TYPE", new Properties())));
updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryTypeStatement(discoveryTypeSegments),
new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap(),
- Collections.singletonMap("discovery_type", new ShardingSphereAlgorithmConfiguration("mgr", new Properties()))));
+ Collections.singletonMap("discovery_type", new ShardingSphereAlgorithmConfiguration("FIXTURE", new Properties()))));
}
@Test
@@ -90,17 +90,17 @@ public final class AlterDatabaseDiscoveryTypeStatementUpdaterTest {
Properties currentProperties = new Properties();
currentProperties.put("key", "value");
DatabaseDiscoveryRuleConfiguration currentRuleConfiguration = new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap(),
- Collections.singletonMap("discovery_type", new ShardingSphereAlgorithmConfiguration("mgr", currentProperties)));
+ Collections.singletonMap("discovery_type", new ShardingSphereAlgorithmConfiguration("FIXTURE", currentProperties)));
Properties properties = new Properties();
properties.put("key", "value_1");
- Set<DatabaseDiscoveryTypeSegment> discoveryTypeSegments = Collections.singleton(new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("MGR", properties)));
+ Set<DatabaseDiscoveryTypeSegment> discoveryTypeSegments = Collections.singleton(new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("FIXTURE", properties)));
updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryTypeStatement(discoveryTypeSegments), currentRuleConfiguration);
DatabaseDiscoveryRuleConfiguration databaseDiscoveryRuleConfiguration =
(DatabaseDiscoveryRuleConfiguration) updater.buildToBeAlteredRuleConfiguration(new AlterDatabaseDiscoveryTypeStatement(discoveryTypeSegments));
DatabaseDiscoveryRuleConfiguration currentConfiguration = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>(), new LinkedHashMap<>());
updater.updateCurrentRuleConfiguration(currentConfiguration, databaseDiscoveryRuleConfiguration);
assertThat(currentConfiguration.getDiscoveryTypes().size(), is(1));
- assertThat(currentConfiguration.getDiscoveryTypes().get("discovery_type").getType(), is("MGR"));
+ assertThat(currentConfiguration.getDiscoveryTypes().get("discovery_type").getType(), is("FIXTURE"));
assertThat(currentConfiguration.getDiscoveryTypes().get("discovery_type").getProps().get("key"), is("value_1"));
}
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryTypeStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatab [...]
index a2a52e52ad5..a7fd93aff3e 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryTypeStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryTypeStatementUpdaterTest.java
@@ -60,8 +60,8 @@ public final class CreateDatabaseDiscoveryTypeStatementUpdaterTest {
public void assertCheckSQLStatementWithDuplicate() throws DistSQLException {
DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("readwrite_ds", Collections.emptyList(), "ha-heartbeat", "test");
Collection<DatabaseDiscoveryTypeSegment> databaseDiscoveryTypeSegments = Arrays.asList(
- new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("mgr", new Properties())),
- new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("mgr", new Properties())));
+ new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("FIXTURE", new Properties())),
+ new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("FIXTURE", new Properties())));
updater.checkSQLStatement(shardingSphereMetaData, new CreateDatabaseDiscoveryTypeStatement(databaseDiscoveryTypeSegments),
new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceRuleConfig), Collections.emptyMap(), Collections.emptyMap()));
}
@@ -70,10 +70,10 @@ public final class CreateDatabaseDiscoveryTypeStatementUpdaterTest {
public void assertCheckSQLStatementWithExist() throws DistSQLException {
DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("readwrite_ds", Collections.emptyList(), "ha-heartbeat", "test");
Collection<DatabaseDiscoveryTypeSegment> databaseDiscoveryTypeSegments = Collections.singletonList(
- new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("mgr", new Properties())));
+ new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("FIXTURE", new Properties())));
updater.checkSQLStatement(shardingSphereMetaData, new CreateDatabaseDiscoveryTypeStatement(databaseDiscoveryTypeSegments),
new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceRuleConfig), Collections.emptyMap(),
- Collections.singletonMap("discovery_type", new ShardingSphereAlgorithmConfiguration("mgr", new Properties()))));
+ Collections.singletonMap("discovery_type", new ShardingSphereAlgorithmConfiguration("FIXTURE", new Properties()))));
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
@@ -85,13 +85,13 @@ public final class CreateDatabaseDiscoveryTypeStatementUpdaterTest {
@Test
public void assertBuildAndUpdate() throws DistSQLException {
- Collection<DatabaseDiscoveryTypeSegment> discoveryTypeSegments = Collections.singleton(new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("MGR", new Properties())));
+ Collection<DatabaseDiscoveryTypeSegment> discoveryTypeSegments = Collections.singleton(new DatabaseDiscoveryTypeSegment("discovery_type", new AlgorithmSegment("FIXTURE", new Properties())));
updater.checkSQLStatement(shardingSphereMetaData, new CreateDatabaseDiscoveryTypeStatement(discoveryTypeSegments), null);
DatabaseDiscoveryRuleConfiguration databaseDiscoveryRuleConfiguration =
(DatabaseDiscoveryRuleConfiguration) updater.buildToBeCreatedRuleConfiguration(new CreateDatabaseDiscoveryTypeStatement(discoveryTypeSegments));
DatabaseDiscoveryRuleConfiguration currentConfiguration = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>(), new LinkedHashMap<>());
updater.updateCurrentRuleConfiguration(currentConfiguration, databaseDiscoveryRuleConfiguration);
assertThat(currentConfiguration.getDiscoveryTypes().size(), is(1));
- assertThat(currentConfiguration.getDiscoveryTypes().get("discovery_type").getType(), is("MGR"));
+ assertThat(currentConfiguration.getDiscoveryTypes().get("discovery_type").getType(), is("FIXTURE"));
}
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryType b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryType
index b43c9e0b3ab..f88d942ed6e 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryType
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryType
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.dbdiscovery.distsql.handler.fixture.MGRDatabaseDiscoveryTypeFixture
+org.apache.shardingsphere.dbdiscovery.distsql.handler.fixture.FixtureDatabaseDiscoveryType