You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by tu...@apache.org on 2022/10/11 08:54:35 UTC
[shardingsphere] branch master updated: Rename ShardingSphereResource to ShardingSphereResourceMetaData (#21486)
This is an automated email from the ASF dual-hosted git repository.
tuichenchuxin 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 5b9946a195b Rename ShardingSphereResource to ShardingSphereResourceMetaData (#21486)
5b9946a195b is described below
commit 5b9946a195b32b26141a18a9176874b5a31c9d6b
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Tue Oct 11 16:54:21 2022 +0800
Rename ShardingSphereResource to ShardingSphereResourceMetaData (#21486)
* Rename ShardingSphereResource to ShardingSphereResources
* optimize checkstyle
* Rename ShardingSphereResource to ShardingSphereResourceMetaData
* rename field
* optimize checkstyle
* optimize checkstyle
* optimize checkstyle
---
.../collector/MetaDataInfoCollector.java | 2 +-
.../route/DatabaseDiscoverySQLRouterTest.java | 12 ++---
...AlterDatabaseDiscoveryRuleStatementUpdater.java | 8 ++--
...reateDatabaseDiscoveryRuleStatementUpdater.java | 8 ++--
...rDatabaseDiscoveryRuleStatementUpdaterTest.java | 8 ++--
...eDatabaseDiscoveryRuleStatementUpdaterTest.java | 8 ++--
.../route/ReadwriteSplittingSQLRouterTest.java | 24 +++++-----
...lterReadwriteSplittingRuleStatementUpdater.java | 2 +-
...eateReadwriteSplittingRuleStatementUpdater.java | 12 ++---
...ReadwriteSplittingRuleStatementUpdaterTest.java | 16 +++----
...ReadwriteSplittingRuleStatementUpdaterTest.java | 22 ++++-----
.../checker/ShadowRuleStatementChecker.java | 2 +-
.../AlterShadowRuleStatementUpdaterTest.java | 8 ++--
.../CreateShadowRuleStatementUpdaterTest.java | 8 ++--
.../engine/type/ShardingRouteEngineFactory.java | 6 +--
.../ShardingInstanceBroadcastRoutingEngine.java | 6 +--
.../merge/dql/ShardingDQLResultMergerTest.java | 4 +-
.../dql/groupby/GroupByStreamMergedResultTest.java | 4 +-
.../dql/orderby/OrderByStreamMergedResultTest.java | 5 +-
...ShardingInstanceBroadcastRoutingEngineTest.java | 8 ++--
.../ShardingTableBroadcastRoutingEngineTest.java | 6 +--
.../engine/type/standard/AbstractSQLRouteTest.java | 8 ++--
.../checker/ShardingTableRuleStatementChecker.java | 2 +-
.../checker/ShardingRuleStatementCheckerTest.java | 6 +--
...AlterShardingTableRuleStatementUpdaterTest.java | 12 ++---
...reateShardingTableRuleStatementUpdaterTest.java | 12 ++---
.../checker/ShardingRouteCacheableCheckerTest.java | 4 +-
.../engine/SQLFederationDeciderEngineTest.java | 14 +++---
.../infra/metadata/ShardingSphereMetaData.java | 2 +-
.../metadata/database/ShardingSphereDatabase.java | 22 ++++-----
...ce.java => ShardingSphereResourceMetaData.java} | 6 +--
.../schema/builder/SystemSchemaBuilderRule.java | 2 +-
.../infra/metadata/ShardingSphereMetaDataTest.java | 22 ++++-----
.../database/ShardingSphereDatabaseTest.java | 24 +++++-----
.../ShardingSphereDatabasesFactoryTest.java | 6 +--
.../resource/ShardingSphereResourceTest.java | 2 +-
.../schema/util/IndexMetaDataUtilTest.java | 4 +-
.../type/AlterTableStatementSchemaRefresher.java | 2 +-
.../type/AlterViewStatementSchemaRefresher.java | 2 +-
.../type/CreateTableStatementSchemaRefresher.java | 2 +-
.../type/CreateViewStatementSchemaRefresher.java | 2 +-
.../type/DropIndexStatementSchemaRefresher.java | 2 +-
.../type/RenameTableStatementSchemaRefresher.java | 2 +-
.../infra/context/kernel/KernelProcessorTest.java | 4 +-
.../RenameTableStatementSchemaRefresherTest.java | 8 ++--
.../sql/context/ExecutionContextBuilder.java | 2 +-
.../sql/context/ExecutionContextBuilderTest.java | 16 +++----
.../shardingsphere/infra/merge/MergeEngine.java | 2 +-
.../infra/rewrite/SQLRewriteEntry.java | 2 +-
.../infra/rewrite/SQLRewriteEntryTest.java | 6 +--
.../route/engine/impl/AllSQLRouteExecutor.java | 2 +-
.../route/engine/impl/PartialSQLRouteExecutor.java | 4 +-
.../route/engine/AllSQLRouteExecutorTest.java | 2 +-
.../infra/route/engine/SQLRouteEngineTest.java | 6 +--
.../driver/executor/DriverExecutor.java | 2 +-
.../batch/BatchPreparedStatementExecutor.java | 2 +-
.../jdbc/adapter/AbstractStatementAdapter.java | 2 +-
.../metadata/ShardingSphereDatabaseMetaData.java | 4 +-
.../statement/ShardingSpherePreparedStatement.java | 22 ++++-----
.../core/statement/ShardingSphereStatement.java | 30 ++++++------
.../driver/executor/AbstractBaseExecutorTest.java | 2 +-
.../jdbc/adapter/PreparedStatementAdapterTest.java | 2 +-
.../UnsupportedOperationPreparedStatementTest.java | 2 +-
.../driver/state/DriverStateContextTest.java | 2 +-
.../spring/boot/SpringBootStarterTest.java | 2 +-
.../boot/jndi/SpringBootJNDIDataSourceTest.java | 2 +-
.../namespace/AbstractSpringNamespaceTest.java | 2 +-
.../ShardingSphereDataScheduleCollector.java | 2 +-
.../scenario/migration/MigrationJobAPIImpl.java | 2 +-
.../singletable/route/SingleTableSQLRouter.java | 4 +-
.../route/SingleTableSQLRouterTest.java | 10 ++--
.../AdvancedSQLFederationExecutorTest.java | 8 ++--
.../transaction/rule/TransactionRule.java | 6 +--
.../transaction/rule/TransactionRuleTest.java | 14 +++---
.../AlterTransactionRuleStatementUpdaterTest.java | 2 +-
.../mode/manager/ContextManager.java | 39 ++++++++--------
.../manager/switcher/ResourceSwitchManager.java | 53 +++++++++++-----------
.../mode/manager/switcher/SwitchingResource.java | 6 +--
.../mode/metadata/MetaDataContextsFactory.java | 2 +-
.../mode/manager/ContextManagerTest.java | 45 +++++++++---------
.../switcher/ResourceSwitchManagerTest.java | 4 +-
.../manager/switcher/SwitchingResourceTest.java | 8 ++--
.../ClusterContextManagerCoordinatorTest.java | 14 +++---
.../backend/communication/ProxySQLExecutor.java | 2 +-
.../communication/ReactiveProxySQLExecutor.java | 2 +-
.../jdbc/JDBCDatabaseCommunicationEngine.java | 2 +-
.../jdbc/datasource/JDBCBackendDataSource.java | 2 +-
.../jdbc/executor/ProxyJDBCExecutor.java | 2 +-
.../vertx/VertxBackendDataSource.java | 2 +-
.../executor/AbstractDatabaseMetadataExecutor.java | 6 +--
.../SelectInformationSchemataExecutor.java | 6 +--
.../executor/SelectDatabaseExecutor.java | 6 +--
.../postgresql/executor/SelectTableExecutor.java | 2 +-
...aseDiscoveryRuleConfigurationImportChecker.java | 2 +-
...iteSplittingRuleConfigurationImportChecker.java | 2 +-
.../ShardingRuleConfigurationImportChecker.java | 2 +-
.../ExportDatabaseConfigurationHandler.java | 4 +-
.../ImportDatabaseConfigurationHandler.java | 2 +-
.../SetReadwriteSplittingStatusHandler.java | 2 +-
.../rdl/resource/AddResourceBackendHandler.java | 4 +-
.../rdl/resource/AlterResourceBackendHandler.java | 4 +-
.../rdl/resource/DropResourceBackendHandler.java | 2 +-
...lterDefaultSingleTableRuleStatementUpdater.java | 2 +-
...eateDefaultSingleTableRuleStatementUpdater.java | 2 +-
.../rql/resource/DataSourceQueryResultSet.java | 14 +++---
.../resource/UnusedDataSourceQueryResultSet.java | 14 +++---
.../rql/rule/RulesUsedResourceQueryResultSet.java | 2 +-
.../handler/distsql/rul/sql/PreviewHandler.java | 4 +-
.../DatabaseCommunicationEngineFactoryTest.java | 2 +-
.../jdbc/JDBCDatabaseCommunicationEngineTest.java | 2 +-
.../jdbc/connection/JDBCBackendConnectionTest.java | 2 +-
.../jdbc/datasource/JDBCBackendDataSourceTest.java | 4 +-
.../proxy/backend/context/ProxyContextTest.java | 2 +-
.../DatabaseAdminQueryBackendHandlerTest.java | 2 +-
.../DatabaseOperateBackendHandlerFactoryTest.java | 6 +--
.../DefaultDatabaseMetadataExecutorTest.java | 4 +-
.../admin/mysql/MySQLAdminExecutorCreatorTest.java | 10 ++--
.../executor/ShowCreateDatabaseExecutorTest.java | 2 +-
.../mysql/executor/ShowDatabasesExecutorTest.java | 2 +-
.../executor/ShowFunctionStatusExecutorTest.java | 2 +-
.../executor/ShowProcedureStatusExecutorTest.java | 2 +-
.../mysql/executor/ShowTablesExecutorTest.java | 2 +-
.../mysql/executor/UseDatabaseExecutorTest.java | 2 +-
.../SelectInformationSchemataExecutorTest.java | 10 ++--
.../executor/SelectDatabaseExecutorTest.java | 7 +--
.../executor/SelectTableExecutorTest.java | 5 +-
.../impl/UnicastDatabaseBackendHandlerTest.java | 2 +-
.../distsql/DistSQLBackendHandlerFactoryTest.java | 12 ++---
.../ExportDatabaseConfigurationHandlerTest.java | 4 +-
.../ImportDatabaseConfigurationHandlerTest.java | 2 +-
.../updatable/SetVariableBackendHandlerTest.java | 4 +-
.../resource/AddResourceBackendHandlerTest.java | 12 ++---
.../resource/AlterResourceBackendHandlerTest.java | 16 +++----
.../resource/DropResourceBackendHandlerTest.java | 26 +++++------
.../AlterDefaultSingleTableRuleUpdaterTest.java | 2 +-
.../CreateDefaultSingleTableRuleUpdaterTest.java | 2 +-
.../DropDefaultSingleTableRuleUpdaterTest.java | 2 +-
.../distsql/rql/DataSourceQueryResultSetTest.java | 6 +--
.../rql/RulesUsedResourceQueryResultSetTest.java | 10 ++--
.../rql/UnusedDataSourceQueryResultSetTest.java | 6 +--
.../protocol/FrontDatabaseProtocolTypeFactory.java | 2 +-
.../FrontDatabaseProtocolTypeFactoryTest.java | 4 +-
.../text/query/MySQLMultiStatementsHandler.java | 2 +-
.../frontend/mysql/MySQLFrontendEngineTest.java | 2 +-
.../command/MySQLCommandExecutorFactoryTest.java | 2 +-
.../execute/MySQLComStmtExecuteExecutorTest.java | 2 +-
.../query/MySQLComQueryPacketExecutorTest.java | 2 +-
.../query/MySQLMultiStatementsHandlerTest.java | 2 +-
.../OpenGaussAuthenticationHandlerTest.java | 4 +-
.../command/query/extended/JDBCPortal.java | 2 +-
.../PostgreSQLBatchedStatementsExecutor.java | 2 +-
.../describe/PostgreSQLComDescribeExecutor.java | 2 +-
.../PostgreSQLAuthenticationHandlerTest.java | 4 +-
.../command/query/extended/JDBCPortalTest.java | 2 +-
.../PostgreSQLComDescribeExecutorTest.java | 2 +-
.../parse/PostgreSQLComParseExecutorTest.java | 4 +-
.../AbstractSQLRewriterParameterizedTest.java | 8 ++--
157 files changed, 505 insertions(+), 499 deletions(-)
diff --git a/agent/plugins/metrics/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/MetaDataInfoCollector.java b/agent/plugins/metrics/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/MetaDataInfoCollector.java
index eb673b4036c..dabb9e84844 100644
--- a/agent/plugins/metrics/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/MetaDataInfoCollector.java
+++ b/agent/plugins/metrics/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/MetaDataInfoCollector.java
@@ -79,7 +79,7 @@ public final class MetaDataInfoCollector extends Collector {
private Collection<String> getDatabaseNames(final ShardingSphereDatabase database) {
Collection<String> result = new HashSet<>();
- for (DataSource each : database.getResource().getDataSources().values()) {
+ for (DataSource each : database.getResourceMetaData().getDataSources().values()) {
getDatabaseName(each).ifPresent(result::add);
}
return result;
diff --git a/features/db-discovery/core/src/test/java/org/apache/shardingsphere/dbdiscovery/route/DatabaseDiscoverySQLRouterTest.java b/features/db-discovery/core/src/test/java/org/apache/shardingsphere/dbdiscovery/route/DatabaseDiscoverySQLRouterTest.java
index e22ac683338..7dcd4a8c0e6 100644
--- a/features/db-discovery/core/src/test/java/org/apache/shardingsphere/dbdiscovery/route/DatabaseDiscoverySQLRouterTest.java
+++ b/features/db-discovery/core/src/test/java/org/apache/shardingsphere/dbdiscovery/route/DatabaseDiscoverySQLRouterTest.java
@@ -32,7 +32,7 @@ import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.route.SQLRouterFactory;
import org.apache.shardingsphere.infra.route.context.RouteContext;
@@ -91,7 +91,7 @@ public final class DatabaseDiscoverySQLRouterTest {
@Test
public void assertCreateRouteContextToPrimaryWithoutRouteUnits() {
QueryContext queryContext = new QueryContext(mock(SQLStatementContext.class), "", Collections.emptyList());
- ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS),
+ ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS),
new ShardingSphereRuleMetaData(Collections.singleton(rule)), Collections.emptyMap());
RouteContext actual = sqlRouter.createRouteContext(queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
@@ -102,7 +102,7 @@ public final class DatabaseDiscoverySQLRouterTest {
public void assertDecorateRouteContextToPrimaryDataSource() {
RouteContext actual = mockRouteContext();
QueryContext queryContext = new QueryContext(mock(SQLStatementContext.class), "", Collections.emptyList());
- ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS),
+ ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS),
new ShardingSphereRuleMetaData(Collections.singleton(rule)), Collections.emptyMap());
sqlRouter.decorateRouteContext(actual, queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
@@ -113,7 +113,7 @@ public final class DatabaseDiscoverySQLRouterTest {
@Test
public void assertCreateRouteContextToPrimaryDataSourceWithLock() {
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
- ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS),
+ ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS),
new ShardingSphereRuleMetaData(Collections.singleton(rule)), Collections.emptyMap());
RouteContext actual = sqlRouter.createRouteContext(queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
@@ -124,7 +124,7 @@ public final class DatabaseDiscoverySQLRouterTest {
public void assertDecorateRouteContextToPrimaryDataSourceWithLock() {
RouteContext actual = mockRouteContext();
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
- ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS),
+ ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS),
new ShardingSphereRuleMetaData(Collections.singleton(rule)), Collections.emptyMap());
sqlRouter.decorateRouteContext(actual, queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
@@ -135,7 +135,7 @@ public final class DatabaseDiscoverySQLRouterTest {
@Test
public void assertCreateRouteContextToPrimaryDataSource() {
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
- ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS),
+ ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS),
new ShardingSphereRuleMetaData(Collections.singleton(rule)), Collections.emptyMap());
RouteContext actual = sqlRouter.createRouteContext(queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
diff --git a/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdater.java b/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdater.java
index f08c7487faa..f15744906bc 100644
--- a/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdater.java
+++ b/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdater.java
@@ -33,7 +33,7 @@ import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlg
import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import java.util.Collection;
@@ -55,7 +55,7 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdater implements RuleDef
String databaseName = database.getName();
checkCurrentRuleConfiguration(databaseName, currentRuleConfig);
checkToBeAlteredRules(databaseName, sqlStatement, currentRuleConfig);
- checkToBeAlteredResources(databaseName, sqlStatement, database.getResource());
+ checkToBeAlteredResources(databaseName, sqlStatement, database.getResourceMetaData());
checkDiscoverTypeAndHeartbeat(sqlStatement, currentRuleConfig);
}
@@ -74,8 +74,8 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdater implements RuleDef
return sqlStatement.getRules().stream().map(AbstractDatabaseDiscoverySegment::getName).collect(Collectors.toList());
}
- private void checkToBeAlteredResources(final String databaseName, final AlterDatabaseDiscoveryRuleStatement sqlStatement, final ShardingSphereResource resource) {
- Collection<String> notExistedResources = resource.getNotExistedResources(getToBeAlteredResourceNames(sqlStatement));
+ private void checkToBeAlteredResources(final String databaseName, final AlterDatabaseDiscoveryRuleStatement sqlStatement, final ShardingSphereResourceMetaData resourceMetaData) {
+ Collection<String> notExistedResources = resourceMetaData.getNotExistedResources(getToBeAlteredResourceNames(sqlStatement));
ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistedResources));
}
diff --git a/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdater.java b/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdater.java
index 08cdf519621..72a07328e12 100644
--- a/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdater.java
+++ b/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdater.java
@@ -31,7 +31,7 @@ import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmCo
import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionCreateUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import java.util.Collection;
@@ -53,7 +53,7 @@ public final class CreateDatabaseDiscoveryRuleStatementUpdater implements RuleDe
public void checkSQLStatement(final ShardingSphereDatabase database, final CreateDatabaseDiscoveryRuleStatement sqlStatement, final DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
String databaseName = database.getName();
checkDuplicateRuleNames(databaseName, sqlStatement, currentRuleConfig);
- checkResources(databaseName, sqlStatement, database.getResource());
+ checkResources(databaseName, sqlStatement, database.getResourceMetaData());
checkDiscoverTypeAndHeartbeat(databaseName, sqlStatement, currentRuleConfig);
}
@@ -72,10 +72,10 @@ public final class CreateDatabaseDiscoveryRuleStatementUpdater implements RuleDe
.entrySet().stream().filter(entry -> entry.getValue() > 1).map(Entry::getKey).collect(Collectors.toSet());
}
- private void checkResources(final String databaseName, final CreateDatabaseDiscoveryRuleStatement sqlStatement, final ShardingSphereResource resource) {
+ private void checkResources(final String databaseName, final CreateDatabaseDiscoveryRuleStatement sqlStatement, final ShardingSphereResourceMetaData resourceMetaData) {
Collection<String> resources = new LinkedHashSet<>();
sqlStatement.getRules().forEach(each -> resources.addAll(each.getDataSources()));
- Collection<String> notExistResources = resource.getNotExistedResources(resources);
+ Collection<String> notExistResources = resourceMetaData.getNotExistedResources(resources);
ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistResources));
}
diff --git a/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java b/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
index 5cac5501b66..ba6b21df2a7 100644
--- a/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
+++ b/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmCo
import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -56,13 +56,13 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdaterTest {
private ShardingSphereDatabase database;
@Mock
- private ShardingSphereResource resource;
+ private ShardingSphereResourceMetaData resourceMetaData;
private final AlterDatabaseDiscoveryRuleStatementUpdater updater = new AlterDatabaseDiscoveryRuleStatementUpdater();
@Before
public void before() {
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
}
@Test(expected = MissingRequiredRuleException.class)
@@ -79,7 +79,7 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdaterTest {
@Test(expected = MissingRequiredResourcesException.class)
public void assertCheckSQLStatementWithoutExistedResources() {
- when(resource.getNotExistedResources(any())).thenReturn(Collections.singleton("ds0"));
+ when(resourceMetaData.getNotExistedResources(any())).thenReturn(Collections.singleton("ds0"));
DatabaseDiscoveryConstructionSegment segment = new DatabaseDiscoveryConstructionSegment("readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), "readwrite_ds_mgr", "readwrite_ds_heartbeat");
DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("readwrite_ds", Collections.emptyList(), "ha-heartbeat", "TEST");
DatabaseDiscoveryRuleConfiguration ruleConfig = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)),
diff --git a/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java b/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java
index b22f92df35e..d903bc85c27 100644
--- a/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java
+++ b/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleExcep
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -58,11 +58,11 @@ public final class CreateDatabaseDiscoveryRuleStatementUpdaterTest {
private ShardingSphereDatabase database;
@Mock
- private ShardingSphereResource resource;
+ private ShardingSphereResourceMetaData resourceMetaData;
@Before
public void before() {
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
}
@Test(expected = DuplicateRuleException.class)
@@ -75,7 +75,7 @@ public final class CreateDatabaseDiscoveryRuleStatementUpdaterTest {
@Test(expected = MissingRequiredResourcesException.class)
public void assertCheckSQLStatementWithoutExistedResources() {
- when(resource.getNotExistedResources(any())).thenReturn(Collections.singleton("ds_read_0"));
+ when(resourceMetaData.getNotExistedResources(any())).thenReturn(Collections.singleton("ds_read_0"));
DatabaseDiscoveryConstructionSegment segment = new DatabaseDiscoveryConstructionSegment("readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), "", "");
updater.checkSQLStatement(database, new CreateDatabaseDiscoveryRuleStatement(Collections.singleton(segment)), null);
}
diff --git a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/route/ReadwriteSplittingSQLRouterTest.java b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/route/ReadwriteSplittingSQLRouterTest.java
index a3e84665e6f..bae26bf5639 100644
--- a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/route/ReadwriteSplittingSQLRouterTest.java
+++ b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/route/ReadwriteSplittingSQLRouterTest.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.context.ConnectionContext;
import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.route.SQLRouterFactory;
import org.apache.shardingsphere.infra.route.context.RouteContext;
@@ -103,7 +103,7 @@ public final class ReadwriteSplittingSQLRouterTest {
QueryContext queryContext = new QueryContext(mock(SQLStatementContext.class), "", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(rule));
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
RouteContext actual = sqlRouter.createRouteContext(queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
assertThat(actual.getRouteUnits().size(), is(1));
RouteUnit routeUnit = actual.getRouteUnits().iterator().next();
@@ -119,7 +119,7 @@ public final class ReadwriteSplittingSQLRouterTest {
QueryContext queryContext = new QueryContext(mock(SQLStatementContext.class), "", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(rule));
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
sqlRouter.decorateRouteContext(actual, queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
assertThat(routedDataSourceNames.next(), is(NONE_READWRITE_SPLITTING_DATASOURCE_NAME));
@@ -134,7 +134,7 @@ public final class ReadwriteSplittingSQLRouterTest {
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(rule));
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
RouteContext actual = sqlRouter.createRouteContext(queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
assertThat(actual.getRouteUnits().size(), is(1));
RouteUnit routeUnit = actual.getRouteUnits().iterator().next();
@@ -153,7 +153,7 @@ public final class ReadwriteSplittingSQLRouterTest {
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(rule));
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
sqlRouter.decorateRouteContext(actual, queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
assertThat(routedDataSourceNames.next(), is(NONE_READWRITE_SPLITTING_DATASOURCE_NAME));
@@ -168,7 +168,7 @@ public final class ReadwriteSplittingSQLRouterTest {
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(rule));
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
RouteContext actual = sqlRouter.createRouteContext(queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
assertThat(routedDataSourceNames.next(), is(WRITE_DATASOURCE));
@@ -183,7 +183,7 @@ public final class ReadwriteSplittingSQLRouterTest {
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(rule));
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
sqlRouter.decorateRouteContext(actual, queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
assertThat(routedDataSourceNames.next(), is(NONE_READWRITE_SPLITTING_DATASOURCE_NAME));
@@ -196,7 +196,7 @@ public final class ReadwriteSplittingSQLRouterTest {
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(rule));
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
RouteContext actual = sqlRouter.createRouteContext(queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
assertThat(routedDataSourceNames.next(), is(WRITE_DATASOURCE));
@@ -209,7 +209,7 @@ public final class ReadwriteSplittingSQLRouterTest {
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(rule));
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
RouteContext actual = sqlRouter.createRouteContext(queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
assertThat(routedDataSourceNames.next(), is(WRITE_DATASOURCE));
@@ -232,7 +232,7 @@ public final class ReadwriteSplittingSQLRouterTest {
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(rule));
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
RouteContext actual = sqlRouter.createRouteContext(queryContext, database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
assertThat(routedDataSourceNames.next(), is(WRITE_DATASOURCE));
@@ -245,7 +245,7 @@ public final class ReadwriteSplittingSQLRouterTest {
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(dynamicRule));
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
RouteContext actual = dynamicSqlRouter.createRouteContext(queryContext, database, dynamicRule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
assertThat(routedDataSourceNames.next(), is(WRITE_DATASOURCE));
@@ -259,7 +259,7 @@ public final class ReadwriteSplittingSQLRouterTest {
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(dynamicRule));
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
dynamicSqlRouter.decorateRouteContext(actual, queryContext, database, dynamicRule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
assertThat(routedDataSourceNames.next(), is(NONE_READWRITE_SPLITTING_DATASOURCE_NAME));
diff --git a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdater.java b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdater.java
index 811c0b0c1d5..ceafd2be270 100644
--- a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdater.java
+++ b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdater.java
@@ -94,7 +94,7 @@ public final class AlterReadwriteSplittingRuleStatementUpdater implements RuleDe
requireDiscoverableResources.add(each.getAutoAwareResource());
}
});
- Collection<String> notExistResources = database.getResource().getNotExistedResources(requireResources);
+ Collection<String> notExistResources = database.getResourceMetaData().getNotExistedResources(requireResources);
ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistResources));
Collection<String> logicResources = getLogicResources(database);
Set<String> notExistLogicResources = requireDiscoverableResources.stream().filter(each -> !logicResources.contains(each)).collect(Collectors.toSet());
diff --git a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdater.java b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdater.java
index 84d34ab5fdf..e06218a62cf 100644
--- a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdater.java
+++ b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdater.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmCo
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidRuleConfigurationException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionCreateUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.rule.identifier.type.exportable.ExportableRule;
import org.apache.shardingsphere.infra.rule.identifier.type.exportable.RuleExportEngine;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -54,7 +54,7 @@ public final class CreateReadwriteSplittingRuleStatementUpdater implements RuleD
@Override
public void checkSQLStatement(final ShardingSphereDatabase database, final CreateReadwriteSplittingRuleStatement sqlStatement, final ReadwriteSplittingRuleConfiguration currentRuleConfig) {
String databaseName = database.getName();
- checkDuplicateRuleNames(databaseName, sqlStatement, currentRuleConfig, database.getResource());
+ checkDuplicateRuleNames(databaseName, sqlStatement, currentRuleConfig, database.getResourceMetaData());
checkToBeCreatedResources(databaseName, sqlStatement, database);
// TODO move all check methods to checker
ReadwriteSplittingRuleStatementChecker.checkDuplicateResourceNames(databaseName, sqlStatement.getRules(), currentRuleConfig, true);
@@ -62,10 +62,10 @@ public final class CreateReadwriteSplittingRuleStatementUpdater implements RuleD
}
private void checkDuplicateRuleNames(final String databaseName, final CreateReadwriteSplittingRuleStatement sqlStatement,
- final ReadwriteSplittingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) {
+ final ReadwriteSplittingRuleConfiguration currentRuleConfig, final ShardingSphereResourceMetaData resourceMetaData) {
Collection<String> currentRuleNames = new LinkedList<>();
- if (null != resource && null != resource.getDataSources()) {
- currentRuleNames.addAll(resource.getDataSources().keySet());
+ if (null != resourceMetaData && null != resourceMetaData.getDataSources()) {
+ currentRuleNames.addAll(resourceMetaData.getDataSources().keySet());
}
Collection<String> duplicateRuleNames = sqlStatement.getRules().stream().map(ReadwriteSplittingRuleSegment::getName).filter(currentRuleNames::contains).collect(Collectors.toList());
if (!duplicateRuleNames.isEmpty()) {
@@ -91,7 +91,7 @@ public final class CreateReadwriteSplittingRuleStatementUpdater implements RuleD
requireDiscoverableResources.add(each.getAutoAwareResource());
}
});
- Collection<String> notExistResources = database.getResource().getNotExistedResources(requireResources);
+ Collection<String> notExistResources = database.getResourceMetaData().getNotExistedResources(requireResources);
ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistResources));
Collection<String> logicResources = getLogicResources(database);
Collection<String> notExistLogicResources = requireDiscoverableResources.stream().filter(each -> !logicResources.contains(each)).collect(Collectors.toSet());
diff --git a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
index df6ef7e8b07..d1264c7abcd 100644
--- a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
+++ b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmCo
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidRuleConfigurationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.rule.identifier.type.exportable.ExportableRule;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
@@ -55,13 +55,13 @@ public final class AlterReadwriteSplittingRuleStatementUpdaterTest {
private ShardingSphereDatabase database;
@Mock
- private ShardingSphereResource resource;
+ private ShardingSphereResourceMetaData resourceMetaData;
private final AlterReadwriteSplittingRuleStatementUpdater updater = new AlterReadwriteSplittingRuleStatementUpdater();
@Before
public void before() {
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
}
@Test(expected = MissingRequiredRuleException.class)
@@ -76,7 +76,7 @@ public final class AlterReadwriteSplittingRuleStatementUpdaterTest {
@Test(expected = MissingRequiredResourcesException.class)
public void assertCheckSQLStatementWithoutExistedResources() {
- when(resource.getNotExistedResources(any())).thenReturn(Collections.singleton("read_ds_0"));
+ when(resourceMetaData.getNotExistedResources(any())).thenReturn(Collections.singleton("read_ds_0"));
updater.checkSQLStatement(database, createSQLStatement("TEST"), createCurrentRuleConfiguration());
}
@@ -98,28 +98,28 @@ public final class AlterReadwriteSplittingRuleStatementUpdaterTest {
@Test(expected = InvalidRuleConfigurationException.class)
public void assertCheckSQLStatementWithDuplicateWriteResourceNamesInStatement() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
updater.checkSQLStatement(database, createSQLStatementWithDuplicateWriteResourceNames("readwrite_ds_0", "readwrite_ds_1", "TEST"), createCurrentRuleConfigurationWithMultipleRules());
}
@Test(expected = InvalidRuleConfigurationException.class)
public void assertCheckSQLStatementWithDuplicateWriteResourceNames() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
updater.checkSQLStatement(database, createSQLStatement("readwrite_ds_0", "ds_write_1", Arrays.asList("read_ds_0", "read_ds_1"), "TEST"), createCurrentRuleConfigurationWithMultipleRules());
}
@Test(expected = InvalidRuleConfigurationException.class)
public void assertCheckSQLStatementWithDuplicateReadResourceNamesInStatement() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
updater.checkSQLStatement(database, createSQLStatementWithDuplicateReadResourceNames("readwrite_ds_0", "readwrite_ds_1", "TEST"), createCurrentRuleConfigurationWithMultipleRules());
}
@Test(expected = InvalidRuleConfigurationException.class)
public void assertCheckSQLStatementWithDuplicateReadResourceNames() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
updater.checkSQLStatement(database, createSQLStatement("readwrite_ds_1", "write_ds_1", Arrays.asList("read_ds_0_0", "read_ds_0_1"), "TEST"), createCurrentRuleConfigurationWithMultipleRules());
}
diff --git a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
index ffc9ba75adb..9d46633ae2e 100644
--- a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
+++ b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleExcep
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidRuleConfigurationException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.rule.identifier.type.exportable.ExportableRule;
import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
@@ -64,33 +64,33 @@ public final class CreateReadwriteSplittingRuleStatementUpdaterTest {
private ShardingSphereDatabase database;
@Mock
- private ShardingSphereResource resource;
+ private ShardingSphereResourceMetaData resourceMetaData;
private final CreateReadwriteSplittingRuleStatementUpdater updater = new CreateReadwriteSplittingRuleStatementUpdater();
@Before
public void before() {
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
}
@Test(expected = DuplicateRuleException.class)
public void assertCheckSQLStatementWithDuplicateRuleNames() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDataSources().keySet()).thenReturn(Collections.emptySet());
+ when(database.getResourceMetaData().getDataSources().keySet()).thenReturn(Collections.emptySet());
updater.checkSQLStatement(database, createSQLStatement("TEST"), createCurrentRuleConfiguration());
}
@Test(expected = InvalidRuleConfigurationException.class)
public void assertCheckSQLStatementWithDuplicateResource() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource()).thenReturn(resource);
- when(resource.getDataSources()).thenReturn(Collections.singletonMap("write_ds", null));
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
+ when(resourceMetaData.getDataSources()).thenReturn(Collections.singletonMap("write_ds", null));
updater.checkSQLStatement(database, createSQLStatement("write_ds", "TEST"), createCurrentRuleConfiguration());
}
@Test(expected = MissingRequiredResourcesException.class)
public void assertCheckSQLStatementWithoutExistedResources() {
- when(resource.getNotExistedResources(any())).thenReturn(Arrays.asList("read_ds_0", "read_ds_1"));
+ when(resourceMetaData.getNotExistedResources(any())).thenReturn(Arrays.asList("read_ds_0", "read_ds_1"));
updater.checkSQLStatement(database, createSQLStatement("TEST"), null);
}
@@ -112,28 +112,28 @@ public final class CreateReadwriteSplittingRuleStatementUpdaterTest {
@Test(expected = InvalidRuleConfigurationException.class)
public void assertCheckSQLStatementWithDuplicateWriteResourceNamesInStatement() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
updater.checkSQLStatement(database, createSQLStatementWithDuplicateWriteResourceNames("write_ds_0", "write_ds_1", "TEST"), null);
}
@Test(expected = InvalidRuleConfigurationException.class)
public void assertCheckSQLStatementWithDuplicateWriteResourceNames() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
updater.checkSQLStatement(database, createSQLStatement("readwrite_ds_1", "ds_write", Arrays.asList("read_ds_0", "read_ds_1"), "TEST"), createCurrentRuleConfiguration());
}
@Test(expected = InvalidRuleConfigurationException.class)
public void assertCheckSQLStatementWithDuplicateReadResourceNamesInStatement() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
updater.checkSQLStatement(database, createSQLStatementWithDuplicateReadResourceNames("write_ds_0", "write_ds_1", "TEST"), null);
}
@Test(expected = InvalidRuleConfigurationException.class)
public void assertCheckSQLStatementWithDuplicateReadResourceNames() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
updater.checkSQLStatement(database, createSQLStatement("readwrite_ds_1", "write_ds_1", Arrays.asList("read_ds_0", "read_ds_1"), "TEST"), createCurrentRuleConfiguration());
}
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
index 09bbab10022..ea70d3f90f1 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
@@ -56,7 +56,7 @@ public class ShadowRuleStatementChecker {
* @param database database
*/
public static void checkResourceExist(final Collection<String> resources, final ShardingSphereDatabase database) {
- Collection<String> notExistedResources = database.getResource().getNotExistedResources(resources);
+ Collection<String> notExistedResources = database.getResourceMetaData().getNotExistedResources(resources);
ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new MissingRequiredResourcesException(database.getName(), notExistedResources));
}
diff --git a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
index fc3f671f193..98c77535679 100644
--- a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
+++ b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleExcep
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
import org.apache.shardingsphere.shadow.distsql.handler.update.AlterShadowRuleStatementUpdater;
@@ -55,7 +55,7 @@ public final class AlterShadowRuleStatementUpdaterTest {
private ShardingSphereDatabase database;
@Mock
- private ShardingSphereResource resource;
+ private ShardingSphereResourceMetaData resourceMetaData;
@Mock
private ShadowRuleConfiguration currentConfig;
@@ -67,7 +67,7 @@ public final class AlterShadowRuleStatementUpdaterTest {
Map<String, ShadowDataSourceConfiguration> map = new HashMap<>();
map.put("initRuleName1", new ShadowDataSourceConfiguration("ds1", "ds_shadow1"));
map.put("initRuleName2", new ShadowDataSourceConfiguration("ds2", "ds_shadow2"));
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(currentConfig.getDataSources()).thenReturn(map);
}
@@ -92,7 +92,7 @@ public final class AlterShadowRuleStatementUpdaterTest {
@Test(expected = MissingRequiredResourcesException.class)
public void assertExecuteWithNotExistResource() {
List<String> dataSources = Arrays.asList("ds", "ds0");
- when(resource.getNotExistedResources(any())).thenReturn(dataSources);
+ when(resourceMetaData.getNotExistedResources(any())).thenReturn(dataSources);
AlterShadowRuleStatement sqlStatement = createSQLStatement(new ShadowRuleSegment("initRuleName1", "ds3", null, null));
updater.checkSQLStatement(database, sqlStatement, currentConfig);
}
diff --git a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
index a9ba9558a59..fefb8ab4225 100644
--- a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
+++ b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
import org.apache.shardingsphere.shadow.distsql.handler.update.CreateShadowRuleStatementUpdater;
@@ -51,7 +51,7 @@ public final class CreateShadowRuleStatementUpdaterTest {
private ShardingSphereDatabase database;
@Mock
- private ShardingSphereResource resource;
+ private ShardingSphereResourceMetaData resourceMetaData;
@Mock
private ShadowRuleConfiguration currentConfig;
@@ -60,7 +60,7 @@ public final class CreateShadowRuleStatementUpdaterTest {
@Before
public void before() {
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(currentConfig.getDataSources()).thenReturn(Collections.singletonMap("initRuleName", new ShadowDataSourceConfiguration("initDs0", "initDs0Shadow")));
}
@@ -80,7 +80,7 @@ public final class CreateShadowRuleStatementUpdaterTest {
@Test(expected = MissingRequiredResourcesException.class)
public void assertExecuteWithNotExistResource() {
List<String> dataSources = Arrays.asList("ds0", "ds1");
- when(resource.getNotExistedResources(any())).thenReturn(dataSources);
+ when(resourceMetaData.getNotExistedResources(any())).thenReturn(dataSources);
CreateShadowRuleStatement sqlStatement = createSQLStatement(new ShadowRuleSegment("ruleName", "ds1", null, null));
updater.checkSQLStatement(database, sqlStatement, currentConfig);
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
index 4cab575bf7e..33ef4abf227 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
@@ -115,7 +115,7 @@ public final class ShardingRouteEngineFactory {
return new ShardingDatabaseBroadcastRoutingEngine();
}
if (sqlStatement instanceof CreateTablespaceStatement || sqlStatement instanceof AlterTablespaceStatement || sqlStatement instanceof DropTablespaceStatement) {
- return new ShardingInstanceBroadcastRoutingEngine(database.getResource());
+ return new ShardingInstanceBroadcastRoutingEngine(database.getResourceMetaData());
}
Collection<String> tableNames = sqlStatementContext instanceof TableAvailable
? ((TableAvailable) sqlStatementContext).getAllTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toSet())
@@ -163,7 +163,7 @@ public final class ShardingRouteEngineFactory {
return new ShardingDatabaseBroadcastRoutingEngine();
}
if (isResourceGroupStatement(sqlStatement)) {
- return new ShardingInstanceBroadcastRoutingEngine(database.getResource());
+ return new ShardingInstanceBroadcastRoutingEngine(database.getResourceMetaData());
}
Collection<String> tableNames = sqlStatementContext.getTablesContext().getTableNames();
Collection<String> shardingRuleTableNames = shardingRule.getShardingRuleTableNames(tableNames);
@@ -193,7 +193,7 @@ public final class ShardingRouteEngineFactory {
Collection<String> shardingRuleTableNames = shardingRule.getShardingRuleTableNames(sqlStatementContext.getTablesContext().getTableNames());
return shardingRuleTableNames.isEmpty() ? new ShardingIgnoreRoutingEngine() : new ShardingTableBroadcastRoutingEngine(database, sqlStatementContext, shardingRuleTableNames);
}
- return new ShardingInstanceBroadcastRoutingEngine(database.getResource());
+ return new ShardingInstanceBroadcastRoutingEngine(database.getResourceMetaData());
}
private static boolean isDCLForSingleTable(final SQLStatementContext<?> sqlStatementContext) {
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingInstanceBroadcastRoutingEngine.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingInstanceBroadcastRoutingEngine.java
index 84ef4e7f91f..6631188ddc1 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingInstanceBroadcastRoutingEngine.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingInstanceBroadcastRoutingEngine.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.route.engine.type.broadcast;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
import org.apache.shardingsphere.infra.route.context.RouteUnit;
@@ -33,13 +33,13 @@ import java.util.Collections;
@RequiredArgsConstructor
public final class ShardingInstanceBroadcastRoutingEngine implements ShardingRouteEngine {
- private final ShardingSphereResource resource;
+ private final ShardingSphereResourceMetaData resourceMetaData;
@Override
public RouteContext route(final ShardingRule shardingRule) {
RouteContext result = new RouteContext();
for (String each : shardingRule.getDataSourceNames()) {
- if (resource.getAllInstanceDataSourceNames().contains(each)) {
+ if (resourceMetaData.getAllInstanceDataSourceNames().contains(each)) {
result.getRouteUnits().add(new RouteUnit(new RouteMapper(each, each), Collections.emptyList()));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
index bd601048b27..5982158ea83 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResult;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
@@ -508,7 +508,7 @@ public final class ShardingDQLResultMergerTest {
ShardingSphereColumn column3 = new ShardingSphereColumn("col3", 0, false, false, false, true);
ShardingSphereTable table = new ShardingSphereTable("tbl", Arrays.asList(column1, column2, column3), Collections.emptyList(), Collections.emptyList());
ShardingSphereSchema schema = new ShardingSphereSchema(Collections.singletonMap("tbl", table), Collections.emptyMap());
- return new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, DatabaseTypeFactory.getInstance("MySQL"), mock(ShardingSphereResource.class),
+ return new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, DatabaseTypeFactory.getInstance("MySQL"), mock(ShardingSphereResourceMetaData.class),
mock(ShardingSphereRuleMetaData.class), Collections.singletonMap(DefaultDatabase.LOGIC_NAME, schema));
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByStreamMergedResultTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByStreamMergedResultTest.java
index 7430046f34f..fb96292df1e 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByStreamMergedResultTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByStreamMergedResultTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResult;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
@@ -180,7 +180,7 @@ public final class GroupByStreamMergedResultTest {
ShardingSphereTable table = new ShardingSphereTable("tbl", Arrays.asList(column1, column2, column3), Collections.emptyList(), Collections.emptyList());
ShardingSphereSchema schema = new ShardingSphereSchema(Collections.singletonMap("tbl", table), Collections.emptyMap());
return new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, DatabaseTypeFactory.getInstance("MySQL"),
- mock(ShardingSphereResource.class), mock(ShardingSphereRuleMetaData.class), Collections.singletonMap(DefaultDatabase.LOGIC_NAME, schema));
+ mock(ShardingSphereResourceMetaData.class), mock(ShardingSphereRuleMetaData.class), Collections.singletonMap(DefaultDatabase.LOGIC_NAME, schema));
}
private QueryResult mockQueryResult() throws SQLException {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByStreamMergedResultTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByStreamMergedResultTest.java
index 6110b3ff36a..11d1e4425aa 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByStreamMergedResultTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByStreamMergedResultTest.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryRe
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResultMetaData;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
@@ -201,6 +201,7 @@ public final class OrderByStreamMergedResultTest {
ShardingSphereTable table = new ShardingSphereTable("tbl", Arrays.asList(column1, column2), Collections.emptyList(), Collections.emptyList());
ShardingSphereSchema schema = new ShardingSphereSchema(Collections.singletonMap("tbl", table), Collections.emptyMap());
return new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- DatabaseTypeFactory.getInstance("MySQL"), mock(ShardingSphereResource.class), mock(ShardingSphereRuleMetaData.class), Collections.singletonMap(DefaultDatabase.LOGIC_NAME, schema));
+ DatabaseTypeFactory.getInstance("MySQL"), mock(ShardingSphereResourceMetaData.class), mock(ShardingSphereRuleMetaData.class),
+ Collections.singletonMap(DefaultDatabase.LOGIC_NAME, schema));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingInstanceBroadcastRoutingEngineTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingInstanceBroadcastRoutingEngineTest.java
index 2b76c22c4e9..c7730b6f9e9 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingInstanceBroadcastRoutingEngineTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingInstanceBroadcastRoutingEngineTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sharding.route.engine.type.broadcast;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.junit.Before;
@@ -41,15 +41,15 @@ public final class ShardingInstanceBroadcastRoutingEngineTest {
private ShardingRule shardingRule;
@Mock
- private ShardingSphereResource resource;
+ private ShardingSphereResourceMetaData resourceMetaData;
private ShardingInstanceBroadcastRoutingEngine shardingInstanceBroadcastRoutingEngine;
@Before
public void setUp() {
when(shardingRule.getDataSourceNames()).thenReturn(Collections.singletonList(DATASOURCE_NAME));
- when(resource.getAllInstanceDataSourceNames()).thenReturn(Collections.singleton(DATASOURCE_NAME));
- shardingInstanceBroadcastRoutingEngine = new ShardingInstanceBroadcastRoutingEngine(resource);
+ when(resourceMetaData.getAllInstanceDataSourceNames()).thenReturn(Collections.singleton(DATASOURCE_NAME));
+ shardingInstanceBroadcastRoutingEngine = new ShardingInstanceBroadcastRoutingEngine(resourceMetaData);
}
@Test
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRoutingEngineTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRoutingEngineTest.java
index c405d3ccc64..ca422183ae1 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRoutingEngineTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRoutingEngineTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.route.context.RouteContext;
@@ -106,7 +106,7 @@ public final class ShardingTableBroadcastRoutingEngineTest extends AbstractRouti
when(((IndexAvailable) sqlStatementContext).getIndexes()).thenReturn(Collections.singletonList(segment));
Map<String, ShardingSphereSchema> schemas = Collections.singletonMap(DefaultDatabase.LOGIC_NAME, schema);
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- new MySQLDatabaseType(), mock(ShardingSphereResource.class), mock(ShardingSphereRuleMetaData.class), schemas);
+ new MySQLDatabaseType(), mock(ShardingSphereResourceMetaData.class), mock(ShardingSphereRuleMetaData.class), schemas);
ShardingTableBroadcastRoutingEngine shardingTableBroadcastRoutingEngine = new ShardingTableBroadcastRoutingEngine(database, sqlStatementContext, tableNames);
RouteContext routeContext = shardingTableBroadcastRoutingEngine.route(createShardingRule(false));
assertThat(routeContext.getActualDataSourceNames().size(), is(2));
@@ -128,7 +128,7 @@ public final class ShardingTableBroadcastRoutingEngineTest extends AbstractRouti
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(tableNames);
Map<String, ShardingSphereSchema> schemas = Collections.singletonMap(DefaultDatabase.LOGIC_NAME, schema);
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- new MySQLDatabaseType(), mock(ShardingSphereResource.class), mock(ShardingSphereRuleMetaData.class), schemas);
+ new MySQLDatabaseType(), mock(ShardingSphereResourceMetaData.class), mock(ShardingSphereRuleMetaData.class), schemas);
ShardingTableBroadcastRoutingEngine shardingTableBroadcastRoutingEngine = new ShardingTableBroadcastRoutingEngine(database, sqlStatementContext, tableNames);
RouteContext routeContext = shardingTableBroadcastRoutingEngine.route(createShardingRule(false));
assertRouteUnitWithoutTables(routeContext);
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/AbstractSQLRouteTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/AbstractSQLRouteTest.java
index 4480b0df5cf..6fc3d9089fa 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/AbstractSQLRouteTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/AbstractSQLRouteTest.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
@@ -61,9 +61,9 @@ public abstract class AbstractSQLRouteTest extends AbstractRoutingEngineTest {
SQLStatementParserEngine sqlStatementParserEngine = new SQLStatementParserEngine("MySQL",
new CacheOption(2000, 65535L), new CacheOption(128, 1024L), false);
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Arrays.asList(shardingRule, singleTableRule));
- ShardingSphereResource resource = mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS);
- when(resource.getDatabaseType()).thenReturn(new MySQLDatabaseType());
- ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, DatabaseTypeFactory.getInstance("MySQL"), resource, ruleMetaData, schemas);
+ ShardingSphereResourceMetaData resourceMetaData = mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS);
+ when(resourceMetaData.getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, DatabaseTypeFactory.getInstance("MySQL"), resourceMetaData, ruleMetaData, schemas);
Map<String, ShardingSphereDatabase> databases = Collections.singletonMap(DefaultDatabase.LOGIC_NAME, database);
SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(databases, parameters, sqlStatementParserEngine.parse(sql, false), DefaultDatabase.LOGIC_NAME);
QueryContext queryContext = new QueryContext(sqlStatementContext, sql, parameters);
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
index 25cee8de7fb..376603c37ac 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
@@ -157,7 +157,7 @@ public final class ShardingTableRuleStatementChecker {
private static void checkResources(final String databaseName, final Collection<AbstractTableRuleSegment> rules, final ShardingSphereDatabase database) {
Collection<String> requiredResource = getRequiredResources(rules);
- Collection<String> notExistedResources = database.getResource().getNotExistedResources(requiredResource);
+ Collection<String> notExistedResources = database.getResourceMetaData().getNotExistedResources(requiredResource);
Collection<String> logicResources = getLogicResources(database);
notExistedResources.removeIf(logicResources::contains);
ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistedResources));
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
index 09df22b4acb..a815eddb012 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmCo
import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -71,12 +71,12 @@ public final class ShardingRuleStatementCheckerTest {
private final ShardingRuleConfiguration shardingRuleConfig = createShardingRuleConfiguration();
- private final ShardingSphereResource shardingSphereResource = new ShardingSphereResource("sharding_db", createDataSource());
+ private final ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", createDataSource());
@Before
public void before() {
when(database.getName()).thenReturn("schema");
- when(database.getResource()).thenReturn(shardingSphereResource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(database.getRuleMetaData()).thenReturn(shardingSphereRuleMetaData);
when(shardingSphereRuleMetaData.getRules()).thenReturn(Collections.emptyList());
}
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
index 97e4ea979c5..ece087d89e4 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -60,20 +60,20 @@ public final class AlterShardingTableRuleStatementUpdaterTest {
private ShardingSphereDatabase database;
@Mock
- private ShardingSphereRuleMetaData shardingSphereRuleMetaData;
+ private ShardingSphereRuleMetaData ruleMetaData;
private final ShardingRuleConfiguration currentRuleConfig = createCurrentShardingRuleConfiguration();
- private final ShardingSphereResource shardingSphereResource = new ShardingSphereResource("sharding_db", createDataSource());
+ private final ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", createDataSource());
private final AlterShardingTableRuleStatementUpdater updater = new AlterShardingTableRuleStatementUpdater();
@Before
public void before() {
when(database.getName()).thenReturn("schema");
- when(database.getResource()).thenReturn(shardingSphereResource);
- when(database.getRuleMetaData()).thenReturn(shardingSphereRuleMetaData);
- when(shardingSphereRuleMetaData.getRules()).thenReturn(Collections.emptyList());
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
+ when(database.getRuleMetaData()).thenReturn(ruleMetaData);
+ when(ruleMetaData.getRules()).thenReturn(Collections.emptyList());
}
@Test
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
index fb0183d0463..6840e370942 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -74,20 +74,20 @@ public final class CreateShardingTableRuleStatementUpdaterTest {
private ShardingSphereDatabase database;
@Mock
- private ShardingSphereRuleMetaData shardingSphereRuleMetaData;
+ private ShardingSphereRuleMetaData ruleMetaData;
private final ShardingRuleConfiguration currentRuleConfig = createCurrentShardingRuleConfiguration();
- private final ShardingSphereResource shardingSphereResource = new ShardingSphereResource("sharding_db", createDataSource());
+ private final ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", createDataSource());
private final CreateShardingTableRuleStatementUpdater updater = new CreateShardingTableRuleStatementUpdater();
@Before
public void before() {
when(database.getName()).thenReturn("schema");
- when(database.getResource()).thenReturn(shardingSphereResource);
- when(database.getRuleMetaData()).thenReturn(shardingSphereRuleMetaData);
- when(shardingSphereRuleMetaData.getRules()).thenReturn(Collections.singleton(new MockDataSourceContainedRule()));
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
+ when(database.getRuleMetaData()).thenReturn(ruleMetaData);
+ when(ruleMetaData.getRules()).thenReturn(Collections.singleton(new MockDataSourceContainedRule()));
}
@Test
diff --git a/features/sharding/plugin/cache/src/test/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableCheckerTest.java b/features/sharding/plugin/cache/src/test/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableCheckerTest.java
index 7d8906a75fa..0a1663332ae 100644
--- a/features/sharding/plugin/cache/src/test/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableCheckerTest.java
+++ b/features/sharding/plugin/cache/src/test/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableCheckerTest.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
@@ -164,7 +164,7 @@ public final class ShardingRouteCacheableCheckerTest {
new ShardingSphereColumn("warehouse_id", Types.INTEGER, false, false, false, true),
new ShardingSphereColumn("order_broadcast_table_id", Types.INTEGER, true, false, false, true)),
Collections.emptyList(), Collections.emptyList()));
- return new ShardingSphereDatabase(DATABASE_NAME, DatabaseTypeFactory.getInstance("PostgreSQL"), new ShardingSphereResource(DATABASE_NAME, Collections.emptyMap()),
+ return new ShardingSphereDatabase(DATABASE_NAME, DatabaseTypeFactory.getInstance("PostgreSQL"), new ShardingSphereResourceMetaData(DATABASE_NAME, Collections.emptyMap()),
new ShardingSphereRuleMetaData(Arrays.asList(shardingRule, shardingCacheRule)), Collections.singletonMap(SCHEMA_NAME, schema));
}
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/decider/engine/SQLFederationDeciderEngineTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/decider/engine/SQLFederationDeciderEngineTest.java
index c7406b786e3..daa034ea5e1 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/decider/engine/SQLFederationDeciderEngineTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/decider/engine/SQLFederationDeciderEngineTest.java
@@ -29,7 +29,7 @@ import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.junit.Test;
@@ -55,7 +55,7 @@ public final class SQLFederationDeciderEngineTest {
when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.singletonList("information_schema"));
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList());
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
SQLFederationDeciderContext actual = deciderEngine.decide(queryContext, database);
assertTrue(actual.isUseSQLFederation());
}
@@ -66,7 +66,7 @@ public final class SQLFederationDeciderEngineTest {
SQLFederationDeciderEngine deciderEngine = new SQLFederationDeciderEngine(rules, new ConfigurationProperties(new Properties()));
QueryContext queryContext = new QueryContext(mock(CommonSQLStatementContext.class), "", Collections.emptyList());
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), new ShardingSphereRuleMetaData(rules), Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), new ShardingSphereRuleMetaData(rules), Collections.emptyMap());
SQLFederationDeciderContext actual = deciderEngine.decide(queryContext, database);
assertFalse(actual.isUseSQLFederation());
}
@@ -79,7 +79,7 @@ public final class SQLFederationDeciderEngineTest {
SQLFederationDeciderEngine deciderEngine = new SQLFederationDeciderEngine(rules, new ConfigurationProperties(props));
QueryContext queryContext = new QueryContext(mock(CommonSQLStatementContext.class), "", Collections.emptyList());
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), new ShardingSphereRuleMetaData(rules), Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), new ShardingSphereRuleMetaData(rules), Collections.emptyMap());
SQLFederationDeciderContext actual = deciderEngine.decide(queryContext, database);
assertFalse(actual.isUseSQLFederation());
}
@@ -92,7 +92,7 @@ public final class SQLFederationDeciderEngineTest {
SQLFederationDeciderEngine deciderEngine = new SQLFederationDeciderEngine(rules, new ConfigurationProperties(props));
QueryContext queryContext = new QueryContext(mock(SelectStatementContext.class, RETURNS_DEEP_STUBS), "", Collections.emptyList());
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), new ShardingSphereRuleMetaData(rules), Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), new ShardingSphereRuleMetaData(rules), Collections.emptyMap());
SQLFederationDeciderContext actual = deciderEngine.decide(queryContext, database);
assertTrue(actual.isUseSQLFederation());
}
@@ -105,7 +105,7 @@ public final class SQLFederationDeciderEngineTest {
SQLFederationDeciderEngine deciderEngine = new SQLFederationDeciderEngine(rules, new ConfigurationProperties(props));
QueryContext queryContext = new QueryContext(mock(SelectStatementContext.class, RETURNS_DEEP_STUBS), "", Collections.emptyList());
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), new ShardingSphereRuleMetaData(rules), Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), new ShardingSphereRuleMetaData(rules), Collections.emptyMap());
SQLFederationDeciderContext actual = deciderEngine.decide(queryContext, database);
assertFalse(actual.isUseSQLFederation());
}
@@ -118,7 +118,7 @@ public final class SQLFederationDeciderEngineTest {
SQLFederationDeciderEngine deciderEngine = new SQLFederationDeciderEngine(rules, new ConfigurationProperties(props));
QueryContext queryContext = new QueryContext(mock(SelectStatementContext.class, RETURNS_DEEP_STUBS), "", Collections.emptyList());
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME,
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), new ShardingSphereRuleMetaData(rules), Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), new ShardingSphereRuleMetaData(rules), Collections.emptyMap());
SQLFederationDeciderContext actual = deciderEngine.decide(queryContext, database);
assertTrue(actual.isUseSQLFederation());
}
diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java
index a80ae4b42ed..cfc9f5e5fb1 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java
@@ -120,6 +120,6 @@ public final class ShardingSphereMetaData {
globalRuleMetaData.findRules(ResourceHeldRule.class).forEach(each -> each.closeStaleResource(databaseName));
database.getRuleMetaData().findRules(ResourceHeldRule.class).forEach(each -> each.closeStaleResource(databaseName));
database.getRuleMetaData().findSingleRule(DynamicDataSourceContainedRule.class).ifPresent(DynamicDataSourceContainedRule::closeHeartBeatJob);
- Optional.ofNullable(database.getResource()).ifPresent(optional -> optional.getDataSources().values().forEach(each -> database.getResource().close(each)));
+ Optional.ofNullable(database.getResourceMetaData()).ifPresent(optional -> optional.getDataSources().values().forEach(each -> database.getResourceMetaData().close(each)));
}
}
diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabase.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabase.java
index 0e10d89ccaa..3dc3b71abb7 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabase.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabase.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
import org.apache.shardingsphere.infra.datasource.state.DataSourceStateManager;
import org.apache.shardingsphere.infra.instance.InstanceContext;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilder;
import org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilderMaterials;
@@ -54,17 +54,17 @@ public final class ShardingSphereDatabase {
private final DatabaseType protocolType;
- private final ShardingSphereResource resource;
+ private final ShardingSphereResourceMetaData resourceMetaData;
private final ShardingSphereRuleMetaData ruleMetaData;
private final Map<String, ShardingSphereSchema> schemas;
- public ShardingSphereDatabase(final String name, final DatabaseType protocolType, final ShardingSphereResource resource,
+ public ShardingSphereDatabase(final String name, final DatabaseType protocolType, final ShardingSphereResourceMetaData resourceMetaData,
final ShardingSphereRuleMetaData ruleMetaData, final Map<String, ShardingSphereSchema> schemas) {
this.name = name;
this.protocolType = protocolType;
- this.resource = resource;
+ this.resourceMetaData = resourceMetaData;
this.ruleMetaData = ruleMetaData;
this.schemas = new ConcurrentHashMap<>(schemas.size(), 1);
schemas.forEach((key, value) -> this.schemas.put(key.toLowerCase(), value));
@@ -107,13 +107,13 @@ public final class ShardingSphereDatabase {
private static ShardingSphereDatabase create(final String name, final DatabaseType protocolType, final DatabaseConfiguration databaseConfig,
final Collection<ShardingSphereRule> rules, final Map<String, ShardingSphereSchema> schemas) {
- ShardingSphereResource resource = createResource(name, databaseConfig.getDataSources());
+ ShardingSphereResourceMetaData resourceMetaData = createResourceMetaData(name, databaseConfig.getDataSources());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(rules);
- return new ShardingSphereDatabase(name, protocolType, resource, ruleMetaData, schemas);
+ return new ShardingSphereDatabase(name, protocolType, resourceMetaData, ruleMetaData, schemas);
}
- private static ShardingSphereResource createResource(final String databaseName, final Map<String, DataSource> dataSourceMap) {
- return new ShardingSphereResource(databaseName, dataSourceMap);
+ private static ShardingSphereResourceMetaData createResourceMetaData(final String databaseName, final Map<String, DataSource> dataSourceMap) {
+ return new ShardingSphereResourceMetaData(databaseName, dataSourceMap);
}
/**
@@ -161,7 +161,7 @@ public final class ShardingSphereDatabase {
* @return is completed or not
*/
public boolean isComplete() {
- return !ruleMetaData.getRules().isEmpty() && !resource.getDataSources().isEmpty();
+ return !ruleMetaData.getRules().isEmpty() && !resourceMetaData.getDataSources().isEmpty();
}
/**
@@ -170,7 +170,7 @@ public final class ShardingSphereDatabase {
* @return contains data source or not
*/
public boolean containsDataSource() {
- return !resource.getDataSources().isEmpty();
+ return !resourceMetaData.getDataSources().isEmpty();
}
/**
@@ -183,7 +183,7 @@ public final class ShardingSphereDatabase {
RuleConfiguration config = toBeReloadedRules.stream().map(ShardingSphereRule::getConfiguration).findFirst().orElse(null);
toBeReloadedRules.stream().findFirst().ifPresent(optional -> {
ruleMetaData.getRules().removeAll(toBeReloadedRules);
- ruleMetaData.getRules().add(((MutableDataNodeRule) optional).reloadRule(config, name, resource.getDataSources(), ruleMetaData.getRules()));
+ ruleMetaData.getRules().add(((MutableDataNodeRule) optional).reloadRule(config, name, resourceMetaData.getDataSources(), ruleMetaData.getRules()));
});
}
}
diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResource.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResourceMetaData.java
similarity index 95%
rename from infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResource.java
rename to infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResourceMetaData.java
index 43598b352d5..4d4028da0e7 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResource.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResourceMetaData.java
@@ -35,10 +35,10 @@ import java.util.Map.Entry;
import java.util.stream.Collectors;
/**
- * ShardingSphere resource.
+ * ShardingSphere resource meta data.
*/
@Getter
-public final class ShardingSphereResource {
+public final class ShardingSphereResourceMetaData {
private final Map<String, DataSource> dataSources;
@@ -47,7 +47,7 @@ public final class ShardingSphereResource {
@Getter(AccessLevel.NONE)
private final Map<String, DataSourceMetaData> dataSourceMetaDataMap;
- public ShardingSphereResource(final String databaseName, final Map<String, DataSource> dataSources) {
+ public ShardingSphereResourceMetaData(final String databaseName, final Map<String, DataSource> dataSources) {
this.dataSources = dataSources;
databaseType = getDatabaseType(DataSourceStateManager.getInstance().getEnabledDataSourceMap(databaseName, dataSources));
dataSourceMetaDataMap = createDataSourceMetaDataMap(dataSources);
diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
index d6dba8ca6ef..5fa452bb0b6 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
@@ -78,7 +78,7 @@ public enum SystemSchemaBuilderRule {
OPEN_GAUSS_PG_TOAST("openGauss", "pg_toast", Collections.emptySet()),
- OPEN_GAUSS_pkg_util("openGauss", "pkg_util", Collections.emptySet()),
+ OPEN_GAUSS_PKG_UTIL("openGauss", "pkg_util", Collections.emptySet()),
OPEN_GAUSS_SQLADVISOR("openGauss", "sqladvisor", Collections.emptySet()),
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaDataTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaDataTest.java
index 060e95121b5..0d20fb3b50b 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaDataTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaDataTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.rule.identifier.type.ResourceHeldRule;
import org.apache.shardingsphere.test.mock.MockedDataSource;
@@ -40,8 +40,8 @@ import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.verify;
@@ -50,12 +50,12 @@ import static org.mockito.Mockito.when;
public final class ShardingSphereMetaDataTest {
@Test
- public void assertAddDatabase() throws SQLException {
- ShardingSphereResource resource = mock(ShardingSphereResource.class);
+ public void assertAddDatabase() {
+ ShardingSphereResourceMetaData resourceMetaData = mock(ShardingSphereResourceMetaData.class);
DataSource dataSource = new MockedDataSource();
ResourceHeldRule<?> databaseResourceHeldRule = mock(ResourceHeldRule.class);
ResourceHeldRule<?> globalResourceHeldRule = mock(ResourceHeldRule.class);
- ShardingSphereDatabase database = mockDatabase(resource, dataSource, databaseResourceHeldRule);
+ ShardingSphereDatabase database = mockDatabase(resourceMetaData, dataSource, databaseResourceHeldRule);
try (MockedStatic<ShardingSphereDatabase> mockedStatic = mockStatic(ShardingSphereDatabase.class)) {
DatabaseType databaseType = mock(DatabaseType.class);
mockedStatic.when(() -> ShardingSphereDatabase.create("foo_db", databaseType)).thenReturn(database);
@@ -70,24 +70,24 @@ public final class ShardingSphereMetaDataTest {
@Test
public void assertDropDatabase() {
- ShardingSphereResource resource = mock(ShardingSphereResource.class);
+ ShardingSphereResourceMetaData resourceMetaData = mock(ShardingSphereResourceMetaData.class);
DataSource dataSource = new MockedDataSource();
ResourceHeldRule<?> databaseResourceHeldRule = mock(ResourceHeldRule.class);
ResourceHeldRule<?> globalResourceHeldRule = mock(ResourceHeldRule.class);
- ShardingSphereMetaData metaData = new ShardingSphereMetaData(new HashMap<>(Collections.singletonMap("foo_db", mockDatabase(resource, dataSource, databaseResourceHeldRule))),
+ ShardingSphereMetaData metaData = new ShardingSphereMetaData(new HashMap<>(Collections.singletonMap("foo_db", mockDatabase(resourceMetaData, dataSource, databaseResourceHeldRule))),
new ShardingSphereRuleMetaData(Collections.singleton(globalResourceHeldRule)), new ConfigurationProperties(new Properties()));
metaData.dropDatabase("foo_db");
assertTrue(metaData.getDatabases().isEmpty());
- verify(resource).close(dataSource);
+ verify(resourceMetaData).close(dataSource);
verify(databaseResourceHeldRule).closeStaleResource("foo_db");
verify(globalResourceHeldRule).closeStaleResource("foo_db");
}
- private ShardingSphereDatabase mockDatabase(final ShardingSphereResource resource, final DataSource dataSource, final ResourceHeldRule<?> databaseResourceHeldRule) {
+ private ShardingSphereDatabase mockDatabase(final ShardingSphereResourceMetaData resourceMetaData, final DataSource dataSource, final ResourceHeldRule<?> databaseResourceHeldRule) {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class);
when(result.getName()).thenReturn("foo_db");
- when(result.getResource()).thenReturn(resource);
- when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap("foo_db", dataSource));
+ when(result.getResourceMetaData()).thenReturn(resourceMetaData);
+ when(result.getResourceMetaData().getDataSources()).thenReturn(Collections.singletonMap("foo_db", dataSource));
when(result.getRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.singleton(databaseResourceHeldRule)));
return result;
}
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabaseTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabaseTest.java
index a9ccc13c6a3..1bc8d2f75c1 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabaseTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabaseTest.java
@@ -18,11 +18,11 @@
package org.apache.shardingsphere.infra.metadata.database;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.MutableDataNodeRule;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
+import org.apache.shardingsphere.infra.rule.identifier.type.MutableDataNodeRule;
import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
import org.apache.shardingsphere.test.mock.MockedDataSource;
import org.junit.Test;
@@ -32,9 +32,9 @@ import java.util.Collections;
import java.util.LinkedList;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -42,34 +42,34 @@ public final class ShardingSphereDatabaseTest {
@Test
public void assertIsComplete() {
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", Collections.singletonMap("ds", new MockedDataSource()));
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("ds", new MockedDataSource()));
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(mock(ShardingSphereRule.class)));
- assertTrue(new ShardingSphereDatabase("foo_db", mock(DatabaseType.class), resource, ruleMetaData, Collections.emptyMap()).isComplete());
+ assertTrue(new ShardingSphereDatabase("foo_db", mock(DatabaseType.class), resourceMetaData, ruleMetaData, Collections.emptyMap()).isComplete());
}
@Test
public void assertIsNotCompleteWithoutRule() {
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", Collections.singletonMap("ds", new MockedDataSource()));
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("ds", new MockedDataSource()));
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.emptyList());
- assertFalse(new ShardingSphereDatabase("foo_db", mock(DatabaseType.class), resource, ruleMetaData, Collections.emptyMap()).isComplete());
+ assertFalse(new ShardingSphereDatabase("foo_db", mock(DatabaseType.class), resourceMetaData, ruleMetaData, Collections.emptyMap()).isComplete());
}
@Test
public void assertIsNotCompleteWithoutDataSource() {
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", Collections.emptyMap());
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", Collections.emptyMap());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(mock(ShardingSphereRule.class)));
- assertFalse(new ShardingSphereDatabase("foo_db", mock(DatabaseType.class), resource, ruleMetaData, Collections.emptyMap()).isComplete());
+ assertFalse(new ShardingSphereDatabase("foo_db", mock(DatabaseType.class), resourceMetaData, ruleMetaData, Collections.emptyMap()).isComplete());
}
@Test
public void assertReloadRules() {
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", Collections.singletonMap("ds", new MockedDataSource()));
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("ds", new MockedDataSource()));
Collection<ShardingSphereRule> rules = new LinkedList<>();
rules.add(mock(MutableDataNodeRule.class, RETURNS_DEEP_STUBS));
rules.add(mock(DataSourceContainedRule.class, RETURNS_DEEP_STUBS));
rules.add(mock(TableContainedRule.class, RETURNS_DEEP_STUBS));
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(rules);
- ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db", mock(DatabaseType.class), resource, ruleMetaData, Collections.emptyMap());
+ ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db", mock(DatabaseType.class), resourceMetaData, ruleMetaData, Collections.emptyMap());
database.reloadRules(MutableDataNodeRule.class);
assertThat(database.getRuleMetaData().getRules().size(), is(3));
}
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabasesFactoryTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabasesFactoryTest.java
index 5a02817ac60..a751fda53a4 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabasesFactoryTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabasesFactoryTest.java
@@ -46,7 +46,7 @@ public final class ShardingSphereDatabasesFactoryTest {
ShardingSphereDatabase actual = ShardingSphereDatabasesFactory.create("foo_db", databaseConfig, new ConfigurationProperties(new Properties()), mock(InstanceContext.class));
assertThat(actual.getName(), is("foo_db"));
assertThat(actual.getRuleMetaData().getRules().iterator().next(), instanceOf(FixtureDatabaseRule.class));
- assertTrue(actual.getResource().getDataSources().isEmpty());
+ assertTrue(actual.getResourceMetaData().getDataSources().isEmpty());
}
@Test
@@ -57,7 +57,7 @@ public final class ShardingSphereDatabasesFactoryTest {
Collection<ShardingSphereRule> rules = actual.get("foo_db").getRuleMetaData().getRules();
assertThat(rules.size(), is(1));
assertThat(rules.iterator().next(), instanceOf(FixtureDatabaseRule.class));
- assertTrue(actual.get("foo_db").getResource().getDataSources().isEmpty());
+ assertTrue(actual.get("foo_db").getResourceMetaData().getDataSources().isEmpty());
}
@Test
@@ -68,6 +68,6 @@ public final class ShardingSphereDatabasesFactoryTest {
Collection<ShardingSphereRule> rules = actual.get("foo_db").getRuleMetaData().getRules();
assertThat(rules.size(), is(1));
assertThat(rules.iterator().next(), instanceOf(FixtureDatabaseRule.class));
- assertTrue(actual.get("foo_db").getResource().getDataSources().isEmpty());
+ assertTrue(actual.get("foo_db").getResourceMetaData().getDataSources().isEmpty());
}
}
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResourceTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResourceTest.java
index fc7157bcfb3..6043d033618 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResourceTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResourceTest.java
@@ -30,7 +30,7 @@ public final class ShardingSphereResourceTest {
@Test
public void assertClose() throws InterruptedException {
MockedDataSource dataSource = new MockedDataSource();
- new ShardingSphereResource("sharding_db", Collections.singletonMap("foo_ds", dataSource)).close(dataSource);
+ new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("foo_ds", dataSource)).close(dataSource);
while (!dataSource.isClosed()) {
Thread.sleep(10L);
}
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/util/IndexMetaDataUtilTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/util/IndexMetaDataUtilTest.java
index bde0f09542f..14339fe9fec 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/util/IndexMetaDataUtilTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/util/IndexMetaDataUtilTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedTable;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereIndex;
@@ -95,6 +95,6 @@ public final class IndexMetaDataUtilTest {
Map<String, ShardingSphereTable> tables = Collections.singletonMap(TABLE_NAME, table);
Map<String, ShardingSphereSchema> schemas = new LinkedHashMap<>(1, 1);
schemas.put(DefaultDatabase.LOGIC_NAME, new ShardingSphereSchema(tables, Collections.emptyMap()));
- return new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResource.class), mock(ShardingSphereRuleMetaData.class), schemas);
+ return new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class), mock(ShardingSphereRuleMetaData.class), schemas);
}
}
diff --git a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/AlterTableStatementSchemaRefresher.java b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/AlterTableStatementSchemaRefresher.java
index 5f29b0fcf8a..372dc5f7ca9 100644
--- a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/AlterTableStatementSchemaRefresher.java
+++ b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/AlterTableStatementSchemaRefresher.java
@@ -70,7 +70,7 @@ public final class AlterTableStatementSchemaRefresher implements MetaDataRefresh
database.getRuleMetaData().findRules(MutableDataNodeRule.class).forEach(each -> each.put(logicDataSourceNames.iterator().next(), schemaName, tableName));
}
GenericSchemaBuilderMaterials materials = new GenericSchemaBuilderMaterials(database.getProtocolType(),
- database.getResource().getDatabaseType(), database.getResource().getDataSources(), database.getRuleMetaData().getRules(), props, schemaName);
+ database.getResourceMetaData().getDatabaseType(), database.getResourceMetaData().getDataSources(), database.getRuleMetaData().getRules(), props, schemaName);
Map<String, ShardingSphereSchema> schemaMap = GenericSchemaBuilder.build(Collections.singletonList(tableName), materials);
Optional<ShardingSphereTable> actualTableMetaData = Optional.ofNullable(schemaMap.get(schemaName)).map(optional -> optional.getTable(tableName));
actualTableMetaData.ifPresent(optional -> database.getSchema(schemaName).putTable(tableName, optional));
diff --git a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/AlterViewStatementSchemaRefresher.java b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/AlterViewStatementSchemaRefresher.java
index 6cde19e3f44..ac686dafe31 100644
--- a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/AlterViewStatementSchemaRefresher.java
+++ b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/AlterViewStatementSchemaRefresher.java
@@ -81,7 +81,7 @@ public final class AlterViewStatementSchemaRefresher implements MetaDataRefreshe
database.getRuleMetaData().findRules(MutableDataNodeRule.class).forEach(each -> each.put(logicDataSourceNames.iterator().next(), schemaName, viewName));
}
GenericSchemaBuilderMaterials materials = new GenericSchemaBuilderMaterials(database.getProtocolType(),
- database.getResource().getDatabaseType(), database.getResource().getDataSources(), database.getRuleMetaData().getRules(), props, schemaName);
+ database.getResourceMetaData().getDatabaseType(), database.getResourceMetaData().getDataSources(), database.getRuleMetaData().getRules(), props, schemaName);
Map<String, ShardingSphereSchema> schemaMap = GenericSchemaBuilder.build(Collections.singletonList(viewName), materials);
Optional<ShardingSphereTable> actualViewMetaData = Optional.ofNullable(schemaMap.get(schemaName)).map(optional -> optional.getTable(viewName));
actualViewMetaData.ifPresent(optional -> database.getSchema(schemaName).putTable(viewName, optional));
diff --git a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/CreateTableStatementSchemaRefresher.java b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/CreateTableStatementSchemaRefresher.java
index 0f9d9d3377c..05b285f2f54 100644
--- a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/CreateTableStatementSchemaRefresher.java
+++ b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/CreateTableStatementSchemaRefresher.java
@@ -49,7 +49,7 @@ public final class CreateTableStatementSchemaRefresher implements MetaDataRefres
database.getRuleMetaData().findRules(MutableDataNodeRule.class).forEach(each -> each.put(logicDataSourceNames.iterator().next(), schemaName, tableName));
}
GenericSchemaBuilderMaterials materials = new GenericSchemaBuilderMaterials(database.getProtocolType(),
- database.getResource().getDatabaseType(), database.getResource().getDataSources(), database.getRuleMetaData().getRules(), props, schemaName);
+ database.getResourceMetaData().getDatabaseType(), database.getResourceMetaData().getDataSources(), database.getRuleMetaData().getRules(), props, schemaName);
Map<String, ShardingSphereSchema> schemaMap = GenericSchemaBuilder.build(Collections.singletonList(tableName), materials);
Optional<ShardingSphereTable> actualTableMetaData = Optional.ofNullable(schemaMap.get(schemaName)).map(optional -> optional.getTable(tableName));
if (actualTableMetaData.isPresent()) {
diff --git a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/CreateViewStatementSchemaRefresher.java b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/CreateViewStatementSchemaRefresher.java
index d1e1b005ed5..b575308c52f 100644
--- a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/CreateViewStatementSchemaRefresher.java
+++ b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/CreateViewStatementSchemaRefresher.java
@@ -50,7 +50,7 @@ public final class CreateViewStatementSchemaRefresher implements MetaDataRefresh
database.getRuleMetaData().findRules(MutableDataNodeRule.class).forEach(each -> each.put(logicDataSourceNames.iterator().next(), schemaName, viewName));
}
GenericSchemaBuilderMaterials materials = new GenericSchemaBuilderMaterials(database.getProtocolType(),
- database.getResource().getDatabaseType(), database.getResource().getDataSources(), database.getRuleMetaData().getRules(), props, schemaName);
+ database.getResourceMetaData().getDatabaseType(), database.getResourceMetaData().getDataSources(), database.getRuleMetaData().getRules(), props, schemaName);
Map<String, ShardingSphereSchema> schemaMap = GenericSchemaBuilder.build(Collections.singletonList(viewName), materials);
Optional<ShardingSphereTable> actualTableMetaData = Optional.ofNullable(schemaMap.get(schemaName)).map(optional -> optional.getTable(viewName));
if (actualTableMetaData.isPresent()) {
diff --git a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/DropIndexStatementSchemaRefresher.java b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/DropIndexStatementSchemaRefresher.java
index 4c7589b05ec..bcf9e2239dc 100644
--- a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/DropIndexStatementSchemaRefresher.java
+++ b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/DropIndexStatementSchemaRefresher.java
@@ -62,7 +62,7 @@ public final class DropIndexStatementSchemaRefresher implements MetaDataRefreshe
if (simpleTableSegment.isPresent()) {
return Optional.of(simpleTableSegment.get().getTableName().getIdentifier().getValue());
}
- Collection<QualifiedTable> tableNames = IndexMetaDataUtil.getTableNames(database, database.getResource().getDatabaseType(), indexSegments);
+ Collection<QualifiedTable> tableNames = IndexMetaDataUtil.getTableNames(database, database.getResourceMetaData().getDatabaseType(), indexSegments);
return tableNames.isEmpty() ? Optional.empty() : Optional.of(tableNames.iterator().next().getTableName());
}
diff --git a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/RenameTableStatementSchemaRefresher.java b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/RenameTableStatementSchemaRefresher.java
index bb2b669f95b..b7bf836babf 100644
--- a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/RenameTableStatementSchemaRefresher.java
+++ b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/RenameTableStatementSchemaRefresher.java
@@ -68,7 +68,7 @@ public final class RenameTableStatementSchemaRefresher implements MetaDataRefres
database.getRuleMetaData().findRules(MutableDataNodeRule.class).forEach(each -> each.put(logicDataSourceNames.iterator().next(), schemaName, tableName));
}
GenericSchemaBuilderMaterials materials = new GenericSchemaBuilderMaterials(database.getProtocolType(),
- database.getResource().getDatabaseType(), database.getResource().getDataSources(), database.getRuleMetaData().getRules(), props, schemaName);
+ database.getResourceMetaData().getDatabaseType(), database.getResourceMetaData().getDataSources(), database.getRuleMetaData().getRules(), props, schemaName);
Map<String, ShardingSphereSchema> schemaMap = GenericSchemaBuilder.build(Collections.singletonList(tableName), materials);
Optional<ShardingSphereTable> actualTableMetaData = Optional.ofNullable(schemaMap.get(schemaName)).map(optional -> optional.getTable(tableName));
actualTableMetaData.ifPresent(optional -> database.getSchema(schemaName).putTable(tableName, optional));
diff --git a/infra/context/src/test/java/org/apache/shardingsphere/infra/context/kernel/KernelProcessorTest.java b/infra/context/src/test/java/org/apache/shardingsphere/infra/context/kernel/KernelProcessorTest.java
index d87c5182502..a442c1da169 100644
--- a/infra/context/src/test/java/org/apache/shardingsphere/infra/context/kernel/KernelProcessorTest.java
+++ b/infra/context/src/test/java/org/apache/shardingsphere/infra/context/kernel/KernelProcessorTest.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
@@ -52,7 +52,7 @@ public final class KernelProcessorTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(SelectStatement.class));
QueryContext queryContext = new QueryContext(sqlStatementContext, "SELECT * FROM tbl", Collections.emptyList());
ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class),
- mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), new ShardingSphereRuleMetaData(Collections.singleton(mock(SQLTranslatorRule.class))), Collections.emptyMap());
+ mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), new ShardingSphereRuleMetaData(Collections.singleton(mock(SQLTranslatorRule.class))), Collections.emptyMap());
ConfigurationProperties props = new ConfigurationProperties(createProperties());
ExecutionContext actual = new KernelProcessor().generateExecutionContext(queryContext, database, new ShardingSphereRuleMetaData(Collections.singleton(mock(SQLTranslatorRule.class))), props,
mock(ConnectionContext.class));
diff --git a/infra/context/src/test/java/org/apache/shardingsphere/infra/context/refresher/type/RenameTableStatementSchemaRefresherTest.java b/infra/context/src/test/java/org/apache/shardingsphere/infra/context/refresher/type/RenameTableStatementSchemaRefresherTest.java
index 99ef4d4b982..b9c30d0682a 100644
--- a/infra/context/src/test/java/org/apache/shardingsphere/infra/context/refresher/type/RenameTableStatementSchemaRefresherTest.java
+++ b/infra/context/src/test/java/org/apache/shardingsphere/infra/context/refresher/type/RenameTableStatementSchemaRefresherTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.dialect.SQL92DatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.database.schema.event.MetaDataRefreshedEvent;
@@ -76,11 +76,11 @@ public final class RenameTableStatementSchemaRefresherTest {
private ShardingSphereDatabase createDatabaseMetaData() {
return new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, new SQL92DatabaseType(),
- mockShardingSphereResource(), new ShardingSphereRuleMetaData(new LinkedList<>()), Collections.singletonMap("foo_schema", mock(ShardingSphereSchema.class)));
+ mockShardingSphereResourceMetaData(), new ShardingSphereRuleMetaData(new LinkedList<>()), Collections.singletonMap("foo_schema", mock(ShardingSphereSchema.class)));
}
- private ShardingSphereResource mockShardingSphereResource() {
- ShardingSphereResource result = mock(ShardingSphereResource.class);
+ private ShardingSphereResourceMetaData mockShardingSphereResourceMetaData() {
+ ShardingSphereResourceMetaData result = mock(ShardingSphereResourceMetaData.class);
when(result.getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, new MockedDataSource()));
when(result.getDatabaseType()).thenReturn(new SQL92DatabaseType());
return result;
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java
index a96ca90192f..92db31265e2 100644
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java
+++ b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java
@@ -59,7 +59,7 @@ public final class ExecutionContextBuilder {
private static Collection<ExecutionUnit> build(final ShardingSphereDatabase database,
final GenericSQLRewriteResult sqlRewriteResult, final SQLStatementContext<?> sqlStatementContext) {
- Collection<String> instanceDataSourceNames = database.getResource().getAllInstanceDataSourceNames();
+ Collection<String> instanceDataSourceNames = database.getResourceMetaData().getAllInstanceDataSourceNames();
if (instanceDataSourceNames.isEmpty()) {
return Collections.emptyList();
}
diff --git a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilderTest.java b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilderTest.java
index a0d308ace32..fc8a7b1792b 100644
--- a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilderTest.java
+++ b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilderTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
@@ -54,11 +54,11 @@ public final class ExecutionContextBuilderTest {
String sql = "sql";
List<Object> parameters = Collections.singletonList("parameter");
GenericSQLRewriteResult genericSQLRewriteResult = new GenericSQLRewriteResult(new SQLRewriteUnit(sql, parameters));
- ShardingSphereResource resource = mock(ShardingSphereResource.class);
+ ShardingSphereResourceMetaData resourceMetaData = mock(ShardingSphereResourceMetaData.class);
String firstDataSourceName = "firstDataSourceName";
- when(resource.getAllInstanceDataSourceNames()).thenReturn(Arrays.asList(firstDataSourceName, "lastDataSourceName"));
+ when(resourceMetaData.getAllInstanceDataSourceNames()).thenReturn(Arrays.asList(firstDataSourceName, "lastDataSourceName"));
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.emptyList());
- ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), resource, ruleMetaData, buildDatabase());
+ ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), resourceMetaData, ruleMetaData, buildDatabase());
Collection<ExecutionUnit> actual = ExecutionContextBuilder.build(database, genericSQLRewriteResult, mock(SQLStatementContext.class));
Collection<ExecutionUnit> expected = Collections.singletonList(new ExecutionUnit(firstDataSourceName, new SQLUnit(sql, parameters)));
assertThat(actual, is(expected));
@@ -73,9 +73,9 @@ public final class ExecutionContextBuilderTest {
Map<RouteUnit, SQLRewriteUnit> sqlRewriteUnits = new HashMap<>(2, 1);
sqlRewriteUnits.put(routeUnit1, sqlRewriteUnit1);
sqlRewriteUnits.put(routeUnit2, sqlRewriteUnit2);
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", Collections.emptyMap());
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", Collections.emptyMap());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.emptyList());
- ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), resource, ruleMetaData, buildDatabase());
+ ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), resourceMetaData, ruleMetaData, buildDatabase());
Collection<ExecutionUnit> actual = ExecutionContextBuilder.build(database, new RouteSQLRewriteResult(sqlRewriteUnits), mock(SQLStatementContext.class));
ExecutionUnit expectedUnit1 = new ExecutionUnit("actualName1", new SQLUnit("sql1", Collections.singletonList("parameter1")));
ExecutionUnit expectedUnit2 = new ExecutionUnit("actualName2", new SQLUnit("sql2", Collections.singletonList("parameter2")));
@@ -91,9 +91,9 @@ public final class ExecutionContextBuilderTest {
SQLRewriteUnit sqlRewriteUnit2 = new SQLRewriteUnit("sql2", Collections.singletonList("parameter2"));
Map<RouteUnit, SQLRewriteUnit> sqlRewriteUnits = new HashMap<>(2, 1);
sqlRewriteUnits.put(routeUnit2, sqlRewriteUnit2);
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", Collections.emptyMap());
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", Collections.emptyMap());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.emptyList());
- ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), resource, ruleMetaData, buildDatabaseWithoutPrimaryKey());
+ ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), resourceMetaData, ruleMetaData, buildDatabaseWithoutPrimaryKey());
Collection<ExecutionUnit> actual = ExecutionContextBuilder.build(database, new RouteSQLRewriteResult(sqlRewriteUnits), mock(SQLStatementContext.class));
ExecutionUnit expectedUnit2 = new ExecutionUnit("actualName2", new SQLUnit("sql2", Collections.singletonList("parameter2")));
Collection<ExecutionUnit> expected = new LinkedHashSet<>(1, 1);
diff --git a/infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/MergeEngine.java b/infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/MergeEngine.java
index 96a63a52852..bfe6898661d 100644
--- a/infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/MergeEngine.java
+++ b/infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/MergeEngine.java
@@ -78,7 +78,7 @@ public final class MergeEngine {
for (Entry<ShardingSphereRule, ResultProcessEngine> entry : engines.entrySet()) {
if (entry.getValue() instanceof ResultMergerEngine) {
ResultMerger resultMerger = ((ResultMergerEngine) entry.getValue()).newInstance(
- database.getName(), database.getResource().getDatabaseType(), entry.getKey(), props, sqlStatementContext);
+ database.getName(), database.getResourceMetaData().getDatabaseType(), entry.getKey(), props, sqlStatementContext);
return Optional.of(resultMerger.merge(queryResults, sqlStatementContext, database, connectionContext));
}
}
diff --git a/infra/rewrite/src/main/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntry.java b/infra/rewrite/src/main/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntry.java
index 2624bfc7a9d..617a8a7a355 100644
--- a/infra/rewrite/src/main/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntry.java
+++ b/infra/rewrite/src/main/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntry.java
@@ -73,7 +73,7 @@ public final class SQLRewriteEntry {
SQLRewriteContext sqlRewriteContext = createSQLRewriteContext(sql, parameters, sqlStatementContext, routeContext, connectionContext);
SQLTranslatorRule rule = globalRuleMetaData.getSingleRule(SQLTranslatorRule.class);
DatabaseType protocolType = database.getProtocolType();
- DatabaseType storageType = database.getResource().getDatabaseType();
+ DatabaseType storageType = database.getResourceMetaData().getDatabaseType();
return routeContext.getRouteUnits().isEmpty()
? new GenericSQLRewriteEngine(rule, protocolType, storageType).rewrite(sqlRewriteContext)
: new RouteSQLRewriteEngine(rule, protocolType, storageType).rewrite(sqlRewriteContext, routeContext);
diff --git a/infra/rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java b/infra/rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java
index 48a034ce158..8c62a5c3719 100644
--- a/infra/rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java
+++ b/infra/rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.context.ConnectionContext;
import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.rewrite.engine.result.GenericSQLRewriteResult;
@@ -76,8 +76,8 @@ public final class SQLRewriteEntryTest {
assertThat(sqlRewriteResult.getSqlRewriteUnits().size(), is(2));
}
- private ShardingSphereResource mockResource() {
- ShardingSphereResource result = mock(ShardingSphereResource.class);
+ private ShardingSphereResourceMetaData mockResource() {
+ ShardingSphereResourceMetaData result = mock(ShardingSphereResourceMetaData.class);
when(result.getDatabaseType()).thenReturn(DatabaseTypeFactory.getInstance("H2"));
return result;
}
diff --git a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/impl/AllSQLRouteExecutor.java b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/impl/AllSQLRouteExecutor.java
index 3741a10ecb0..f4c580ad481 100644
--- a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/impl/AllSQLRouteExecutor.java
+++ b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/impl/AllSQLRouteExecutor.java
@@ -35,7 +35,7 @@ public final class AllSQLRouteExecutor implements SQLRouteExecutor {
@Override
public RouteContext route(final ConnectionContext connectionContext, final QueryContext queryContext, final ShardingSphereDatabase database) {
RouteContext result = new RouteContext();
- for (String each : database.getResource().getDataSources().keySet()) {
+ for (String each : database.getResourceMetaData().getDataSources().keySet()) {
result.getRouteUnits().add(new RouteUnit(new RouteMapper(each, each), Collections.emptyList()));
}
return result;
diff --git a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/impl/PartialSQLRouteExecutor.java b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/impl/PartialSQLRouteExecutor.java
index b9d784bfba6..8af38d84797 100644
--- a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/impl/PartialSQLRouteExecutor.java
+++ b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/impl/PartialSQLRouteExecutor.java
@@ -60,8 +60,8 @@ public final class PartialSQLRouteExecutor implements SQLRouteExecutor {
entry.getValue().decorateRouteContext(result, queryContext, database, entry.getKey(), props, connectionContext);
}
}
- if (result.getRouteUnits().isEmpty() && 1 == database.getResource().getDataSources().size()) {
- String singleDataSourceName = database.getResource().getDataSources().keySet().iterator().next();
+ if (result.getRouteUnits().isEmpty() && 1 == database.getResourceMetaData().getDataSources().size()) {
+ String singleDataSourceName = database.getResourceMetaData().getDataSources().keySet().iterator().next();
result.getRouteUnits().add(new RouteUnit(new RouteMapper(singleDataSourceName, singleDataSourceName), Collections.emptyList()));
}
return result;
diff --git a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/engine/AllSQLRouteExecutorTest.java b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/engine/AllSQLRouteExecutorTest.java
index ebf28a00604..53f24016d7b 100644
--- a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/engine/AllSQLRouteExecutorTest.java
+++ b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/engine/AllSQLRouteExecutorTest.java
@@ -41,7 +41,7 @@ public final class AllSQLRouteExecutorTest {
public void assertRouteSuccess() {
String name = "test";
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDataSources().keySet()).thenReturn(Stream.of(name).collect(Collectors.toSet()));
+ when(database.getResourceMetaData().getDataSources().keySet()).thenReturn(Stream.of(name).collect(Collectors.toSet()));
AllSQLRouteExecutor allSQLRouteExecutor = new AllSQLRouteExecutor();
RouteContext actual = allSQLRouteExecutor.route(new ConnectionContext(), mock(QueryContext.class), database);
assertThat(actual.getRouteUnits().size(), is(1));
diff --git a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/engine/SQLRouteEngineTest.java b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/engine/SQLRouteEngineTest.java
index 734716242b1..8a5c54286b6 100644
--- a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/engine/SQLRouteEngineTest.java
+++ b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/engine/SQLRouteEngineTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.ConnectionContext;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteUnit;
@@ -47,7 +47,7 @@ public final class SQLRouteEngineTest {
QueryContext queryContext = new QueryContext(mock(CommonSQLStatementContext.class), "SELECT 1", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(new RouteRuleFixture()));
ShardingSphereDatabase database = new ShardingSphereDatabase("logic_schema",
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
SQLRouteEngine sqlRouteEngine = new SQLRouteEngine(Collections.singleton(new RouteRuleFixture()), new ConfigurationProperties(new Properties()));
RouteContext actual = sqlRouteEngine.route(new ConnectionContext(), queryContext, database);
assertThat(actual.getRouteUnits().size(), is(1));
@@ -62,7 +62,7 @@ public final class SQLRouteEngineTest {
QueryContext queryContext = new QueryContext(mock(CommonSQLStatementContext.class), "SELECT 1", Collections.emptyList());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(new RouteRuleFixture()));
ShardingSphereDatabase database = new ShardingSphereDatabase("logic_schema",
- mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
+ mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS), ruleMetaData, Collections.emptyMap());
new SQLRouteEngine(Collections.singleton(new RouteFailureRuleFixture()), new ConfigurationProperties(new Properties())).route(new ConnectionContext(), queryContext, database);
}
}
diff --git a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java
index a0266395368..c37fad4150a 100644
--- a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java
+++ b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java
@@ -53,7 +53,7 @@ public final class DriverExecutor implements AutoCloseable {
JDBCExecutor jdbcExecutor = new JDBCExecutor(executorEngine, connection.isHoldTransaction());
regularExecutor = new DriverJDBCExecutor(connection.getDatabaseName(), connection.getContextManager(), jdbcExecutor);
rawExecutor = new RawExecutor(executorEngine, connection.isHoldTransaction(), metaDataContexts.getMetaData().getProps(), eventBusContext);
- DatabaseType databaseType = metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType();
+ DatabaseType databaseType = metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType();
String schemaName = DatabaseTypeEngine.getDefaultSchemaName(databaseType, connection.getDatabaseName());
SQLFederationRule sqlFederationRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLFederationRule.class);
federationExecutor = sqlFederationRule.getSQLFederationExecutor(connection.getDatabaseName(), schemaName, metaDataContexts.getMetaData(), jdbcExecutor, eventBusContext);
diff --git a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutor.java b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutor.java
index e687cb6de93..2d2b2a78206 100644
--- a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutor.java
+++ b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutor.java
@@ -138,7 +138,7 @@ public final class BatchPreparedStatementExecutor {
public int[] executeBatch(final SQLStatementContext<?> sqlStatementContext) throws SQLException {
boolean isExceptionThrown = SQLExecutorExceptionHandler.isExceptionThrown();
JDBCExecutorCallback<int[]> callback = new JDBCExecutorCallback<int[]>(
- metaDataContexts.getMetaData().getDatabase(databaseName).getResource().getDatabaseType(), sqlStatementContext.getSqlStatement(), isExceptionThrown, eventBusContext) {
+ metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData().getDatabaseType(), sqlStatementContext.getSqlStatement(), isExceptionThrown, eventBusContext) {
@Override
protected int[] executeSQL(final String sql, final Statement statement, final ConnectionMode connectionMode) throws SQLException {
diff --git a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractStatementAdapter.java b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractStatementAdapter.java
index 5f479f0d88d..0e909e368fe 100644
--- a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractStatementAdapter.java
+++ b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractStatementAdapter.java
@@ -195,7 +195,7 @@ public abstract class AbstractStatementAdapter extends AbstractUnsupportedOperat
protected final void handleExceptionInTransaction(final ShardingSphereConnection connection, final MetaDataContexts metaDataContexts) {
if (connection.getConnectionManager().getConnectionTransaction().isInTransaction()) {
- DatabaseType databaseType = metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType();
+ DatabaseType databaseType = metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType();
if (databaseType instanceof PostgreSQLDatabaseType || databaseType instanceof OpenGaussDatabaseType) {
connection.getConnectionManager().getConnectionTransaction().setRollbackOnly(true);
}
diff --git a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaData.java b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaData.java
index cfab4708ad8..f305ba87876 100644
--- a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaData.java
+++ b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaData.java
@@ -223,13 +223,13 @@ public final class ShardingSphereDatabaseMetaData extends AdaptedDatabaseMetaDat
private String getActualCatalog(final String catalog) {
DataSourceMetaData metaData = connection.getContextManager()
- .getMetaDataContexts().getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDataSourceMetaData(getDataSourceName());
+ .getMetaDataContexts().getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDataSourceMetaData(getDataSourceName());
return null != catalog && catalog.contains(DefaultDatabase.LOGIC_NAME) ? metaData.getCatalog() : catalog;
}
private String getActualSchema(final String schema) {
DataSourceMetaData metaData = connection.getContextManager()
- .getMetaDataContexts().getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDataSourceMetaData(getDataSourceName());
+ .getMetaDataContexts().getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDataSourceMetaData(getDataSourceName());
return null != schema && schema.contains(DefaultDatabase.LOGIC_NAME) ? metaData.getSchema() : schema;
}
diff --git a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
index fd8dc7e4e31..5a2442c41a0 100644
--- a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
+++ b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
@@ -191,7 +191,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
parameterSets = new ArrayList<>();
SQLParserRule sqlParserRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLParserRule.class);
ShardingSphereSQLParserEngine sqlParserEngine = sqlParserRule.getSQLParserEngine(
- DatabaseTypeEngine.getTrunkDatabaseTypeName(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType()));
+ DatabaseTypeEngine.getTrunkDatabaseTypeName(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType()));
sqlStatement = sqlParserEngine.parse(sql, true);
sqlStatementContext = SQLStatementContextFactory.newInstance(metaDataContexts.getMetaData().getDatabases(), sqlStatement, connection.getDatabaseName());
parameterMetaData = new ShardingSphereParameterMetaData(sqlStatement);
@@ -239,7 +239,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
} catch (final Exception ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
} finally {
clearBatch();
}
@@ -294,13 +294,13 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext = createExecutionGroupContext();
cacheStatements(executionGroupContext.getInputGroups());
return executor.getRegularExecutor().executeQuery(executionGroupContext, executionContext.getQueryContext(),
- new PreparedStatementExecuteQueryCallback(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType(),
+ new PreparedStatementExecuteQueryCallback(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType(),
sqlStatement, SQLExecutorExceptionHandler.isExceptionThrown(), eventBusContext));
}
private ResultSet executeFederationQuery(final QueryContext queryContext) throws SQLException {
PreparedStatementExecuteQueryCallback callback = new PreparedStatementExecuteQueryCallback(
- metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType(), sqlStatement, SQLExecutorExceptionHandler.isExceptionThrown(),
+ metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType(), sqlStatement, SQLExecutorExceptionHandler.isExceptionThrown(),
eventBusContext);
SQLFederationExecutorContext context = new SQLFederationExecutorContext(false, queryContext, metaDataContexts.getMetaData().getDatabases());
return executor.getFederationExecutor().executeQuery(createDriverExecutionPrepareEngine(), callback, context);
@@ -310,7 +310,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
int maxConnectionsSizePerQuery = metaDataContexts.getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
return new DriverExecutionPrepareEngine<>(JDBCDriverType.PREPARED_STATEMENT, maxConnectionsSizePerQuery, connection.getConnectionManager(), statementManager,
statementOption, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getRuleMetaData().getRules(),
- metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType());
+ metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType());
}
@Override
@@ -341,7 +341,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
} catch (final Exception ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
} finally {
clearBatch();
}
@@ -357,7 +357,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
private JDBCExecutorCallback<Integer> createExecuteUpdateCallback() {
boolean isExceptionThrown = SQLExecutorExceptionHandler.isExceptionThrown();
- return new JDBCExecutorCallback<Integer>(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType(), sqlStatement, isExceptionThrown,
+ return new JDBCExecutorCallback<Integer>(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType(), sqlStatement, isExceptionThrown,
eventBusContext) {
@Override
@@ -406,7 +406,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
} catch (final Exception ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
} finally {
clearBatch();
}
@@ -434,7 +434,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
private JDBCExecutorCallback<Boolean> createExecuteCallback() {
boolean isExceptionThrown = SQLExecutorExceptionHandler.isExceptionThrown();
- return new JDBCExecutorCallback<Boolean>(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType(), sqlStatement, isExceptionThrown,
+ return new JDBCExecutorCallback<Boolean>(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType(), sqlStatement, isExceptionThrown,
eventBusContext) {
@Override
@@ -594,7 +594,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
} catch (final Exception ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
} finally {
clearBatch();
}
@@ -605,7 +605,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
.<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY), connection.getConnectionManager(), statementManager, statementOption,
metaDataContexts.getMetaData()
.getDatabase(connection.getDatabaseName()).getRuleMetaData().getRules(),
- metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType());
+ metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType());
List<ExecutionUnit> executionUnits = new ArrayList<>(batchPreparedStatementExecutor.getBatchExecutionUnits().size());
for (BatchExecutionUnit each : batchPreparedStatementExecutor.getBatchExecutionUnits()) {
ExecutionUnit executionUnit = each.getExecutionUnit();
diff --git a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
index 0baef6af82a..dac8e4be9c9 100644
--- a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
+++ b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
@@ -176,7 +176,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
} catch (final Exception ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
} finally {
currentResultSet = null;
}
@@ -214,13 +214,13 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
}
ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext = createExecutionContext();
cacheStatements(executionGroupContext.getInputGroups());
- StatementExecuteQueryCallback callback = new StatementExecuteQueryCallback(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType(),
+ StatementExecuteQueryCallback callback = new StatementExecuteQueryCallback(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType(),
executionContext.getSqlStatementContext().getSqlStatement(), SQLExecutorExceptionHandler.isExceptionThrown(), eventBusContext);
return executor.getRegularExecutor().executeQuery(executionGroupContext, executionContext.getQueryContext(), callback);
}
private ResultSet executeFederationQuery(final QueryContext queryContext) throws SQLException {
- StatementExecuteQueryCallback callback = new StatementExecuteQueryCallback(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType(),
+ StatementExecuteQueryCallback callback = new StatementExecuteQueryCallback(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType(),
queryContext.getSqlStatementContext().getSqlStatement(), SQLExecutorExceptionHandler.isExceptionThrown(), eventBusContext);
SQLFederationExecutorContext context = new SQLFederationExecutorContext(false, queryContext, metaDataContexts.getMetaData().getDatabases());
return executor.getFederationExecutor().executeQuery(createDriverExecutionPrepareEngine(), callback, context);
@@ -230,7 +230,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
int maxConnectionsSizePerQuery = metaDataContexts.getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
return new DriverExecutionPrepareEngine<>(JDBCDriverType.STATEMENT, maxConnectionsSizePerQuery, connection.getConnectionManager(), statementManager, statementOption,
metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getRuleMetaData().getRules(),
- metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType());
+ metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType());
}
@Override
@@ -255,7 +255,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
} catch (final Exception ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
} finally {
currentResultSet = null;
}
@@ -286,7 +286,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
} catch (final Exception ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
} finally {
currentResultSet = null;
}
@@ -315,7 +315,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
} catch (final Exception ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
} finally {
currentResultSet = null;
}
@@ -344,7 +344,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
} catch (final Exception ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
} finally {
currentResultSet = null;
}
@@ -354,7 +354,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
final SQLStatementContext<?> sqlStatementContext, final Collection<RouteUnit> routeUnits) throws SQLException {
boolean isExceptionThrown = SQLExecutorExceptionHandler.isExceptionThrown();
JDBCExecutorCallback<Integer> callback = new JDBCExecutorCallback<Integer>(
- metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType(), sqlStatementContext.getSqlStatement(), isExceptionThrown,
+ metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType(), sqlStatementContext.getSqlStatement(), isExceptionThrown,
eventBusContext) {
@Override
@@ -386,7 +386,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
} catch (final SQLException ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
}
}
@@ -401,7 +401,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
} catch (final SQLException ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
}
}
@@ -414,7 +414,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
} catch (final SQLException ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
}
}
@@ -427,7 +427,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
} catch (final SQLException ex) {
// CHECKSTYLE:ON
handleExceptionInTransaction(connection, metaDataContexts);
- throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType().getType());
+ throw SQLExceptionTransformEngine.toSQLException(ex, metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType().getType());
}
}
@@ -435,7 +435,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
final SQLStatement sqlStatement, final Collection<RouteUnit> routeUnits) throws SQLException {
boolean isExceptionThrown = SQLExecutorExceptionHandler.isExceptionThrown();
JDBCExecutorCallback<Boolean> jdbcExecutorCallback = new JDBCExecutorCallback<Boolean>(
- metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType(), sqlStatement, isExceptionThrown, eventBusContext) {
+ metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType(), sqlStatement, isExceptionThrown, eventBusContext) {
@Override
protected Boolean executeSQL(final String sql, final Statement statement, final ConnectionMode connectionMode) throws SQLException {
@@ -508,7 +508,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
private QueryContext createQueryContext(final String sql) {
SQLParserRule sqlParserRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLParserRule.class);
SQLStatement sqlStatement = sqlParserRule.getSQLParserEngine(
- DatabaseTypeEngine.getTrunkDatabaseTypeName(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType())).parse(sql, false);
+ DatabaseTypeEngine.getTrunkDatabaseTypeName(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType())).parse(sql, false);
SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(metaDataContexts.getMetaData().getDatabases(), sqlStatement, connection.getDatabaseName());
return new QueryContext(sqlStatementContext, sql, Collections.emptyList());
}
diff --git a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/executor/AbstractBaseExecutorTest.java b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/executor/AbstractBaseExecutorTest.java
index 5e0c23eb7b8..ef30090c02a 100644
--- a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/executor/AbstractBaseExecutorTest.java
+++ b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/executor/AbstractBaseExecutorTest.java
@@ -90,7 +90,7 @@ public abstract class AbstractBaseExecutorTest {
TransactionRule transactionRule = mockTransactionRule();
when(globalRuleMetaData.getSingleRule(TransactionRule.class)).thenReturn(transactionRule);
when(globalRuleMetaData.getSingleRule(TrafficRule.class)).thenReturn(new TrafficRule(new DefaultTrafficRuleConfigurationBuilder().build()));
- when(result.getMetaData().getDatabase(DefaultDatabase.LOGIC_NAME).getResource().getDatabaseType()).thenReturn(DatabaseTypeFactory.getInstance("H2"));
+ when(result.getMetaData().getDatabase(DefaultDatabase.LOGIC_NAME).getResourceMetaData().getDatabaseType()).thenReturn(DatabaseTypeFactory.getInstance("H2"));
ShardingRule shardingRule = mockShardingRule();
when(result.getMetaData().getDatabase(DefaultDatabase.LOGIC_NAME).getRuleMetaData().getRules()).thenReturn(Collections.singleton(shardingRule));
return result;
diff --git a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/PreparedStatementAdapterTest.java b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/PreparedStatementAdapterTest.java
index 490a037feca..80a3d020081 100644
--- a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/PreparedStatementAdapterTest.java
+++ b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/PreparedStatementAdapterTest.java
@@ -71,7 +71,7 @@ public final class PreparedStatementAdapterTest {
ShardingSphereRuleMetaData globalRuleMetaData = mock(ShardingSphereRuleMetaData.class);
when(connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(globalRuleMetaData);
when(globalRuleMetaData.getSingleRule(SQLParserRule.class)).thenReturn(new SQLParserRule(new DefaultSQLParserRuleConfigurationBuilder().build()));
- when(connection.getContextManager().getMetaDataContexts().getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(connection.getContextManager().getMetaDataContexts().getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(SQLParserRule.class)).thenReturn(sqlParserRule);
when(connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(TrafficRule.class)).thenReturn(trafficRule);
when(connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(SQLFederationRule.class)).thenReturn(sqlFederationRule);
diff --git a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationPreparedStatementTest.java b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationPreparedStatementTest.java
index 217149af14a..570d572aeb4 100644
--- a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationPreparedStatementTest.java
+++ b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationPreparedStatementTest.java
@@ -56,7 +56,7 @@ public final class UnsupportedOperationPreparedStatementTest {
when(connection.getDatabaseName()).thenReturn(DefaultDatabase.LOGIC_NAME);
ShardingSphereRuleMetaData globalRuleMetaData = mock(ShardingSphereRuleMetaData.class);
when(connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(globalRuleMetaData);
- when(connection.getContextManager().getMetaDataContexts().getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(connection.getContextManager().getMetaDataContexts().getMetaData().getDatabase(connection.getDatabaseName()).getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(globalRuleMetaData.getSingleRule(SQLParserRule.class)).thenReturn(sqlParserRule);
when(globalRuleMetaData.getSingleRule(TrafficRule.class)).thenReturn(trafficRule);
when(globalRuleMetaData.getSingleRule(SQLFederationRule.class)).thenReturn(sqlFederationRule);
diff --git a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
index 5281753f708..8d7571cbe45 100644
--- a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
+++ b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
@@ -71,7 +71,7 @@ public final class DriverStateContextTest {
private Map<String, ShardingSphereDatabase> mockDatabases() {
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>();
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, Answers.RETURNS_DEEP_STUBS);
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
result.put(DefaultDatabase.LOGIC_NAME, database);
return result;
}
diff --git a/jdbc/spring/core/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootStarterTest.java b/jdbc/spring/core/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootStarterTest.java
index a5a035b0638..b223c953937 100644
--- a/jdbc/spring/core/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootStarterTest.java
+++ b/jdbc/spring/core/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootStarterTest.java
@@ -73,7 +73,7 @@ public class SpringBootStarterTest {
@Test
public void assertDataSources() {
- Map<String, DataSource> dataSources = getContextManager(dataSource).getMetaDataContexts().getMetaData().getDatabase("foo_db").getResource().getDataSources();
+ Map<String, DataSource> dataSources = getContextManager(dataSource).getMetaDataContexts().getMetaData().getDatabase("foo_db").getResourceMetaData().getDataSources();
assertThat(dataSources.size(), is(3));
assertTrue(dataSources.containsKey("read_ds_0"));
assertTrue(dataSources.containsKey("read_ds_1"));
diff --git a/jdbc/spring/core/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/jndi/SpringBootJNDIDataSourceTest.java b/jdbc/spring/core/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/jndi/SpringBootJNDIDataSourceTest.java
index e063fd40126..b591d764e50 100644
--- a/jdbc/spring/core/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/jndi/SpringBootJNDIDataSourceTest.java
+++ b/jdbc/spring/core/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/jndi/SpringBootJNDIDataSourceTest.java
@@ -59,7 +59,7 @@ public class SpringBootJNDIDataSourceTest {
@Test
public void assertDataSources() {
- Map<String, DataSource> dataSources = getContextManager(dataSource).getMetaDataContexts().getMetaData().getDatabase("foo_db").getResource().getDataSources();
+ Map<String, DataSource> dataSources = getContextManager(dataSource).getMetaDataContexts().getMetaData().getDatabase("foo_db").getResourceMetaData().getDataSources();
assertThat(dataSources.size(), is(3));
assertTrue(dataSources.containsKey("read_ds_0"));
assertTrue(dataSources.containsKey("read_ds_1"));
diff --git a/jdbc/spring/core/shardingsphere-jdbc-core-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/AbstractSpringNamespaceTest.java b/jdbc/spring/core/shardingsphere-jdbc-core-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/AbstractSpringNamespaceTest.java
index fdd0dffd31a..3a363923d24 100644
--- a/jdbc/spring/core/shardingsphere-jdbc-core-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/AbstractSpringNamespaceTest.java
+++ b/jdbc/spring/core/shardingsphere-jdbc-core-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/AbstractSpringNamespaceTest.java
@@ -52,7 +52,7 @@ public abstract class AbstractSpringNamespaceTest extends AbstractJUnit4SpringCo
@Test
public void assertShardingSphereDataSource() {
- assertDataSources(getContextManager(dataSource).getMetaDataContexts().getMetaData().getDatabase(DefaultDatabase.LOGIC_NAME).getResource().getDataSources());
+ assertDataSources(getContextManager(dataSource).getMetaDataContexts().getMetaData().getDatabase(DefaultDatabase.LOGIC_NAME).getResourceMetaData().getDataSources());
assertDatabaseRules(getContextManager(dataSource).getMetaDataContexts().getMetaData().getDatabase(DefaultDatabase.LOGIC_NAME).getRuleMetaData().getRules());
assertGlobalRules(getContextManager(dataSource).getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getRules());
}
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/execute/ShardingSphereDataScheduleCollector.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/execute/ShardingSphereDataScheduleCollector.java
index 60bc4e33e87..d429b567449 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/execute/ShardingSphereDataScheduleCollector.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/execute/ShardingSphereDataScheduleCollector.java
@@ -99,7 +99,7 @@ public final class ShardingSphereDataScheduleCollector {
private void collectForEachDatabase(final ShardingSphereData shardingSphereData, final ShardingSphereTable table, final ShardingSphereDatabase database, final DatabaseType databaseType) {
String databaseName = database.getName();
- Map<String, DataSource> dataSources = database.getResource().getDataSources();
+ Map<String, DataSource> dataSources = database.getResourceMetaData().getDataSources();
ShardingSphereDataCollectorFactory.findInstance(table.getName()).ifPresent(shardingSphereDataCollector -> {
try {
shardingSphereDataCollector.collect(shardingSphereData, databaseName, database.getRuleMetaData(), dataSources, databaseType);
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
index 6302b2673f4..8a491f33146 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
@@ -382,7 +382,7 @@ public final class MigrationJobAPIImpl extends AbstractInventoryIncrementalJobAP
result.setSourceTableName(parameter.getSourceTableName());
Map<String, Map<String, Object>> targetDataSourceProperties = new HashMap<>();
ShardingSphereDatabase targetDatabase = PipelineContext.getContextManager().getMetaDataContexts().getMetaData().getDatabase(parameter.getTargetDatabaseName());
- for (Entry<String, DataSource> entry : targetDatabase.getResource().getDataSources().entrySet()) {
+ for (Entry<String, DataSource> entry : targetDatabase.getResourceMetaData().getDataSources().entrySet()) {
Map<String, Object> dataSourceProps = swapper.swapToMap(DataSourcePropertiesCreator.create(entry.getValue()));
targetDataSourceProperties.put(entry.getKey(), dataSourceProps);
}
diff --git a/kernel/single-table/core/src/main/java/org/apache/shardingsphere/singletable/route/SingleTableSQLRouter.java b/kernel/single-table/core/src/main/java/org/apache/shardingsphere/singletable/route/SingleTableSQLRouter.java
index da8a68f180e..003ff3cff7f 100644
--- a/kernel/single-table/core/src/main/java/org/apache/shardingsphere/singletable/route/SingleTableSQLRouter.java
+++ b/kernel/single-table/core/src/main/java/org/apache/shardingsphere/singletable/route/SingleTableSQLRouter.java
@@ -56,7 +56,7 @@ public final class SingleTableSQLRouter implements SQLRouter<SingleTableRule> {
@Override
public RouteContext createRouteContext(final QueryContext queryContext, final ShardingSphereDatabase database, final SingleTableRule rule,
final ConfigurationProperties props, final ConnectionContext connectionContext) {
- if (1 == database.getResource().getDataSources().size()) {
+ if (1 == database.getResourceMetaData().getDataSources().size()) {
return createSingleDataSourceRouteContext(rule, database);
}
RouteContext result = new RouteContext();
@@ -85,7 +85,7 @@ public final class SingleTableSQLRouter implements SQLRouter<SingleTableRule> {
private RouteContext createSingleDataSourceRouteContext(final SingleTableRule rule, final ShardingSphereDatabase database) {
String logicDataSource = rule.getDataSourceNames().iterator().next();
- String actualDataSource = database.getResource().getDataSources().keySet().iterator().next();
+ String actualDataSource = database.getResourceMetaData().getDataSources().keySet().iterator().next();
RouteContext result = new RouteContext();
result.getRouteUnits().add(new RouteUnit(new RouteMapper(logicDataSource, actualDataSource), Collections.emptyList()));
return result;
diff --git a/kernel/single-table/core/src/test/java/org/apache/shardingsphere/singletable/route/SingleTableSQLRouterTest.java b/kernel/single-table/core/src/test/java/org/apache/shardingsphere/singletable/route/SingleTableSQLRouterTest.java
index 7fc43532e7c..772e0e1b803 100644
--- a/kernel/single-table/core/src/test/java/org/apache/shardingsphere/singletable/route/SingleTableSQLRouterTest.java
+++ b/kernel/single-table/core/src/test/java/org/apache/shardingsphere/singletable/route/SingleTableSQLRouterTest.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.route.SQLRouterFactory;
import org.apache.shardingsphere.infra.route.context.RouteContext;
@@ -78,7 +78,7 @@ public final class SingleTableSQLRouterTest {
private ShardingSphereDatabase mockSingleDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap("foo_ds", new MockedDataSource()));
+ when(result.getResourceMetaData().getDataSources()).thenReturn(Collections.singletonMap("foo_ds", new MockedDataSource()));
return result;
}
@@ -99,7 +99,7 @@ public final class SingleTableSQLRouterTest {
private ShardingSphereDatabase mockReadwriteSplittingDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(result.getName()).thenReturn(" db_schema");
- when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap("write_ds", new MockedDataSource()));
+ when(result.getResourceMetaData().getDataSources()).thenReturn(Collections.singletonMap("write_ds", new MockedDataSource()));
return result;
}
@@ -143,7 +143,7 @@ public final class SingleTableSQLRouterTest {
Map<String, DataSource> dataSourceMap = new HashMap<>(2, 1);
dataSourceMap.put("ds_0", new MockedDataSource());
dataSourceMap.put("ds_1", new MockedDataSource());
- when(result.getResource().getDataSources()).thenReturn(dataSourceMap);
+ when(result.getResourceMetaData().getDataSources()).thenReturn(dataSourceMap);
when(result.getName()).thenReturn(DefaultDatabase.LOGIC_NAME);
return result;
}
@@ -170,7 +170,7 @@ public final class SingleTableSQLRouterTest {
routeContext.getRouteUnits().add(readWriteRouteUnit);
routeContext.getRouteUnits().add(writeRouteUnit);
SingleTableSQLRouter sqlRouter = (SingleTableSQLRouter) SQLRouterFactory.getInstances(Collections.singleton(rule)).get(rule);
- ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS),
+ ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS),
new ShardingSphereRuleMetaData(Collections.singleton(rule)), Collections.emptyMap());
sqlRouter.decorateRouteContext(routeContext, createQueryContext(), database, rule, new ConfigurationProperties(new Properties()), new ConnectionContext());
Iterator<String> routedDataSourceNames = routeContext.getActualDataSourceNames().iterator();
diff --git a/kernel/sql-federation/executor/advanced/src/test/java/org/apache/shardingsphere/sqlfederation/advanced/AdvancedSQLFederationExecutorTest.java b/kernel/sql-federation/executor/advanced/src/test/java/org/apache/shardingsphere/sqlfederation/advanced/AdvancedSQLFederationExecutorTest.java
index 93226946609..52268cfd325 100644
--- a/kernel/sql-federation/executor/advanced/src/test/java/org/apache/shardingsphere/sqlfederation/advanced/AdvancedSQLFederationExecutorTest.java
+++ b/kernel/sql-federation/executor/advanced/src/test/java/org/apache/shardingsphere/sqlfederation/advanced/AdvancedSQLFederationExecutorTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
@@ -55,7 +55,7 @@ public final class AdvancedSQLFederationExecutorTest {
String schemaName = "federate_jdbc";
String databaseName = "database_name";
Map<String, ShardingSphereSchema> schemas = Collections.singletonMap(schemaName, new ShardingSphereSchema(tables, Collections.emptyMap()));
- ShardingSphereDatabase database = new ShardingSphereDatabase(databaseName, new H2DatabaseType(), mockResource(), null, schemas);
+ ShardingSphereDatabase database = new ShardingSphereDatabase(databaseName, new H2DatabaseType(), mockResourceMetaData(), null, schemas);
ShardingSphereRuleMetaData globalRuleMetaData = createGlobalRuleMetaData();
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
when(metaData.getDatabase(databaseName)).thenReturn(database);
@@ -69,8 +69,8 @@ public final class AdvancedSQLFederationExecutorTest {
return new ShardingSphereRuleMetaData(Collections.singleton(new SQLParserRule(new SQLParserRuleConfiguration(false, cacheOption, cacheOption))));
}
- private ShardingSphereResource mockResource() {
- ShardingSphereResource result = mock(ShardingSphereResource.class);
+ private ShardingSphereResourceMetaData mockResourceMetaData() {
+ ShardingSphereResourceMetaData result = mock(ShardingSphereResourceMetaData.class);
when(result.getDatabaseType()).thenReturn(new H2DatabaseType());
return result;
}
diff --git a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java
index 4f9a6b90913..46a87afb08b 100644
--- a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java
+++ b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java
@@ -74,9 +74,9 @@ public final class TransactionRule implements GlobalRule, ResourceHeldRule<Shard
Set<DatabaseType> databaseTypes = new HashSet<>();
for (Entry<String, ShardingSphereDatabase> entry : databases.entrySet()) {
ShardingSphereDatabase database = entry.getValue();
- database.getResource().getDataSources().forEach((key, value) -> dataSourceMap.put(database.getName() + "." + key, value));
- if (null != entry.getValue().getResource().getDatabaseType()) {
- databaseTypes.add(entry.getValue().getResource().getDatabaseType());
+ database.getResourceMetaData().getDataSources().forEach((key, value) -> dataSourceMap.put(database.getName() + "." + key, value));
+ if (null != entry.getValue().getResourceMetaData().getDatabaseType()) {
+ databaseTypes.add(entry.getValue().getResourceMetaData().getDatabaseType());
}
}
Preconditions.checkState(databaseTypes.size() < 2, "Multiple types of databases are not supported");
diff --git a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/rule/TransactionRuleTest.java b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/rule/TransactionRuleTest.java
index eb97f653f2a..f08fd4a21b7 100644
--- a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/rule/TransactionRuleTest.java
+++ b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/rule/TransactionRuleTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.transaction.rule;
import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
import org.junit.Test;
@@ -38,13 +38,13 @@ public final class TransactionRuleTest {
when(transactionRuleConfiguration.getDefaultType()).thenReturn("XA");
when(transactionRuleConfiguration.getProviderType()).thenReturn("Atomikos");
ShardingSphereDatabase db1 = mock(ShardingSphereDatabase.class);
- ShardingSphereResource resource1 = mock(ShardingSphereResource.class);
- when(resource1.getDatabaseType()).thenReturn(new OpenGaussDatabaseType());
- when(db1.getResource()).thenReturn(resource1);
+ ShardingSphereResourceMetaData resourceMetaData1 = mock(ShardingSphereResourceMetaData.class);
+ when(resourceMetaData1.getDatabaseType()).thenReturn(new OpenGaussDatabaseType());
+ when(db1.getResourceMetaData()).thenReturn(resourceMetaData1);
ShardingSphereDatabase db2 = mock(ShardingSphereDatabase.class);
- ShardingSphereResource resource2 = mock(ShardingSphereResource.class);
- when(resource2.getDatabaseType()).thenReturn(new PostgreSQLDatabaseType());
- when(db2.getResource()).thenReturn(resource2);
+ ShardingSphereResourceMetaData resourceMetaData2 = mock(ShardingSphereResourceMetaData.class);
+ when(resourceMetaData2.getDatabaseType()).thenReturn(new PostgreSQLDatabaseType());
+ when(db2.getResourceMetaData()).thenReturn(resourceMetaData2);
Map<String, ShardingSphereDatabase> databaseMap = new HashMap<>();
databaseMap.put("db1", db1);
databaseMap.put("db2", db2);
diff --git a/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleStatementUpdaterTest.java b/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleStatementUpdaterTest.java
index c0f9b3bb74a..630e2a20769 100644
--- a/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleStatementUpdaterTest.java
+++ b/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleStatementUpdaterTest.java
@@ -84,7 +84,7 @@ public final class AlterTransactionRuleStatementUpdaterTest {
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap("foo_ds", mock(DataSource.class, RETURNS_DEEP_STUBS)));
+ when(result.getResourceMetaData().getDataSources()).thenReturn(Collections.singletonMap("foo_ds", mock(DataSource.class, RETURNS_DEEP_STUBS)));
return result;
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
index 3cfca2ecd56..da706a87621 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
@@ -34,7 +34,7 @@ import org.apache.shardingsphere.infra.metadata.data.ShardingSphereData;
import org.apache.shardingsphere.infra.metadata.data.builder.ShardingSphereDataBuilderFactory;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.SchemaManager;
import org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilder;
@@ -97,7 +97,7 @@ public final class ContextManager implements AutoCloseable {
* @return data source map
*/
public Map<String, DataSource> getDataSourceMap(final String databaseName) {
- return metaDataContexts.getMetaData().getDatabase(databaseName).getResource().getDataSources();
+ return metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData().getDataSources();
}
/**
@@ -254,7 +254,7 @@ public final class ContextManager implements AutoCloseable {
* @throws SQLException SQL exception
*/
public synchronized void addResources(final String databaseName, final Map<String, DataSourceProperties> toBeAddedDataSourcePropsMap) throws SQLException {
- SwitchingResource switchingResource = new ResourceSwitchManager().create(metaDataContexts.getMetaData().getDatabase(databaseName).getResource(), toBeAddedDataSourcePropsMap);
+ SwitchingResource switchingResource = new ResourceSwitchManager().create(metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData(), toBeAddedDataSourcePropsMap);
metaDataContexts.getMetaData().getDatabases().putAll(createChangedDatabases(databaseName, switchingResource, null));
metaDataContexts.getMetaData().getGlobalRuleMetaData().findRules(ResourceHeldRule.class).forEach(each -> each.addResource(metaDataContexts.getMetaData().getDatabase(databaseName)));
metaDataContexts.getMetaData().getDatabase(databaseName).getSchemas().forEach((schemaName, schema) -> metaDataContexts.getPersistService().getDatabaseMetaDataService()
@@ -271,7 +271,7 @@ public final class ContextManager implements AutoCloseable {
* @throws SQLException SQL exception
*/
public synchronized void updateResources(final String databaseName, final Map<String, DataSourceProperties> toBeUpdatedDataSourcePropsMap) throws SQLException {
- SwitchingResource switchingResource = new ResourceSwitchManager().create(metaDataContexts.getMetaData().getDatabase(databaseName).getResource(), toBeUpdatedDataSourcePropsMap);
+ SwitchingResource switchingResource = new ResourceSwitchManager().create(metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData(), toBeUpdatedDataSourcePropsMap);
metaDataContexts.getMetaData().getDatabases().putAll(createChangedDatabases(databaseName, switchingResource, null));
metaDataContexts.getMetaData().getGlobalRuleMetaData().findRules(ResourceHeldRule.class).forEach(each -> each.addResource(metaDataContexts.getMetaData().getDatabase(databaseName)));
metaDataContexts.getMetaData().getDatabases().putAll(newShardingSphereDatabase(metaDataContexts.getMetaData().getDatabase(databaseName)));
@@ -290,7 +290,8 @@ public final class ContextManager implements AutoCloseable {
// TODO should check to be dropped resources are unused here. ContextManager is atomic domain to maintain metadata, not Dist SQL handler
Map<String, DataSourceProperties> dataSourcePropsMap = metaDataContexts.getPersistService().getDataSourceService().load(metaDataContexts.getMetaData().getActualDatabaseName(databaseName));
Map<String, DataSourceProperties> toBeDeletedDataSourcePropsMap = getToBeDeletedDataSourcePropsMap(dataSourcePropsMap, toBeDroppedResourceNames);
- SwitchingResource switchingResource = new ResourceSwitchManager().createByDropResource(metaDataContexts.getMetaData().getDatabase(databaseName).getResource(), toBeDeletedDataSourcePropsMap);
+ SwitchingResource switchingResource =
+ new ResourceSwitchManager().createByDropResource(metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData(), toBeDeletedDataSourcePropsMap);
metaDataContexts.getMetaData().getDatabases().putAll(renewDatabase(metaDataContexts.getMetaData().getDatabase(databaseName), switchingResource));
MetaDataContexts reloadMetaDataContexts = createMetaDataContexts(databaseName, switchingResource, null);
alterSchemaMetaData(databaseName, reloadMetaDataContexts.getMetaData().getDatabase(databaseName), metaDataContexts.getMetaData().getDatabase(databaseName));
@@ -304,10 +305,10 @@ public final class ContextManager implements AutoCloseable {
private Map<String, ShardingSphereDatabase> renewDatabase(final ShardingSphereDatabase database, final SwitchingResource resource) {
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1);
Map<String, DataSource> newDataSource =
- database.getResource().getDataSources().entrySet().stream().filter(entry -> !resource.getStaleDataSources().containsKey(entry.getKey()))
+ database.getResourceMetaData().getDataSources().entrySet().stream().filter(entry -> !resource.getStaleDataSources().containsKey(entry.getKey()))
.collect(Collectors.toMap(Entry::getKey, Entry::getValue));
result.put(database.getName().toLowerCase(),
- new ShardingSphereDatabase(database.getName(), database.getProtocolType(), new ShardingSphereResource(database.getName(), newDataSource),
+ new ShardingSphereDatabase(database.getName(), database.getProtocolType(), new ShardingSphereResourceMetaData(database.getName(), newDataSource),
database.getRuleMetaData(), database.getSchemas()));
return result;
}
@@ -358,7 +359,7 @@ public final class ContextManager implements AutoCloseable {
try {
Collection<ResourceHeldRule> staleResourceHeldRules = getStaleResourceHeldRules(databaseName);
staleResourceHeldRules.forEach(ResourceHeldRule::closeStaleResource);
- SwitchingResource switchingResource = new ResourceSwitchManager().create(metaDataContexts.getMetaData().getDatabase(databaseName).getResource(), dataSourcePropsMap);
+ SwitchingResource switchingResource = new ResourceSwitchManager().create(metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData(), dataSourcePropsMap);
metaDataContexts = createMetaDataContexts(databaseName, switchingResource, null);
metaDataContexts.getMetaData().getDatabases().putAll(newShardingSphereDatabase(metaDataContexts.getMetaData().getDatabase(databaseName)));
switchingResource.closeStaleDataSources();
@@ -380,7 +381,7 @@ public final class ContextManager implements AutoCloseable {
try {
Collection<ResourceHeldRule> staleResourceHeldRules = getStaleResourceHeldRules(databaseName);
staleResourceHeldRules.forEach(ResourceHeldRule::closeStaleResource);
- SwitchingResource switchingResource = new ResourceSwitchManager().create(metaDataContexts.getMetaData().getDatabase(databaseName).getResource(), dataSourcePropsMap);
+ SwitchingResource switchingResource = new ResourceSwitchManager().create(metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData(), dataSourcePropsMap);
metaDataContexts = createMetaDataContexts(databaseName, switchingResource, ruleConfigs);
metaDataContexts.getMetaData().getDatabases().putAll(newShardingSphereDatabase(metaDataContexts.getMetaData().getDatabase(databaseName)));
switchingResource.closeStaleDataSources();
@@ -410,13 +411,13 @@ public final class ContextManager implements AutoCloseable {
private Map<String, ShardingSphereDatabase> createChangedDatabases(final String databaseName,
final SwitchingResource switchingResource, final Collection<RuleConfiguration> ruleConfigs) throws SQLException {
if (null != switchingResource && !switchingResource.getNewDataSources().isEmpty()) {
- metaDataContexts.getMetaData().getDatabase(databaseName).getResource().getDataSources().putAll(switchingResource.getNewDataSources());
+ metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData().getDataSources().putAll(switchingResource.getNewDataSources());
}
Collection<RuleConfiguration> toBeCreatedRuleConfigs = null == ruleConfigs
? metaDataContexts.getMetaData().getDatabase(databaseName).getRuleMetaData().getConfigurations()
: ruleConfigs;
DatabaseConfiguration toBeCreatedDatabaseConfig =
- new DataSourceProvidedDatabaseConfiguration(metaDataContexts.getMetaData().getDatabase(databaseName).getResource().getDataSources(), toBeCreatedRuleConfigs);
+ new DataSourceProvidedDatabaseConfiguration(metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData().getDataSources(), toBeCreatedRuleConfigs);
ShardingSphereDatabase changedDatabase = ShardingSphereDatabasesFactory.create(metaDataContexts.getMetaData().getActualDatabaseName(databaseName),
toBeCreatedDatabaseConfig, metaDataContexts.getMetaData().getProps(), instanceContext);
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(metaDataContexts.getMetaData().getDatabases());
@@ -439,7 +440,7 @@ public final class ContextManager implements AutoCloseable {
private Map<String, ShardingSphereDatabase> newShardingSphereDatabase(final ShardingSphereDatabase originalDatabase) {
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1);
result.put(originalDatabase.getName().toLowerCase(), new ShardingSphereDatabase(originalDatabase.getName(),
- originalDatabase.getProtocolType(), originalDatabase.getResource(), originalDatabase.getRuleMetaData(),
+ originalDatabase.getProtocolType(), originalDatabase.getResourceMetaData(), originalDatabase.getRuleMetaData(),
metaDataContexts.getPersistService().getDatabaseMetaDataService().loadSchemas(originalDatabase.getName())));
return result;
}
@@ -481,8 +482,8 @@ public final class ContextManager implements AutoCloseable {
*/
public synchronized void reloadDatabase(final String databaseName) {
try {
- ShardingSphereResource currentResource = metaDataContexts.getMetaData().getDatabase(databaseName).getResource();
- SwitchingResource switchingResource = new SwitchingResource(currentResource, currentResource.getDataSources(), Collections.emptyMap());
+ ShardingSphereResourceMetaData currentResourceMetaData = metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData();
+ SwitchingResource switchingResource = new SwitchingResource(currentResourceMetaData, currentResourceMetaData.getDataSources(), Collections.emptyMap());
MetaDataContexts reloadedMetaDataContexts = createMetaDataContexts(databaseName, switchingResource, null);
deletedSchemaNames(databaseName, reloadedMetaDataContexts.getMetaData().getDatabase(databaseName), metaDataContexts.getMetaData().getDatabase(databaseName));
metaDataContexts = reloadedMetaDataContexts;
@@ -523,8 +524,8 @@ public final class ContextManager implements AutoCloseable {
private ShardingSphereSchema loadSchema(final String databaseName, final String schemaName, final String dataSourceName) throws SQLException {
ShardingSphereDatabase database = metaDataContexts.getMetaData().getDatabase(databaseName);
database.reloadRules(MutableDataNodeRule.class);
- GenericSchemaBuilderMaterials materials = new GenericSchemaBuilderMaterials(database.getProtocolType(), database.getResource().getDatabaseType(),
- Collections.singletonMap(dataSourceName, database.getResource().getDataSources().get(dataSourceName)),
+ GenericSchemaBuilderMaterials materials = new GenericSchemaBuilderMaterials(database.getProtocolType(), database.getResourceMetaData().getDatabaseType(),
+ Collections.singletonMap(dataSourceName, database.getResourceMetaData().getDataSources().get(dataSourceName)),
database.getRuleMetaData().getRules(), metaDataContexts.getMetaData().getProps(), schemaName);
ShardingSphereSchema result = GenericSchemaBuilder.build(materials).get(schemaName);
result.getViews().putAll(metaDataContexts.getPersistService().getDatabaseMetaDataService().getViewMetaDataPersistService().load(database.getName(), schemaName));
@@ -539,7 +540,7 @@ public final class ContextManager implements AutoCloseable {
* @param tableName to be reloaded table name
*/
public void reloadTable(final String databaseName, final String schemaName, final String tableName) {
- Map<String, DataSource> dataSourceMap = metaDataContexts.getMetaData().getDatabase(databaseName).getResource().getDataSources();
+ Map<String, DataSource> dataSourceMap = metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData().getDataSources();
try {
reloadTable(databaseName, schemaName, tableName, dataSourceMap);
} catch (final SQLException ex) {
@@ -557,7 +558,7 @@ public final class ContextManager implements AutoCloseable {
*/
public void reloadTable(final String databaseName, final String schemaName, final String dataSourceName, final String tableName) {
Map<String, DataSource> dataSourceMap = Collections.singletonMap(
- dataSourceName, metaDataContexts.getMetaData().getDatabase(databaseName).getResource().getDataSources().get(dataSourceName));
+ dataSourceName, metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData().getDataSources().get(dataSourceName));
try {
reloadTable(databaseName, schemaName, tableName, dataSourceMap);
} catch (final SQLException ex) {
@@ -568,7 +569,7 @@ public final class ContextManager implements AutoCloseable {
private synchronized void reloadTable(final String databaseName, final String schemaName, final String tableName, final Map<String, DataSource> dataSourceMap) throws SQLException {
ShardingSphereDatabase database = metaDataContexts.getMetaData().getDatabase(databaseName);
GenericSchemaBuilderMaterials materials = new GenericSchemaBuilderMaterials(database.getProtocolType(),
- database.getResource().getDatabaseType(), dataSourceMap, database.getRuleMetaData().getRules(), metaDataContexts.getMetaData().getProps(), schemaName);
+ database.getResourceMetaData().getDatabaseType(), dataSourceMap, database.getRuleMetaData().getRules(), metaDataContexts.getMetaData().getProps(), schemaName);
ShardingSphereSchema schema = GenericSchemaBuilder.build(Collections.singletonList(tableName), materials).getOrDefault(schemaName, new ShardingSphereSchema());
if (schema.containsTable(tableName)) {
alterTable(databaseName, schemaName, schema.getTable(tableName));
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManager.java
index 07a0c8087a8..812ee15d1f4 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManager.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManager.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.mode.manager.switcher;
import org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator;
import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
import org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesCreator;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import javax.sql.DataSource;
import java.util.Collections;
@@ -37,39 +37,40 @@ public final class ResourceSwitchManager {
/**
* Create switching resource.
*
- * @param resource resource
+ * @param resourceMetaData resource meta data
* @param toBeChangedDataSourceProps to be changed data source properties map
* @return created switching resource
*/
- public SwitchingResource create(final ShardingSphereResource resource, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
- return new SwitchingResource(resource, createNewDataSources(resource, toBeChangedDataSourceProps), getStaleDataSources(resource, toBeChangedDataSourceProps));
+ public SwitchingResource create(final ShardingSphereResourceMetaData resourceMetaData, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
+ return new SwitchingResource(resourceMetaData, createNewDataSources(resourceMetaData, toBeChangedDataSourceProps), getStaleDataSources(resourceMetaData, toBeChangedDataSourceProps));
}
/**
* Create switching resource.
*
- * @param resource resource
+ * @param resourceMetaData resource meta data
* @param toBeDeletedDataSourceProps to be deleted data source properties map
* @return created switching resource
*/
- public SwitchingResource createByDropResource(final ShardingSphereResource resource, final Map<String, DataSourceProperties> toBeDeletedDataSourceProps) {
- return new SwitchingResource(resource, Collections.emptyMap(), getStaleDataSources(resource.getDataSources(), toBeDeletedDataSourceProps));
+ public SwitchingResource createByDropResource(final ShardingSphereResourceMetaData resourceMetaData, final Map<String, DataSourceProperties> toBeDeletedDataSourceProps) {
+ return new SwitchingResource(resourceMetaData, Collections.emptyMap(), getStaleDataSources(resourceMetaData.getDataSources(), toBeDeletedDataSourceProps));
}
- private Map<String, DataSource> createNewDataSources(final ShardingSphereResource resource, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
- Map<String, DataSource> result = new LinkedHashMap<>(resource.getDataSources());
- result.keySet().removeAll(getToBeDeletedDataSources(resource, toBeChangedDataSourceProps).keySet());
- result.putAll(createToBeChangedDataSources(resource, toBeChangedDataSourceProps));
- result.putAll(createToBeAddedDataSources(resource, toBeChangedDataSourceProps));
+ private Map<String, DataSource> createNewDataSources(final ShardingSphereResourceMetaData resourceMetaData, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
+ Map<String, DataSource> result = new LinkedHashMap<>(resourceMetaData.getDataSources());
+ result.keySet().removeAll(getToBeDeletedDataSources(resourceMetaData, toBeChangedDataSourceProps).keySet());
+ result.putAll(createToBeChangedDataSources(resourceMetaData, toBeChangedDataSourceProps));
+ result.putAll(createToBeAddedDataSources(resourceMetaData, toBeChangedDataSourceProps));
return result;
}
- private Map<String, DataSource> createToBeChangedDataSources(final ShardingSphereResource resource, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
- return DataSourcePoolCreator.create(getChangedDataSourceProperties(resource, toBeChangedDataSourceProps));
+ private Map<String, DataSource> createToBeChangedDataSources(final ShardingSphereResourceMetaData resourceMetaData, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
+ return DataSourcePoolCreator.create(getChangedDataSourceProperties(resourceMetaData, toBeChangedDataSourceProps));
}
- private Map<String, DataSourceProperties> getChangedDataSourceProperties(final ShardingSphereResource resource, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
- return toBeChangedDataSourceProps.entrySet().stream().filter(entry -> isModifiedDataSource(resource.getDataSources(), entry.getKey(), entry.getValue()))
+ private Map<String, DataSourceProperties> getChangedDataSourceProperties(final ShardingSphereResourceMetaData resourceMetaData,
+ final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
+ return toBeChangedDataSourceProps.entrySet().stream().filter(entry -> isModifiedDataSource(resourceMetaData.getDataSources(), entry.getKey(), entry.getValue()))
.collect(Collectors.toMap(Entry::getKey, Entry::getValue, (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
}
@@ -77,15 +78,15 @@ public final class ResourceSwitchManager {
return originalDataSources.containsKey(dataSourceName) && !dataSourceProps.equals(DataSourcePropertiesCreator.create(originalDataSources.get(dataSourceName)));
}
- private Map<String, DataSource> createToBeAddedDataSources(final ShardingSphereResource resource, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
+ private Map<String, DataSource> createToBeAddedDataSources(final ShardingSphereResourceMetaData resourceMetaData, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
Map<String, DataSourceProperties> toBeAddedDataSourceProps = toBeChangedDataSourceProps.entrySet().stream()
- .filter(entry -> !resource.getDataSources().containsKey(entry.getKey())).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+ .filter(entry -> !resourceMetaData.getDataSources().containsKey(entry.getKey())).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
return DataSourcePoolCreator.create(toBeAddedDataSourceProps);
}
- private Map<String, DataSource> getStaleDataSources(final ShardingSphereResource resource, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
- Map<String, DataSource> result = new LinkedHashMap<>(resource.getDataSources().size(), 1);
- result.putAll(getToBeChangedDataSources(resource, toBeChangedDataSourceProps));
+ private Map<String, DataSource> getStaleDataSources(final ShardingSphereResourceMetaData resourceMetaData, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
+ Map<String, DataSource> result = new LinkedHashMap<>(resourceMetaData.getDataSources().size(), 1);
+ result.putAll(getToBeChangedDataSources(resourceMetaData, toBeChangedDataSourceProps));
return result;
}
@@ -93,12 +94,12 @@ public final class ResourceSwitchManager {
return dataSources.entrySet().stream().filter(entry -> toBeDeletedDataSourceProps.containsKey(entry.getKey())).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
}
- private Map<String, DataSource> getToBeDeletedDataSources(final ShardingSphereResource resource, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
- return resource.getDataSources().entrySet().stream().filter(entry -> !toBeChangedDataSourceProps.containsKey(entry.getKey())).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+ private Map<String, DataSource> getToBeDeletedDataSources(final ShardingSphereResourceMetaData resourceMetaData, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
+ return resourceMetaData.getDataSources().entrySet().stream().filter(entry -> !toBeChangedDataSourceProps.containsKey(entry.getKey())).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
}
- private Map<String, DataSource> getToBeChangedDataSources(final ShardingSphereResource resource, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
- Map<String, DataSourceProperties> changedDataSourceProps = getChangedDataSourceProperties(resource, toBeChangedDataSourceProps);
- return resource.getDataSources().entrySet().stream().filter(entry -> changedDataSourceProps.containsKey(entry.getKey())).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+ private Map<String, DataSource> getToBeChangedDataSources(final ShardingSphereResourceMetaData resourceMetaData, final Map<String, DataSourceProperties> toBeChangedDataSourceProps) {
+ Map<String, DataSourceProperties> changedDataSourceProps = getChangedDataSourceProperties(resourceMetaData, toBeChangedDataSourceProps);
+ return resourceMetaData.getDataSources().entrySet().stream().filter(entry -> changedDataSourceProps.containsKey(entry.getKey())).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
}
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/SwitchingResource.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/SwitchingResource.java
index 5d4d9bea68f..8a0dd829b46 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/SwitchingResource.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/SwitchingResource.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mode.manager.switcher;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import javax.sql.DataSource;
import java.util.Map;
@@ -30,7 +30,7 @@ import java.util.Map;
@RequiredArgsConstructor
public final class SwitchingResource {
- private final ShardingSphereResource resource;
+ private final ShardingSphereResourceMetaData resourceMetaData;
@Getter
private final Map<String, DataSource> newDataSources;
@@ -42,6 +42,6 @@ public final class SwitchingResource {
* Close stale data sources.
*/
public void closeStaleDataSources() {
- staleDataSources.values().forEach(resource::close);
+ staleDataSources.values().forEach(resourceMetaData::close);
}
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java
index ab429f25e9a..380dc414288 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java
@@ -137,7 +137,7 @@ public final class MetaDataContextsFactory {
databases.forEach((key, value) -> {
Map<String, ShardingSphereSchema> schemas = persistService.getDatabaseMetaDataService().loadSchemas(key);
result.put(key.toLowerCase(), new ShardingSphereDatabase(value.getName(),
- value.getProtocolType(), value.getResource(), value.getRuleMetaData(), schemas.isEmpty() ? value.getSchemas() : schemas));
+ value.getProtocolType(), value.getResourceMetaData(), value.getRuleMetaData(), schemas.isEmpty() ? value.getSchemas() : schemas));
});
return result;
}
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
index d95b4b4e22e..ee0508324c2 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
@@ -90,7 +90,7 @@ public final class ContextManagerTest {
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(result.getProtocolType()).thenReturn(new MySQLDatabaseType());
- when(result.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(result.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
MutableDataNodeRule mutableDataNodeRule = mock(MutableDataNodeRule.class, RETURNS_DEEP_STUBS);
when(mutableDataNodeRule.findSingleTableDataNode("foo_schema", "foo_tbl")).thenReturn(Optional.of(mock(DataNode.class)));
when(result.getRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.singleton(mutableDataNodeRule)));
@@ -100,8 +100,9 @@ public final class ContextManagerTest {
@Test
public void assertGetDataSourceMap() {
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource()));
- ShardingSphereDatabase database = new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), resource, mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource()));
+ ShardingSphereDatabase database =
+ new ShardingSphereDatabase(DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), resourceMetaData, mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
when(metaDataContexts.getMetaData().getDatabase(DefaultDatabase.LOGIC_NAME)).thenReturn(database);
assertThat(contextManager.getDataSourceMap(DefaultDatabase.LOGIC_NAME).size(), is(1));
}
@@ -229,21 +230,21 @@ public final class ContextManagerTest {
@Test
public void assertUpdateResources() throws SQLException {
ShardingSphereDatabase originalDatabase = createOriginalDatabaseMetaData();
- ShardingSphereResource originalResource = originalDatabase.getResource();
- DataSource originalDataSource = originalResource.getDataSources().get("bar_ds");
+ ShardingSphereResourceMetaData originalResourceMetaData = originalDatabase.getResourceMetaData();
+ DataSource originalDataSource = originalResourceMetaData.getDataSources().get("bar_ds");
when(metaDataContexts.getMetaData().getDatabase("foo_db")).thenReturn(originalDatabase);
contextManager.updateResources("foo_db", Collections.singletonMap("bar_ds", new DataSourceProperties(MockedDataSource.class.getName(),
createProperties("test", "test"))));
- verify(originalResource, times(1)).close(originalDataSource);
- assertAlteredDataSource((MockedDataSource) contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").getResource().getDataSources().get("bar_ds"));
+ verify(originalResourceMetaData, times(1)).close(originalDataSource);
+ assertAlteredDataSource((MockedDataSource) contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").getResourceMetaData().getDataSources().get("bar_ds"));
}
private ShardingSphereDatabase createOriginalDatabaseMetaData() {
- ShardingSphereResource resource = mock(ShardingSphereResource.class);
- when(resource.getDataSources()).thenReturn(Collections.singletonMap("bar_ds", new MockedDataSource()));
+ ShardingSphereResourceMetaData resourceMetaData = mock(ShardingSphereResourceMetaData.class);
+ when(resourceMetaData.getDataSources()).thenReturn(Collections.singletonMap("bar_ds", new MockedDataSource()));
ShardingSphereRuleMetaData ruleMetaData = mock(ShardingSphereRuleMetaData.class);
when(ruleMetaData.getConfigurations()).thenReturn(new LinkedList<>());
- return new ShardingSphereDatabase("foo_db", new MySQLDatabaseType(), resource, ruleMetaData, Collections.emptyMap());
+ return new ShardingSphereDatabase("foo_db", new MySQLDatabaseType(), resourceMetaData, ruleMetaData, Collections.emptyMap());
}
private void assertAlteredDataSource(final MockedDataSource actual) {
@@ -267,14 +268,14 @@ public final class ContextManagerTest {
dataSourcePropertiesMap.put("ds_2", mock(DataSourceProperties.class));
when(metaDataContexts.getPersistService().getDataSourceService().load("foo_db")).thenReturn(dataSourcePropertiesMap);
contextManager.dropResources("foo_db", Arrays.asList("ds_1", "ds_2"));
- assertTrue(metaDataContexts.getMetaData().getDatabases().get("foo_db").getResource().getDataSources().isEmpty());
+ assertTrue(metaDataContexts.getMetaData().getDatabases().get("foo_db").getResourceMetaData().getDataSources().isEmpty());
}
@Test
public void assertAlterRuleConfiguration() {
- ShardingSphereResource resource = mock(ShardingSphereResource.class);
+ ShardingSphereResourceMetaData resourceMetaData = mock(ShardingSphereResourceMetaData.class);
Map<String, ShardingSphereDatabase> databases = new HashMap<>();
- databases.put("foo_db", new ShardingSphereDatabase("foo_db", new MySQLDatabaseType(), resource, mock(ShardingSphereRuleMetaData.class), Collections.emptyMap()));
+ databases.put("foo_db", new ShardingSphereDatabase("foo_db", new MySQLDatabaseType(), resourceMetaData, mock(ShardingSphereRuleMetaData.class), Collections.emptyMap()));
when(metaDataContexts.getMetaData().getDatabases()).thenReturn(databases);
when(metaDataContexts.getMetaData().getGlobalRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.emptyList()));
when(metaDataContexts.getPersistService()).thenReturn(mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS));
@@ -294,12 +295,12 @@ public final class ContextManagerTest {
when(metaDataContexts.getMetaData().getActualDatabaseName("foo_db")).thenReturn("foo_db");
when(metaDataContexts.getMetaData().getGlobalRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.emptyList()));
contextManager.alterDataSourceConfiguration("foo_db", Collections.singletonMap("foo_ds", new DataSourceProperties(MockedDataSource.class.getName(), createProperties("test", "test"))));
- assertThat(contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").getResource().getDataSources().size(), is(3));
- assertAlteredDataSource((MockedDataSource) contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").getResource().getDataSources().get("foo_ds"));
+ assertThat(contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").getResourceMetaData().getDataSources().size(), is(3));
+ assertAlteredDataSource((MockedDataSource) contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").getResourceMetaData().getDataSources().get("foo_ds"));
}
- private ShardingSphereResource createOriginalResource() {
- ShardingSphereResource result = mock(ShardingSphereResource.class);
+ private ShardingSphereResourceMetaData createOriginalResource() {
+ ShardingSphereResourceMetaData result = mock(ShardingSphereResourceMetaData.class);
Map<String, DataSource> originalDataSources = new LinkedHashMap<>(2, 1);
originalDataSources.put("ds_1", new MockedDataSource());
originalDataSources.put("ds_2", new MockedDataSource());
@@ -332,7 +333,7 @@ public final class ContextManagerTest {
public void assertReloadDatabase() {
Map<String, DataSource> dataSourceMap = new LinkedHashMap<>(1, 1);
dataSourceMap.put("foo_ds", new MockedDataSource());
- when(metaDataContexts.getMetaData().getDatabase("foo_db").getResource().getDataSources()).thenReturn(dataSourceMap);
+ when(metaDataContexts.getMetaData().getDatabase("foo_db").getResourceMetaData().getDataSources()).thenReturn(dataSourceMap);
when(metaDataContexts.getMetaData().getActualDatabaseName("foo_db")).thenReturn("foo_db");
DatabaseMetaDataPersistService databaseMetaDataPersistService = mock(DatabaseMetaDataPersistService.class, RETURNS_DEEP_STUBS);
MetaDataPersistService persistService = mock(MetaDataPersistService.class);
@@ -345,7 +346,7 @@ public final class ContextManagerTest {
@Test
public void assertReloadSchema() {
- when(metaDataContexts.getMetaData().getDatabase("foo_db").getResource().getDataSources()).thenReturn(Collections.singletonMap("foo_ds", new MockedDataSource()));
+ when(metaDataContexts.getMetaData().getDatabase("foo_db").getResourceMetaData().getDataSources()).thenReturn(Collections.singletonMap("foo_ds", new MockedDataSource()));
when(metaDataContexts.getMetaData().getActualDatabaseName("foo_db")).thenReturn("foo_db");
DatabaseMetaDataPersistService databaseMetaDataPersistService = mock(DatabaseMetaDataPersistService.class, RETURNS_DEEP_STUBS);
MetaDataPersistService persistService = mock(MetaDataPersistService.class);
@@ -357,13 +358,13 @@ public final class ContextManagerTest {
@Test
public void assertReloadTable() {
- when(metaDataContexts.getMetaData().getDatabase("foo_db").getResource().getDataSources()).thenReturn(Collections.singletonMap("foo_ds", new MockedDataSource()));
+ when(metaDataContexts.getMetaData().getDatabase("foo_db").getResourceMetaData().getDataSources()).thenReturn(Collections.singletonMap("foo_ds", new MockedDataSource()));
DatabaseMetaDataPersistService databaseMetaDataPersistService = mock(DatabaseMetaDataPersistService.class, RETURNS_DEEP_STUBS);
MetaDataPersistService persistService = mock(MetaDataPersistService.class);
when(persistService.getDatabaseMetaDataService()).thenReturn(databaseMetaDataPersistService);
when(metaDataContexts.getPersistService()).thenReturn(persistService);
contextManager.reloadTable("foo_db", "foo_schema", "foo_table");
- assertTrue(contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").getResource().getDataSources().containsKey("foo_ds"));
+ assertTrue(contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").getResourceMetaData().getDataSources().containsKey("foo_ds"));
}
private Map<String, Object> createProperties(final String username, final String password) {
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManagerTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManagerTest.java
index 098793fdb29..453cfdb992c 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManagerTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManagerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.mode.manager.switcher;
import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.test.mock.MockedDataSource;
import org.junit.Test;
@@ -37,7 +37,7 @@ public final class ResourceSwitchManagerTest {
@Test
public void assertCreate() throws InterruptedException {
Map<String, DataSource> dataSourceMap = createDataSourceMap();
- SwitchingResource actual = new ResourceSwitchManager().create(new ShardingSphereResource("sharding_db", dataSourceMap), createToBeChangedDataSourcePropsMap());
+ SwitchingResource actual = new ResourceSwitchManager().create(new ShardingSphereResourceMetaData("sharding_db", dataSourceMap), createToBeChangedDataSourcePropsMap());
assertNewDataSources(actual);
actual.closeStaleDataSources();
assertStaleDataSources(dataSourceMap);
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/switcher/SwitchingResourceTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/switcher/SwitchingResourceTest.java
index ccbd2eb1842..c1834e35b08 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/switcher/SwitchingResourceTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/switcher/SwitchingResourceTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.mode.manager.switcher;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.test.mock.MockedDataSource;
import org.junit.Test;
@@ -31,8 +31,8 @@ public final class SwitchingResourceTest {
@Test
public void assertCloseStaleDataSources() {
MockedDataSource staleDataSource = new MockedDataSource();
- ShardingSphereResource resource = mock(ShardingSphereResource.class);
- new SwitchingResource(resource, Collections.singletonMap("new_ds", new MockedDataSource()), Collections.singletonMap("stale_ds", staleDataSource)).closeStaleDataSources();
- verify(resource).close(staleDataSource);
+ ShardingSphereResourceMetaData resourceMetaData = mock(ShardingSphereResourceMetaData.class);
+ new SwitchingResource(resourceMetaData, Collections.singletonMap("new_ds", new MockedDataSource()), Collections.singletonMap("stale_ds", staleDataSource)).closeStaleDataSources();
+ verify(resourceMetaData).close(staleDataSource);
}
}
diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
index 8ebd956eda5..d5857e628a0 100644
--- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
+++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
@@ -34,7 +34,7 @@ import org.apache.shardingsphere.infra.instance.metadata.proxy.ProxyInstanceMeta
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.data.ShardingSphereData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
@@ -148,8 +148,8 @@ public final class ClusterContextManagerCoordinatorTest {
private Map<String, ShardingSphereDatabase> createDatabases() {
when(database.getName()).thenReturn("db");
- when(database.getResource().getDataSources()).thenReturn(new LinkedHashMap<>());
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDataSources()).thenReturn(new LinkedHashMap<>());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(database.getSchemas()).thenReturn(Collections.singletonMap("foo_schema", new ShardingSphereSchema()));
when(database.getProtocolType()).thenReturn(new MySQLDatabaseType());
when(database.getSchema("foo_schema")).thenReturn(mock(ShardingSphereSchema.class));
@@ -166,7 +166,7 @@ public final class ClusterContextManagerCoordinatorTest {
when(persistService.getDataSourceService().load("db_added")).thenReturn(createDataSourcePropertiesMap());
when(persistService.getDatabaseRulePersistService().load("db_added")).thenReturn(Collections.emptyList());
coordinator.renew(new DatabaseAddedEvent("db_added"));
- assertNotNull(contextManager.getMetaDataContexts().getMetaData().getDatabase("db_added").getResource().getDataSources());
+ assertNotNull(contextManager.getMetaDataContexts().getMetaData().getDatabase("db_added").getResourceMetaData().getDataSources());
}
private Map<String, DataSourceProperties> createDataSourcePropertiesMap() {
@@ -238,7 +238,7 @@ public final class ClusterContextManagerCoordinatorTest {
public void assertRenewForDataSourceChanged() {
when(persistService.getMetaDataVersionPersistService().isActiveVersion("db", "0")).thenReturn(true);
coordinator.renew(new DataSourceChangedEvent("db", "0", createChangedDataSourcePropertiesMap()));
- assertTrue(contextManager.getMetaDataContexts().getMetaData().getDatabase("db").getResource().getDataSources().containsKey("ds_2"));
+ assertTrue(contextManager.getMetaDataContexts().getMetaData().getDatabase("db").getResourceMetaData().getDataSources().containsKey("ds_2"));
}
private Map<String, DataSourceProperties> createChangedDataSourcePropertiesMap() {
@@ -394,8 +394,8 @@ public final class ClusterContextManagerCoordinatorTest {
private Map<String, DataSource> initContextManager() {
Map<String, DataSource> result = getDataSourceMap();
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", result);
- ShardingSphereDatabase database = new ShardingSphereDatabase("db", new MySQLDatabaseType(), resource, mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", result);
+ ShardingSphereDatabase database = new ShardingSphereDatabase("db", new MySQLDatabaseType(), resourceMetaData, mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
contextManager.getMetaDataContexts().getMetaData().getDatabases().put("db", database);
return result;
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java
index ff69c09ef9a..b36179ea113 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java
@@ -200,7 +200,7 @@ public final class ProxySQLExecutor {
}
private List<ExecuteResult> getSaneExecuteResults(final ExecutionContext executionContext, final SQLException originalException) throws SQLException {
- DatabaseType databaseType = ProxyContext.getInstance().getDatabase(backendConnection.getConnectionSession().getDatabaseName()).getResource().getDatabaseType();
+ DatabaseType databaseType = ProxyContext.getInstance().getDatabase(backendConnection.getConnectionSession().getDatabaseName()).getResourceMetaData().getDatabaseType();
Optional<ExecuteResult> executeResult = SaneQueryResultEngineFactory.getInstance(databaseType)
.getSaneQueryResult(executionContext.getSqlStatementContext().getSqlStatement(), originalException);
if (executeResult.isPresent()) {
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ReactiveProxySQLExecutor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ReactiveProxySQLExecutor.java
index 542fec4490a..daf7e56d296 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ReactiveProxySQLExecutor.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ReactiveProxySQLExecutor.java
@@ -151,7 +151,7 @@ public final class ReactiveProxySQLExecutor {
}
private List<ExecuteResult> getSaneExecuteResults(final ExecutionContext executionContext, final SQLException originalException) throws SQLException {
- DatabaseType databaseType = ProxyContext.getInstance().getDatabase(backendConnection.getConnectionSession().getDatabaseName()).getResource().getDatabaseType();
+ DatabaseType databaseType = ProxyContext.getInstance().getDatabase(backendConnection.getConnectionSession().getDatabaseName()).getResourceMetaData().getDatabaseType();
Optional<ExecuteResult> executeResult = SaneQueryResultEngineFactory.getInstance(databaseType)
.getSaneQueryResult(executionContext.getSqlStatementContext().getSqlStatement(), originalException);
if (executeResult.isPresent()) {
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
index db0cbf6351d..8dd3bab3fc0 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
@@ -155,7 +155,7 @@ public final class JDBCDatabaseCommunicationEngine extends DatabaseCommunication
boolean isReturnGeneratedKeys = queryContext.getSqlStatementContext().getSqlStatement() instanceof MySQLInsertStatement;
ShardingSphereDatabase database = metaDataContexts.getMetaData().getDatabase(backendConnection.getConnectionSession().getDatabaseName());
DatabaseType protocolType = database.getProtocolType();
- DatabaseType databaseType = database.getResource().getDatabaseType();
+ DatabaseType databaseType = database.getResourceMetaData().getDatabaseType();
ProxyJDBCExecutorCallback callback = ProxyJDBCExecutorCallbackFactory.newInstance(getDriverType(), protocolType, databaseType,
queryContext.getSqlStatementContext().getSqlStatement(), this, isReturnGeneratedKeys, SQLExecutorExceptionHandler.isExceptionThrown(), true);
DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = createDriverExecutionPrepareEngine(isReturnGeneratedKeys, metaDataContexts);
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSource.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSource.java
index 72812e2af27..f015e828242 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSource.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSource.java
@@ -68,7 +68,7 @@ public final class JDBCBackendDataSource implements BackendDataSource {
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
public List<Connection> getConnections(final String databaseName, final String dataSourceName,
final int connectionSize, final ConnectionMode connectionMode, final TransactionType transactionType) throws SQLException {
- DataSource dataSource = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResource().getDataSources().get(dataSourceName);
+ DataSource dataSource = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResourceMetaData().getDataSources().get(dataSourceName);
if (dataSourceName.contains(".")) {
String dataSourceStr = dataSourceName.split("\\.")[0];
if (GlobalDataSourceRegistry.getInstance().getCachedDataSourceDataSources().containsKey(dataSourceStr)) {
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/ProxyJDBCExecutor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/ProxyJDBCExecutor.java
index bbb0b956953..03576f12ee8 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/ProxyJDBCExecutor.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/ProxyJDBCExecutor.java
@@ -68,7 +68,7 @@ public final class ProxyJDBCExecutor {
EventBusContext eventBusContext = ProxyContext.getInstance().getContextManager().getInstanceContext().getEventBusContext();
ShardingSphereDatabase database = metaDataContexts.getMetaData().getDatabase(connectionSession.getDatabaseName());
DatabaseType protocolType = database.getProtocolType();
- DatabaseType databaseType = database.getResource().getDatabaseType();
+ DatabaseType databaseType = database.getResourceMetaData().getDatabaseType();
ExecuteProcessEngine.initializeExecution(queryContext, executionGroupContext, eventBusContext);
SQLStatementContext<?> context = queryContext.getSqlStatementContext();
List<ExecuteResult> result = jdbcExecutor.execute(executionGroupContext,
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java
index b3009b02475..03404c62c66 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java
@@ -128,7 +128,7 @@ public final class VertxBackendDataSource implements BackendDataSource {
}
private Pool createPoolFromSchemaDataSource(final String databaseName, final String dataSourceName) {
- DataSource dataSource = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResource().getDataSources().get(dataSourceName);
+ DataSource dataSource = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResourceMetaData().getDataSources().get(dataSourceName);
Preconditions.checkNotNull(dataSource, "Can not get connection from datasource %s.", dataSourceName);
HikariDataSource value = (HikariDataSource) dataSource;
URI uri = URI.create(value.getJdbcUrl().replace("jdbc:", ""));
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/AbstractDatabaseMetadataExecutor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/AbstractDatabaseMetadataExecutor.java
index a475da55db7..1e237b33ca9 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/AbstractDatabaseMetadataExecutor.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/AbstractDatabaseMetadataExecutor.java
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.ra
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.type.memory.row.MemoryQueryResultDataRow;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.merge.result.impl.transparent.TransparentMergedResult;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -207,8 +207,8 @@ public abstract class AbstractDatabaseMetadataExecutor implements DatabaseAdminQ
*/
@Override
protected void getSourceData(final String databaseName, final FunctionWithException<ResultSet, SQLException> callback) throws SQLException {
- ShardingSphereResource resource = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResource();
- Optional<Entry<String, DataSource>> dataSourceEntry = resource.getDataSources().entrySet().stream().findFirst();
+ ShardingSphereResourceMetaData resourceMetaData = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResourceMetaData();
+ Optional<Entry<String, DataSource>> dataSourceEntry = resourceMetaData.getDataSources().entrySet().stream().findFirst();
log.info("Actual SQL: {} ::: {}", dataSourceEntry.orElseThrow(ResourceNotExistedException::new).getKey(), sql);
try (
Connection connection = dataSourceEntry.get().getValue().getConnection();
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/information/SelectInformationSchemataExecutor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/information/SelectInformationSchemataExecutor.java
index 6a46d5a69a7..72d7c096f93 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/information/SelectInformationSchemataExecutor.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/information/SelectInformationSchemataExecutor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.handler.admin.mysql.executor.information;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.handler.admin.executor.AbstractDatabaseMetadataExecutor;
@@ -94,8 +94,8 @@ public final class SelectInformationSchemataExecutor extends DefaultDatabaseMeta
@Override
protected void rowPostProcessing(final String databaseName, final Map<String, Object> rowMap, final Map<String, String> aliasMap) {
- ShardingSphereResource resource = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResource();
- Set<String> catalogs = resource.getDataSources().keySet().stream().map(each -> resource.getDataSourceMetaData(each).getCatalog()).collect(Collectors.toSet());
+ ShardingSphereResourceMetaData resourceMetaData = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResourceMetaData();
+ Set<String> catalogs = resourceMetaData.getDataSources().keySet().stream().map(each -> resourceMetaData.getDataSourceMetaData(each).getCatalog()).collect(Collectors.toSet());
schemaNameAlias = aliasMap.getOrDefault(SCHEMA_NAME, "");
String rowValue = rowMap.getOrDefault(schemaNameAlias, "").toString();
queryDatabase = !rowValue.isEmpty();
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectDatabaseExecutor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectDatabaseExecutor.java
index 265870f1d4c..0480eb72233 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectDatabaseExecutor.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectDatabaseExecutor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.handler.admin.postgresql.executor;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.handler.admin.executor.AbstractDatabaseMetadataExecutor;
@@ -87,8 +87,8 @@ public final class SelectDatabaseExecutor extends DefaultDatabaseMetadataExecuto
@Override
protected void rowPostProcessing(final String databaseName, final Map<String, Object> rowMap, final Map<String, String> aliasMap) {
buildColumnNames(aliasMap);
- ShardingSphereResource resource = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResource();
- Set<String> catalogs = resource.getDataSources().keySet().stream().map(each -> resource.getDataSourceMetaData(each).getCatalog()).collect(Collectors.toSet());
+ ShardingSphereResourceMetaData resourceMetaData = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResourceMetaData();
+ Set<String> catalogs = resourceMetaData.getDataSources().keySet().stream().map(each -> resourceMetaData.getDataSourceMetaData(each).getCatalog()).collect(Collectors.toSet());
databaseNameAlias = aliasMap.getOrDefault(DATABASE_NAME, aliasMap.getOrDefault(DATNAME, aliasMap.getOrDefault(NAME, "")));
String rowValue = rowMap.getOrDefault(databaseNameAlias, "").toString();
isQueryDatabase = !rowValue.isEmpty();
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectTableExecutor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectTableExecutor.java
index 6ab9566f918..1a86017165a 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectTableExecutor.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectTableExecutor.java
@@ -55,7 +55,7 @@ public final class SelectTableExecutor extends DefaultDatabaseMetadataExecutor {
@Override
protected void initDatabaseData(final String databaseName) {
ShardingSphereDatabase database = ProxyContext.getInstance().getDatabase(databaseName);
- String schemaName = DatabaseTypeEngine.getDefaultSchemaName(database.getResource().getDatabaseType(), databaseName);
+ String schemaName = DatabaseTypeEngine.getDefaultSchemaName(database.getResourceMetaData().getDatabaseType(), databaseName);
tableNames = new ArrayList<>(database.getSchema(schemaName).getAllTableNames());
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
index 4d05e78710d..d856d55c0d5 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
@@ -55,7 +55,7 @@ public final class DatabaseDiscoveryRuleConfigurationImportChecker {
private void checkResources(final String databaseName, final ShardingSphereDatabase database, final DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
Collection<String> requireResources = new LinkedHashSet<>();
currentRuleConfig.getDataSources().forEach(each -> requireResources.addAll(each.getDataSourceNames()));
- Collection<String> notExistResources = database.getResource().getNotExistedResources(requireResources);
+ Collection<String> notExistResources = database.getResourceMetaData().getNotExistedResources(requireResources);
ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistResources));
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportChecker.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportChecker.java
index d67e3209073..609a188d180 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportChecker.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportChecker.java
@@ -66,7 +66,7 @@ public final class ReadwriteSplittingRuleConfigurationImportChecker {
}
}
});
- Collection<String> notExistResources = database.getResource().getNotExistedResources(requireResources);
+ Collection<String> notExistResources = database.getResourceMetaData().getNotExistedResources(requireResources);
ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistResources));
Collection<String> logicResources = getLogicResources(database);
Collection<String> notExistLogicResources = requireDiscoverableResources.stream().filter(each -> !logicResources.contains(each)).collect(Collectors.toSet());
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
index b9cc7826252..b3a33628a90 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
@@ -121,7 +121,7 @@ public final class ShardingRuleConfigurationImportChecker {
private void checkResources(final String databaseName, final ShardingSphereDatabase database, final ShardingRuleConfiguration currentRuleConfig) {
Collection<String> requiredResource = getRequiredResources(currentRuleConfig);
- Collection<String> notExistedResources = database.getResource().getNotExistedResources(requiredResource);
+ Collection<String> notExistedResources = database.getResourceMetaData().getNotExistedResources(requiredResource);
Collection<String> logicResources = getLogicResources(database);
notExistedResources.removeIf(logicResources::contains);
ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistedResources));
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationHandler.java
index ccfaf94ad9c..57d67bc62cd 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationHandler.java
@@ -88,11 +88,11 @@ public final class ExportDatabaseConfigurationHandler extends QueryableRALBacken
}
private void appendDataSourceConfigurations(final ShardingSphereDatabase database, final StringBuilder stringBuilder) {
- if (database.getResource().getDataSources().isEmpty()) {
+ if (database.getResourceMetaData().getDataSources().isEmpty()) {
return;
}
stringBuilder.append("dataSources:").append(System.lineSeparator());
- for (Entry<String, DataSource> entry : database.getResource().getDataSources().entrySet()) {
+ for (Entry<String, DataSource> entry : database.getResourceMetaData().getDataSources().entrySet()) {
appendDataSourceConfiguration(entry.getKey(), entry.getValue(), stringBuilder);
}
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationHandler.java
index c67e7ba8103..7d0010eb611 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationHandler.java
@@ -106,7 +106,7 @@ public final class ImportDatabaseConfigurationHandler extends UpdatableRALBacken
private void checkDatabase(final String databaseName, final File file) {
Preconditions.checkNotNull(databaseName, "Property `databaseName` in file `%s` is required", file.getName());
if (ProxyContext.getInstance().databaseExists(databaseName)) {
- Preconditions.checkState(ProxyContext.getInstance().getDatabase(databaseName).getResource().getDataSources().isEmpty(), "Database `%s` exists and is not empty", databaseName);
+ Preconditions.checkState(ProxyContext.getInstance().getDatabase(databaseName).getResourceMetaData().getDataSources().isEmpty(), "Database `%s` exists and is not empty", databaseName);
}
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java
index 7bad407b29e..116465656fb 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java
@@ -123,7 +123,7 @@ public final class SetReadwriteSplittingStatusHandler extends UpdatableRALBacken
private void checkResourceExists(final ContextManager contextManager, final String databaseName, final String toBeDisabledResource) {
Collection<String> notExistedResources = contextManager
- .getMetaDataContexts().getMetaData().getDatabase(databaseName).getResource().getNotExistedResources(Collections.singleton(toBeDisabledResource));
+ .getMetaDataContexts().getMetaData().getDatabase(databaseName).getResourceMetaData().getNotExistedResources(Collections.singleton(toBeDisabledResource));
ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, Collections.singleton(toBeDisabledResource)));
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AddResourceBackendHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AddResourceBackendHandler.java
index 39be51f0e13..7e17ba3442c 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AddResourceBackendHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AddResourceBackendHandler.java
@@ -61,7 +61,7 @@ public final class AddResourceBackendHandler extends DatabaseRequiredBackendHand
public ResponseHeader execute(final String databaseName, final AddResourceStatement sqlStatement) {
checkSQLStatement(databaseName, sqlStatement);
Map<String, DataSourceProperties> dataSourcePropsMap = ResourceSegmentsConverter.convert(databaseType, sqlStatement.getDataSources());
- DatabaseType storeType = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResource().getDatabaseType();
+ DatabaseType storeType = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResourceMetaData().getDatabaseType();
validator.validate(dataSourcePropsMap, storeType);
try {
ProxyContext.getInstance().getContextManager().addResources(databaseName, dataSourcePropsMap);
@@ -76,7 +76,7 @@ public final class AddResourceBackendHandler extends DatabaseRequiredBackendHand
Collection<String> dataSourceNames = new ArrayList<>(sqlStatement.getDataSources().size());
Collection<String> duplicateDataSourceNames = new HashSet<>(sqlStatement.getDataSources().size(), 1);
for (DataSourceSegment each : sqlStatement.getDataSources()) {
- if (dataSourceNames.contains(each.getName()) || ProxyContext.getInstance().getDatabase(databaseName).getResource().getDataSources().containsKey(each.getName())) {
+ if (dataSourceNames.contains(each.getName()) || ProxyContext.getInstance().getDatabase(databaseName).getResourceMetaData().getDataSources().containsKey(each.getName())) {
duplicateDataSourceNames.add(each.getName());
}
dataSourceNames.add(each.getName());
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandler.java
index c9e470b7793..2708a44fb8c 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandler.java
@@ -86,7 +86,7 @@ public final class AlterResourceBackendHandler extends DatabaseRequiredBackendHa
}
private void checkDatabase(final String databaseName, final AlterResourceStatement sqlStatement) {
- Map<String, DataSource> resources = ProxyContext.getInstance().getDatabase(databaseName).getResource().getDataSources();
+ Map<String, DataSource> resources = ProxyContext.getInstance().getDatabase(databaseName).getResourceMetaData().getDataSources();
Collection<String> invalid = sqlStatement.getDataSources().stream().collect(Collectors.toMap(DataSourceSegment::getName, each -> each)).entrySet().stream()
.filter(each -> !isIdenticalDatabase(each.getValue(), resources.get(each.getKey()))).map(Entry::getKey).collect(Collectors.toSet());
ShardingSpherePreconditions.checkState(invalid.isEmpty(), () -> new InvalidResourcesException(Collections.singleton(String.format("Cannot alter the database of %s", invalid))));
@@ -106,7 +106,7 @@ public final class AlterResourceBackendHandler extends DatabaseRequiredBackendHa
}
private void checkResourceNameExisted(final String databaseName, final Collection<String> resourceNames) {
- Map<String, DataSource> resources = ProxyContext.getInstance().getDatabase(databaseName).getResource().getDataSources();
+ Map<String, DataSource> resources = ProxyContext.getInstance().getDatabase(databaseName).getResourceMetaData().getDataSources();
Collection<String> notExistedResourceNames = resourceNames.stream().filter(each -> !resources.containsKey(each)).collect(Collectors.toList());
ShardingSpherePreconditions.checkState(notExistedResourceNames.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistedResourceNames));
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/DropResourceBackendHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/DropResourceBackendHandler.java
index 4646a6e8ead..df02d1b9d8a 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/DropResourceBackendHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/DropResourceBackendHandler.java
@@ -77,7 +77,7 @@ public final class DropResourceBackendHandler extends DatabaseRequiredBackendHan
}
private void checkResourceNameExisted(final String databaseName, final Collection<String> resourceNames) {
- Map<String, DataSource> resources = ProxyContext.getInstance().getDatabase(databaseName).getResource().getDataSources();
+ Map<String, DataSource> resources = ProxyContext.getInstance().getDatabase(databaseName).getResourceMetaData().getDataSources();
Collection<String> notExistedResourceNames = resourceNames.stream().filter(each -> !resources.containsKey(each)).collect(Collectors.toList());
ShardingSpherePreconditions.checkState(notExistedResourceNames.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistedResourceNames));
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleStatementUpdater.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleStatementUpdater.java
index 530e3fc3837..0827aabdfb6 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleStatementUpdater.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleStatementUpdater.java
@@ -47,7 +47,7 @@ public final class AlterDefaultSingleTableRuleStatementUpdater implements RuleDe
}
private void checkResourceExist(final ShardingSphereDatabase database, final AlterDefaultSingleTableRuleStatement sqlStatement) {
- Set<String> resourceNames = database.getResource().getDataSources().keySet();
+ Set<String> resourceNames = database.getResourceMetaData().getDataSources().keySet();
ShardingSpherePreconditions.checkState(resourceNames.contains(sqlStatement.getDefaultResource()),
() -> new MissingRequiredResourcesException(database.getName(), Collections.singleton(sqlStatement.getDefaultResource())));
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleStatementUpdater.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleStatementUpdater.java
index a7d1f08249a..da83e8c4999 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleStatementUpdater.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleStatementUpdater.java
@@ -40,7 +40,7 @@ public final class CreateDefaultSingleTableRuleStatementUpdater implements RuleD
}
private void checkResourceExist(final ShardingSphereDatabase database, final CreateDefaultSingleTableRuleStatement sqlStatement) {
- Collection<String> resourceNames = database.getResource().getDataSources().keySet();
+ Collection<String> resourceNames = database.getResourceMetaData().getDataSources().keySet();
ShardingSpherePreconditions.checkState(resourceNames.contains(sqlStatement.getDefaultResource()),
() -> new MissingRequiredResourcesException(database.getName(), Collections.singleton(sqlStatement.getDefaultResource())));
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/resource/DataSourceQueryResultSet.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/resource/DataSourceQueryResultSet.java
index fe8dd94fda5..c9d5b9eb027 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/resource/DataSourceQueryResultSet.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/resource/DataSourceQueryResultSet.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
import org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesCreator;
import org.apache.shardingsphere.infra.distsql.query.DatabaseDistSQLResultSet;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import javax.sql.DataSource;
@@ -53,7 +53,7 @@ public final class DataSourceQueryResultSet implements DatabaseDistSQLResultSet
private static final String READ_ONLY = "readOnly";
- private ShardingSphereResource resource;
+ private ShardingSphereResourceMetaData resourceMetaData;
private Map<String, DataSourceProperties> dataSourcePropsMap;
@@ -61,9 +61,9 @@ public final class DataSourceQueryResultSet implements DatabaseDistSQLResultSet
@Override
public void init(final ShardingSphereDatabase database, final SQLStatement sqlStatement) {
- resource = database.getResource();
- dataSourcePropsMap = new LinkedHashMap<>(database.getResource().getDataSources().size(), 1);
- for (Entry<String, DataSource> entry : database.getResource().getDataSources().entrySet()) {
+ resourceMetaData = database.getResourceMetaData();
+ dataSourcePropsMap = new LinkedHashMap<>(database.getResourceMetaData().getDataSources().size(), 1);
+ for (Entry<String, DataSource> entry : database.getResourceMetaData().getDataSources().entrySet()) {
dataSourcePropsMap.put(entry.getKey(), DataSourcePropertiesCreator.create(entry.getValue()));
}
dataSourceNames = dataSourcePropsMap.keySet().iterator();
@@ -83,10 +83,10 @@ public final class DataSourceQueryResultSet implements DatabaseDistSQLResultSet
@Override
public Collection<Object> getRowData() {
String dataSourceName = dataSourceNames.next();
- DataSourceMetaData metaData = resource.getDataSourceMetaData(dataSourceName);
+ DataSourceMetaData metaData = resourceMetaData.getDataSourceMetaData(dataSourceName);
Collection<Object> result = new LinkedList<>();
result.add(dataSourceName);
- result.add(resource.getDatabaseType().getType());
+ result.add(resourceMetaData.getDatabaseType().getType());
result.add(metaData.getHostname());
result.add(metaData.getPort());
result.add(metaData.getCatalog());
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/resource/UnusedDataSourceQueryResultSet.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/resource/UnusedDataSourceQueryResultSet.java
index 4c452672b95..f7a3774795d 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/resource/UnusedDataSourceQueryResultSet.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/resource/UnusedDataSourceQueryResultSet.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
import org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesCreator;
import org.apache.shardingsphere.infra.distsql.query.DatabaseDistSQLResultSet;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
@@ -63,7 +63,7 @@ public final class UnusedDataSourceQueryResultSet implements DatabaseDistSQLResu
private static final String READ_ONLY = "readOnly";
- private ShardingSphereResource resource;
+ private ShardingSphereResourceMetaData resourceMetaData;
private Map<String, DataSourceProperties> dataSourcePropsMap;
@@ -71,10 +71,10 @@ public final class UnusedDataSourceQueryResultSet implements DatabaseDistSQLResu
@Override
public void init(final ShardingSphereDatabase database, final SQLStatement sqlStatement) {
- resource = database.getResource();
- dataSourcePropsMap = new LinkedHashMap<>(database.getResource().getDataSources().size(), 1);
+ resourceMetaData = database.getResourceMetaData();
+ dataSourcePropsMap = new LinkedHashMap<>(database.getResourceMetaData().getDataSources().size(), 1);
Multimap<String, String> inUsedMultiMap = getInUsedResources(database.getRuleMetaData());
- for (Entry<String, DataSource> entry : database.getResource().getDataSources().entrySet()) {
+ for (Entry<String, DataSource> entry : database.getResourceMetaData().getDataSources().entrySet()) {
if (inUsedMultiMap.containsKey(entry.getKey())) {
continue;
}
@@ -128,10 +128,10 @@ public final class UnusedDataSourceQueryResultSet implements DatabaseDistSQLResu
@Override
public Collection<Object> getRowData() {
String dataSourceName = dataSourceNames.next();
- DataSourceMetaData metaData = resource.getDataSourceMetaData(dataSourceName);
+ DataSourceMetaData metaData = resourceMetaData.getDataSourceMetaData(dataSourceName);
Collection<Object> result = new LinkedList<>();
result.add(dataSourceName);
- result.add(resource.getDatabaseType().getType());
+ result.add(resourceMetaData.getDatabaseType().getType());
result.add(metaData.getHostname());
result.add(metaData.getPort());
result.add(metaData.getCatalog());
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/rule/RulesUsedResourceQueryResultSet.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/rule/RulesUsedResourceQueryResultSet.java
index 3baff8b07a5..b9cee9cb440 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/rule/RulesUsedResourceQueryResultSet.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/rule/RulesUsedResourceQueryResultSet.java
@@ -66,7 +66,7 @@ public final class RulesUsedResourceQueryResultSet implements DatabaseDistSQLRes
List<Collection<Object>> data = new LinkedList<>();
ShowRulesUsedResourceStatement statement = (ShowRulesUsedResourceStatement) sqlStatement;
String resourceName = statement.getResourceName().orElse(null);
- if (database.getResource().getDataSources().containsKey(resourceName)) {
+ if (database.getResourceMetaData().getDataSources().containsKey(resourceName)) {
data.addAll(getShardingData(database));
data.addAll(getReadwriteSplittingData(database, resourceName));
data.addAll(getDatabaseDiscoveryData(database, resourceName));
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
index 97c7911d670..d21c9382e11 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
@@ -139,7 +139,7 @@ public final class PreviewHandler extends SQLRULBackendHandler<PreviewStatement>
boolean isReturnGeneratedKeys = sqlStatement instanceof MySQLInsertStatement;
DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = createDriverExecutionPrepareEngine(isReturnGeneratedKeys, metaDataContexts);
SQLFederationExecutorContext context = new SQLFederationExecutorContext(true, queryContext, metaDataContexts.getMetaData().getDatabases());
- DatabaseType databaseType = metaDataContexts.getMetaData().getDatabase(getDatabaseName()).getResource().getDatabaseType();
+ DatabaseType databaseType = metaDataContexts.getMetaData().getDatabase(getDatabaseName()).getResourceMetaData().getDatabaseType();
String schemaName = queryContext.getSqlStatementContext().getTablesContext().getSchemaName().orElseGet(() -> DatabaseTypeEngine.getDefaultSchemaName(databaseType, databaseName));
EventBusContext eventBusContext = ProxyContext.getInstance().getContextManager().getInstanceContext().getEventBusContext();
SQLFederationRule sqlFederationRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLFederationRule.class);
@@ -169,7 +169,7 @@ public final class PreviewHandler extends SQLRULBackendHandler<PreviewStatement>
return new DriverExecutionPrepareEngine<>(JDBCDriverType.STATEMENT, maxConnectionsSizePerQuery, (JDBCBackendConnection) getConnectionSession().getBackendConnection(),
(JDBCBackendStatement) getConnectionSession().getStatementManager(), new StatementOption(isReturnGeneratedKeys),
metaDataContexts.getMetaData().getDatabase(getDatabaseName()).getRuleMetaData().getRules(),
- metaDataContexts.getMetaData().getDatabase(getDatabaseName()).getResource().getDatabaseType());
+ metaDataContexts.getMetaData().getDatabase(getDatabaseName()).getResourceMetaData().getDatabaseType());
}
private String getDatabaseName() {
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
index 5c7dfad53b9..f4697610cc3 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
@@ -60,7 +60,7 @@ public final class DatabaseCommunicationEngineFactoryTest extends ProxyContextRe
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.containsDataSource()).thenReturn(true);
when(database.isComplete()).thenReturn(true);
- when(database.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new H2DatabaseType());
when(database.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1);
result.put("db", database);
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
index 44bd74eabe7..21c3719f9e6 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
@@ -126,7 +126,7 @@ public final class JDBCDatabaseCommunicationEngineTest extends ProxyContextResto
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.containsDataSource()).thenReturn(true);
when(database.isComplete()).thenReturn(true);
- when(database.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new H2DatabaseType());
when(database.getProtocolType()).thenReturn(new H2DatabaseType());
when(database.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1);
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnectionTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnectionTest.java
index fee46aad417..31b8d8d33e0 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnectionTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnectionTest.java
@@ -122,7 +122,7 @@ public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
for (int i = 0; i < 10; i++) {
String name = String.format(SCHEMA_PATTERN, i);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
result.put(name, database);
}
return result;
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSourceTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSourceTest.java
index aaa794e9599..2831abae486 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSourceTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSourceTest.java
@@ -77,8 +77,8 @@ public final class JDBCBackendDataSourceTest extends ProxyContextRestorer {
private Map<String, ShardingSphereDatabase> createDatabases() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("schema");
- when(database.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
- when(database.getResource().getDataSources()).thenReturn(mockDataSources(2));
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new H2DatabaseType());
+ when(database.getResourceMetaData().getDataSources()).thenReturn(mockDataSources(2));
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1);
result.put("schema", database);
return result;
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
index 864f63ec3bd..fb35307076c 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
@@ -125,7 +125,7 @@ public final class ProxyContextTest extends ProxyContextRestorer {
private Map<String, ShardingSphereDatabase> mockDatabases() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new H2DatabaseType());
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1);
result.put("db", database);
return result;
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/DatabaseAdminQueryBackendHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/DatabaseAdminQueryBackendHandlerTest.java
index fc508d95435..65229d6a657 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/DatabaseAdminQueryBackendHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/DatabaseAdminQueryBackendHandlerTest.java
@@ -74,7 +74,7 @@ public final class DatabaseAdminQueryBackendHandlerTest extends ProxyContextRest
private Map<String, ShardingSphereDatabase> getDatabases() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("db");
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(database.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1);
result.put("db", database);
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/DatabaseOperateBackendHandlerFactoryTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/DatabaseOperateBackendHandlerFactoryTest.java
index b998ada6244..0c5b9c64d76 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/DatabaseOperateBackendHandlerFactoryTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/DatabaseOperateBackendHandlerFactoryTest.java
@@ -136,7 +136,7 @@ public final class DatabaseOperateBackendHandlerFactoryTest extends ProxyContext
private Map<String, ShardingSphereDatabase> getDatabases() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(database.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1);
result.put("db", database);
@@ -153,8 +153,8 @@ public final class DatabaseOperateBackendHandlerFactoryTest extends ProxyContext
private MetaDataContexts mockMetaDataContexts() {
MetaDataContexts result = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
- when(result.getMetaData().getDatabase("db").getResource().getDataSources()).thenReturn(Collections.emptyMap());
- when(result.getMetaData().getDatabase("db").getResource().getNotExistedResources(any())).thenReturn(Collections.emptyList());
+ when(result.getMetaData().getDatabase("db").getResourceMetaData().getDataSources()).thenReturn(Collections.emptyMap());
+ when(result.getMetaData().getDatabase("db").getResourceMetaData().getNotExistedResources(any())).thenReturn(Collections.emptyList());
return result;
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/DefaultDatabaseMetadataExecutorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/DefaultDatabaseMetadataExecutorTest.java
index 75e5614132d..bad7b1d378c 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/DefaultDatabaseMetadataExecutorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/DefaultDatabaseMetadataExecutorTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.data.ShardingSphereData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -110,7 +110,7 @@ public final class DefaultDatabaseMetadataExecutorTest extends ProxyContextResto
private ShardingSphereDatabase createDatabase(final Map<String, String> expectedResultSetMap) throws SQLException {
return new ShardingSphereDatabase("auth_db", new MySQLDatabaseType(),
- new ShardingSphereResource("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource(mockConnection(expectedResultSetMap)))),
+ new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource(mockConnection(expectedResultSetMap)))),
mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/MySQLAdminExecutorCreatorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/MySQLAdminExecutorCreatorTest.java
index 1899a69179f..541e1b38d99 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/MySQLAdminExecutorCreatorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/MySQLAdminExecutorCreatorTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.data.ShardingSphereData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
@@ -259,8 +259,8 @@ public final class MySQLAdminExecutorCreatorTest extends ProxyContextRestorer {
@Test
public void assertCreateWithOtherSelectStatementForDatabaseName() {
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1);
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", Collections.singletonMap("ds", new MockedDataSource()));
- ShardingSphereDatabase database = new ShardingSphereDatabase("db_0", mock(DatabaseType.class), resource, mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("ds", new MockedDataSource()));
+ ShardingSphereDatabase database = new ShardingSphereDatabase("db_0", mock(DatabaseType.class), resourceMetaData, mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
result.put("db_0", database);
initProxyContext(result);
MySQLSelectStatement mySQLSelectStatement = mock(MySQLSelectStatement.class);
@@ -276,8 +276,8 @@ public final class MySQLAdminExecutorCreatorTest extends ProxyContextRestorer {
@Test
public void assertCreateWithOtherSelectStatementForNullDatabaseName() {
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1);
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", Collections.singletonMap("ds_0", new MockedDataSource()));
- ShardingSphereDatabase database = new ShardingSphereDatabase("db_0", mock(DatabaseType.class), resource, mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("ds_0", new MockedDataSource()));
+ ShardingSphereDatabase database = new ShardingSphereDatabase("db_0", mock(DatabaseType.class), resourceMetaData, mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
result.put("db_0", database);
initProxyContext(result);
MySQLSelectStatement mySQLSelectStatement = mock(MySQLSelectStatement.class);
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowCreateDatabaseExecutorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowCreateDatabaseExecutorTest.java
index 137a261d12b..c6fb71f17e0 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowCreateDatabaseExecutorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowCreateDatabaseExecutorTest.java
@@ -63,7 +63,7 @@ public final class ShowCreateDatabaseExecutorTest extends ProxyContextRestorer {
Map<String, ShardingSphereDatabase> result = new HashMap<>(10, 1);
for (int i = 0; i < 10; i++) {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
result.put(String.format(DATABASE_PATTERN, i), database);
}
return result;
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowDatabasesExecutorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowDatabasesExecutorTest.java
index fd83452ccce..395ca6ea3fb 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowDatabasesExecutorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowDatabasesExecutorTest.java
@@ -70,7 +70,7 @@ public final class ShowDatabasesExecutorTest extends ProxyContextRestorer {
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(10, 1);
for (int i = 0; i < 10; i++) {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(database.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
when(database.getName()).thenReturn(String.format(DATABASE_PATTERN, i));
result.put(String.format(DATABASE_PATTERN, i), database);
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowFunctionStatusExecutorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowFunctionStatusExecutorTest.java
index fd49f520bae..4b260c034bb 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowFunctionStatusExecutorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowFunctionStatusExecutorTest.java
@@ -67,7 +67,7 @@ public final class ShowFunctionStatusExecutorTest extends ProxyContextRestorer {
for (int i = 0; i < 10; i++) {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.isComplete()).thenReturn(false);
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
result.put(String.format(DATABASE_PATTERN, i), database);
}
return result;
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowProcedureStatusExecutorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowProcedureStatusExecutorTest.java
index 31311457963..6a5fa7c47ee 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowProcedureStatusExecutorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowProcedureStatusExecutorTest.java
@@ -64,7 +64,7 @@ public final class ShowProcedureStatusExecutorTest extends ProxyContextRestorer
for (int i = 0; i < 10; i++) {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.isComplete()).thenReturn(false);
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
result.put(String.format(DATABASE_PATTERN, i), database);
}
return result;
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowTablesExecutorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowTablesExecutorTest.java
index 3f042d61de7..6b00b9dbac4 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowTablesExecutorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/ShowTablesExecutorTest.java
@@ -82,7 +82,7 @@ public final class ShowTablesExecutorTest extends ProxyContextRestorer {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getSchema(String.format(DATABASE_PATTERN, 0))).thenReturn(schema);
when(database.isComplete()).thenReturn(true);
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
Map<String, ShardingSphereDatabase> result = new HashMap<>(2, 1);
result.put(String.format(DATABASE_PATTERN, 0), database);
ShardingSphereDatabase uncompletedDatabase = mock(ShardingSphereDatabase.class);
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/UseDatabaseExecutorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/UseDatabaseExecutorTest.java
index 4ef7b30bfda..a0fa4d605c4 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/UseDatabaseExecutorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/UseDatabaseExecutorTest.java
@@ -69,7 +69,7 @@ public final class UseDatabaseExecutorTest extends ProxyContextRestorer {
Map<String, ShardingSphereDatabase> result = new HashMap<>(10, 1);
for (int i = 0; i < 10; i++) {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new H2DatabaseType());
when(database.getRuleMetaData().getRules()).thenReturn(new LinkedList<>());
result.put(String.format(DATABASE_PATTERN, i), database);
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/information/SelectInformationSchemataExecutorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/information/SelectInformationSchemataExecutorTest.java
index fc5effba21c..0039e2a58a0 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/information/SelectInformationSchemataExecutorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/information/SelectInformationSchemataExecutorTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.data.ShardingSphereData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -135,16 +135,16 @@ public final class SelectInformationSchemataExecutorTest extends ProxyContextRes
assertThat(executor.getQueryResultMetaData().getColumnCount(), is(0));
}
- private ShardingSphereDatabase createDatabase(final String databaseName, final ShardingSphereResource resource) {
- return new ShardingSphereDatabase(databaseName, new MySQLDatabaseType(), resource, mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
+ private ShardingSphereDatabase createDatabase(final String databaseName, final ShardingSphereResourceMetaData resourceMetaData) {
+ return new ShardingSphereDatabase(databaseName, new MySQLDatabaseType(), resourceMetaData, mock(ShardingSphereRuleMetaData.class), Collections.emptyMap());
}
private ShardingSphereDatabase createDatabase(final String databaseName) {
- return createDatabase(databaseName, new ShardingSphereResource("sharding_db", Collections.emptyMap()));
+ return createDatabase(databaseName, new ShardingSphereResourceMetaData("sharding_db", Collections.emptyMap()));
}
private ShardingSphereDatabase createDatabase(final Map<String, String> expectedResultSetMap) throws SQLException {
- return createDatabase("auth_db", new ShardingSphereResource("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource(mockConnection(expectedResultSetMap)))));
+ return createDatabase("auth_db", new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource(mockConnection(expectedResultSetMap)))));
}
private Connection mockConnection(final Map<String, String> expectedResultSetMap) throws SQLException {
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectDatabaseExecutorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectDatabaseExecutorTest.java
index 601ac399a04..83ee577fcb8 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectDatabaseExecutorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectDatabaseExecutorTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseT
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.data.ShardingSphereData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
@@ -97,13 +97,14 @@ public final class SelectDatabaseExecutorTest extends ProxyContextRestorer {
private void addShardingDatabase() throws SQLException {
Map<String, ShardingSphereDatabase> databases = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabases();
databases.put("sharding_db", new ShardingSphereDatabase("sharding_db", new PostgreSQLDatabaseType(),
- new ShardingSphereResource("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource(mockConnection()))), mock(ShardingSphereRuleMetaData.class), Collections.emptyMap()));
+ new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource(mockConnection()))), mock(ShardingSphereRuleMetaData.class),
+ Collections.emptyMap()));
}
private void addEmptyDatabase() {
Map<String, ShardingSphereDatabase> databases = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabases();
databases.put("empty_db", new ShardingSphereDatabase("empty_db", new PostgreSQLDatabaseType(),
- new ShardingSphereResource("sharding_db", Collections.emptyMap()), new ShardingSphereRuleMetaData(Collections.emptyList()), Collections.emptyMap()));
+ new ShardingSphereResourceMetaData("sharding_db", Collections.emptyMap()), new ShardingSphereRuleMetaData(Collections.emptyList()), Collections.emptyMap()));
}
private Connection mockConnection() throws SQLException {
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectTableExecutorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectTableExecutorTest.java
index db26aa5041a..fe196934792 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectTableExecutorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/postgresql/executor/SelectTableExecutorTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseT
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.data.ShardingSphereData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereTable;
@@ -88,7 +88,8 @@ public final class SelectTableExecutorTest extends ProxyContextRestorer {
}
private ShardingSphereDatabase createDatabase() throws SQLException {
- return new ShardingSphereDatabase("public", new PostgreSQLDatabaseType(), new ShardingSphereResource("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource(mockConnection()))),
+ return new ShardingSphereDatabase("public", new PostgreSQLDatabaseType(),
+ new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource(mockConnection()))),
new ShardingSphereRuleMetaData(Collections.emptyList()), Collections.singletonMap("public",
new ShardingSphereSchema(Collections.singletonMap("t_order", mock(ShardingSphereTable.class)), Collections.emptyMap())));
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandlerTest.java
index 4a8a5cd5509..b6424221b12 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandlerTest.java
@@ -98,7 +98,7 @@ public final class UnicastDatabaseBackendHandlerTest extends ProxyContextRestore
for (int i = 0; i < 10; i++) {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.containsDataSource()).thenReturn(true);
- when(database.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new H2DatabaseType());
result.put(String.format(DATABASE_PATTERN, i), database);
}
return result;
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
index 7177c4060ce..5340e019e97 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRul
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.data.ShardingSphereData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
@@ -92,7 +92,7 @@ public final class DistSQLBackendHandlerFactoryTest extends ProxyContextRestorer
private Map<String, ShardingSphereDatabase> getDatabases() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1);
result.put("db", database);
return result;
@@ -246,9 +246,9 @@ public final class DistSQLBackendHandlerFactoryTest extends ProxyContextRestorer
private MetaDataContexts mockMetaDataContexts() {
MetaDataContexts result = mock(MetaDataContexts.class, RETURNS_DEEP_STUBS);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
- when(database.getResource().getDataSources()).thenReturn(Collections.emptyMap());
- when(database.getResource().getNotExistedResources(any())).thenReturn(Collections.emptyList());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDataSources()).thenReturn(Collections.emptyMap());
+ when(database.getResourceMetaData().getNotExistedResources(any())).thenReturn(Collections.emptyList());
when(database.getRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.emptyList()));
when(result.getMetaData().containsDatabase("db")).thenReturn(true);
when(result.getMetaData().getDatabase("db")).thenReturn(database);
@@ -259,7 +259,7 @@ public final class DistSQLBackendHandlerFactoryTest extends ProxyContextRestorer
MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("db");
- when(database.getResource()).thenReturn(mock(ShardingSphereResource.class));
+ when(database.getResourceMetaData()).thenReturn(mock(ShardingSphereResourceMetaData.class));
ShardingSphereRuleMetaData ruleMetaData = mock(ShardingSphereRuleMetaData.class);
when(ruleMetaData.getConfigurations()).thenReturn(Collections.singleton(mock(ShadowRuleConfiguration.class)));
when(database.getRuleMetaData()).thenReturn(ruleMetaData);
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationHandlerTest.java
index ce1779c1446..dc3db13fbbb 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationHandlerTest.java
@@ -88,7 +88,7 @@ public final class ExportDatabaseConfigurationHandlerTest extends ProxyContextRe
private ShardingSphereDatabase createNormalDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(result.getResource().getDataSources()).thenReturn(createDataSourceMap());
+ when(result.getResourceMetaData().getDataSources()).thenReturn(createDataSourceMap());
when(result.getRuleMetaData().getConfigurations()).thenReturn(Collections.singleton(createShardingRuleConfiguration()));
when(result.getSchema("normal_db")).thenReturn(new ShardingSphereSchema(createTables(), Collections.emptyMap()));
return result;
@@ -141,7 +141,7 @@ public final class ExportDatabaseConfigurationHandlerTest extends ProxyContextRe
private ShardingSphereDatabase createEmptyDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(result.getResource().getDataSources()).thenReturn(Collections.emptyMap());
+ when(result.getResourceMetaData().getDataSources()).thenReturn(Collections.emptyMap());
when(result.getRuleMetaData().getConfigurations()).thenReturn(Collections.emptyList());
return result;
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationHandlerTest.java
index ae746c61690..b76c30f0a97 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationHandlerTest.java
@@ -137,7 +137,7 @@ public final class ImportDatabaseConfigurationHandlerTest extends ProxyContextRe
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getSchema(DefaultDatabase.LOGIC_NAME)).thenReturn(new ShardingSphereSchema(createTableMap(), Collections.emptyMap()));
- when(database.getResource().getDataSources()).thenReturn(createDataSourceMap());
+ when(database.getResourceMetaData().getDataSources()).thenReturn(createDataSourceMap());
when(contextManager.getMetaDataContexts().getMetaData().getDatabases()).thenReturn(Collections.singletonMap(feature, database));
when(contextManager.getMetaDataContexts().getMetaData().getDatabase(feature)).thenReturn(database);
when(contextManager.getMetaDataContexts().getMetaData().containsDatabase(feature)).thenReturn(true);
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetVariableBackendHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetVariableBackendHandlerTest.java
index 4769cdb5fbc..4643b5113b9 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetVariableBackendHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetVariableBackendHandlerTest.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.data.ShardingSphereData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -77,7 +77,7 @@ public final class SetVariableBackendHandlerTest extends ProxyContextRestorer {
Map<String, ShardingSphereDatabase> result = new HashMap<>(10, 1);
for (int i = 0; i < 10; i++) {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource()).thenReturn(new ShardingSphereResource("sharding_db", Collections.emptyMap()));
+ when(database.getResourceMetaData()).thenReturn(new ShardingSphereResourceMetaData("sharding_db", Collections.emptyMap()));
when(database.getRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.emptyList()));
when(database.getSchema(DefaultDatabase.LOGIC_NAME)).thenReturn(mock(ShardingSphereSchema.class));
result.put(String.format(DATABASE_PATTERN, i), database);
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AddResourceBackendHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AddResourceBackendHandlerTest.java
index ba722fbd534..03a5e526aac 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AddResourceBackendHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AddResourceBackendHandlerTest.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesValidator;
import org.apache.shardingsphere.infra.distsql.exception.resource.DuplicateResourceException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -71,7 +71,7 @@ public final class AddResourceBackendHandlerTest extends ProxyContextRestorer {
private ShardingSphereDatabase database;
@Mock
- private ShardingSphereResource resource;
+ private ShardingSphereResourceMetaData resourceMetaData;
private AddResourceBackendHandler addResourceBackendHandler;
@@ -92,8 +92,8 @@ public final class AddResourceBackendHandlerTest extends ProxyContextRestorer {
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
ProxyContext.init(contextManager);
when(metaDataContexts.getMetaData().getDatabases()).thenReturn(Collections.singletonMap("test_db", database));
- when(database.getResource()).thenReturn(resource);
- when(resource.getDataSources()).thenReturn(Collections.emptyMap());
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
+ when(resourceMetaData.getDataSources()).thenReturn(Collections.emptyMap());
ResponseHeader responseHeader = addResourceBackendHandler.execute("test_db", createAddResourceStatement());
assertThat(responseHeader, instanceOf(UpdateResponseHeader.class));
}
@@ -104,8 +104,8 @@ public final class AddResourceBackendHandlerTest extends ProxyContextRestorer {
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
ProxyContext.init(contextManager);
when(metaDataContexts.getMetaData().getDatabases()).thenReturn(Collections.singletonMap("test_db", database));
- when(database.getResource()).thenReturn(resource);
- when(resource.getDataSources()).thenReturn(Collections.emptyMap());
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
+ when(resourceMetaData.getDataSources()).thenReturn(Collections.emptyMap());
addResourceBackendHandler.execute("test_db", createAlterResourceStatementWithDuplicateResourceNames());
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandlerTest.java
index 95e37d1f263..a4a8476694d 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandlerTest.java
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.infra.distsql.exception.resource.DuplicateResou
import org.apache.shardingsphere.infra.distsql.exception.resource.InvalidResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -75,7 +75,7 @@ public final class AlterResourceBackendHandlerTest extends ProxyContextRestorer
private ShardingSphereDatabase database;
@Mock
- private ShardingSphereResource resource;
+ private ShardingSphereResourceMetaData resourceMetaData;
@Mock
private DataSource dataSource;
@@ -98,8 +98,8 @@ public final class AlterResourceBackendHandlerTest extends ProxyContextRestorer
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
ProxyContext.init(contextManager);
- when(database.getResource()).thenReturn(resource);
- when(resource.getDataSources()).thenReturn(Collections.singletonMap("ds_0", mockHikariDataSource("ds_0")));
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
+ when(resourceMetaData.getDataSources()).thenReturn(Collections.singletonMap("ds_0", mockHikariDataSource("ds_0")));
assertThat(alterResourceBackendHandler.execute("test_db", createAlterResourceStatement("ds_0")), instanceOf(UpdateResponseHeader.class));
}
@@ -114,8 +114,8 @@ public final class AlterResourceBackendHandlerTest extends ProxyContextRestorer
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
ProxyContext.init(contextManager);
when(metaDataContexts.getMetaData().getDatabases()).thenReturn(Collections.singletonMap("test_db", database));
- when(database.getResource()).thenReturn(resource);
- when(resource.getDataSources()).thenReturn(Collections.singletonMap("ds_0", dataSource));
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
+ when(resourceMetaData.getDataSources()).thenReturn(Collections.singletonMap("ds_0", dataSource));
alterResourceBackendHandler.execute("test_db", createAlterResourceStatement("not_existed"));
}
@@ -124,8 +124,8 @@ public final class AlterResourceBackendHandlerTest extends ProxyContextRestorer
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
ProxyContext.init(contextManager);
- when(database.getResource()).thenReturn(resource);
- when(resource.getDataSources()).thenReturn(Collections.singletonMap("ds_0", mockHikariDataSource("ds_1")));
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
+ when(resourceMetaData.getDataSources()).thenReturn(Collections.singletonMap("ds_0", mockHikariDataSource("ds_1")));
ResponseHeader responseHeader = alterResourceBackendHandler.execute("test_db", createAlterResourceStatement("ds_0"));
assertThat(responseHeader, instanceOf(UpdateResponseHeader.class));
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/DropResourceBackendHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/DropResourceBackendHandlerTest.java
index 514535429a4..336b51a1c17 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/DropResourceBackendHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/DropResourceBackendHandlerTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.resource.ResourceInUsedException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
@@ -63,7 +63,7 @@ public final class DropResourceBackendHandlerTest extends ProxyContextRestorer {
private ShardingSphereDatabase database;
@Mock
- private ShardingSphereResource resource;
+ private ShardingSphereResourceMetaData resourceMetaData;
@Mock
private DataSource dataSource;
@@ -83,10 +83,10 @@ public final class DropResourceBackendHandlerTest extends ProxyContextRestorer {
@Before
public void setUp() {
- resource = mock(ShardingSphereResource.class, RETURNS_DEEP_STUBS);
- when(resource.getDataSources()).thenReturn(Collections.singletonMap("foo_ds", dataSource));
+ resourceMetaData = mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS);
+ when(resourceMetaData.getDataSources()).thenReturn(Collections.singletonMap("foo_ds", dataSource));
when(database.getRuleMetaData()).thenReturn(ruleMetaData);
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
MetaDataContexts metaDataContexts = mock(MetaDataContexts.class, RETURNS_DEEP_STUBS);
when(metaDataContexts.getMetaData().getDatabases()).thenReturn(Collections.singletonMap("test", database));
when(metaDataContexts.getMetaData().containsDatabase("test")).thenReturn(true);
@@ -99,8 +99,8 @@ public final class DropResourceBackendHandlerTest extends ProxyContextRestorer {
@Test
public void assertExecute() throws SQLException {
when(ruleMetaData.getRules()).thenReturn(Collections.emptyList());
- when(resource.getDataSources()).thenReturn(Collections.singletonMap("foo_ds", dataSource));
- when(database.getResource()).thenReturn(resource);
+ when(resourceMetaData.getDataSources()).thenReturn(Collections.singletonMap("foo_ds", dataSource));
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(contextManager.getMetaDataContexts().getMetaData().getDatabase("test")).thenReturn(database);
DropResourceStatement dropResourceStatement = new DropResourceStatement(Collections.singleton("foo_ds"), false);
assertThat(dropResourceBackendHandler.execute("test", dropResourceStatement), instanceOf(UpdateResponseHeader.class));
@@ -117,8 +117,8 @@ public final class DropResourceBackendHandlerTest extends ProxyContextRestorer {
when(ruleMetaData.getRules()).thenReturn(Collections.singleton(shadowRule));
when(shadowRule.getType()).thenReturn("ShadowRule");
when(shadowRule.getDataSourceMapper()).thenReturn(Collections.singletonMap("", Collections.singleton("foo_ds")));
- when(resource.getDataSources()).thenReturn(Collections.singletonMap("foo_ds", dataSource));
- when(database.getResource()).thenReturn(resource);
+ when(resourceMetaData.getDataSources()).thenReturn(Collections.singletonMap("foo_ds", dataSource));
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(contextManager.getMetaDataContexts().getMetaData().getDatabase("test")).thenReturn(database);
dropResourceBackendHandler.execute("test", new DropResourceStatement(Collections.singleton("foo_ds"), false));
}
@@ -130,8 +130,8 @@ public final class DropResourceBackendHandlerTest extends ProxyContextRestorer {
DataNode dataNode = mock(DataNode.class);
when(dataNode.getDataSourceName()).thenReturn("foo_ds");
when(singleTableRule.getAllDataNodes()).thenReturn(Collections.singletonMap("", Collections.singleton(dataNode)));
- when(resource.getDataSources()).thenReturn(Collections.singletonMap("foo_ds", dataSource));
- when(database.getResource()).thenReturn(resource);
+ when(resourceMetaData.getDataSources()).thenReturn(Collections.singletonMap("foo_ds", dataSource));
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(contextManager.getMetaDataContexts().getMetaData().getDatabase("test")).thenReturn(database);
dropResourceBackendHandler.execute("test", new DropResourceStatement(Collections.singleton("foo_ds"), false));
}
@@ -143,8 +143,8 @@ public final class DropResourceBackendHandlerTest extends ProxyContextRestorer {
DataNode dataNode = mock(DataNode.class);
when(dataNode.getDataSourceName()).thenReturn("foo_ds");
when(singleTableRule.getAllDataNodes()).thenReturn(Collections.singletonMap("", Collections.singleton(dataNode)));
- when(resource.getDataSources()).thenReturn(Collections.singletonMap("foo_ds", dataSource));
- when(database.getResource()).thenReturn(resource);
+ when(resourceMetaData.getDataSources()).thenReturn(Collections.singletonMap("foo_ds", dataSource));
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(contextManager.getMetaDataContexts().getMetaData().getDatabase("test")).thenReturn(database);
DropResourceStatement dropResourceStatement = new DropResourceStatement(Collections.singleton("foo_ds"), true);
assertThat(dropResourceBackendHandler.execute("test", dropResourceStatement), instanceOf(UpdateResponseHeader.class));
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleUpdaterTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleUpdaterTest.java
index c709b0aedf9..5ff2ccf1b49 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleUpdaterTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleUpdaterTest.java
@@ -52,7 +52,7 @@ public final class AlterDefaultSingleTableRuleUpdaterTest {
@Before
public void setUp() {
when(database.getName()).thenReturn("sharding_db");
- when(database.getResource().getDataSources()).thenReturn(Collections.singletonMap("ds_0", new MockedDataSource()));
+ when(database.getResourceMetaData().getDataSources()).thenReturn(Collections.singletonMap("ds_0", new MockedDataSource()));
}
@Test(expected = MissingRequiredRuleException.class)
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleUpdaterTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleUpdaterTest.java
index 9ab4f18d8ff..7e36cc7e9a0 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleUpdaterTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleUpdaterTest.java
@@ -52,7 +52,7 @@ public final class CreateDefaultSingleTableRuleUpdaterTest {
@Before
public void setUp() {
when(database.getName()).thenReturn("sharding_db");
- when(database.getResource().getDataSources()).thenReturn(Collections.singletonMap("ds_0", new MockedDataSource()));
+ when(database.getResourceMetaData().getDataSources()).thenReturn(Collections.singletonMap("ds_0", new MockedDataSource()));
}
@Test(expected = MissingRequiredResourcesException.class)
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/DropDefaultSingleTableRuleUpdaterTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/DropDefaultSingleTableRuleUpdaterTest.java
index e535c8fd139..a8532e89ab9 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/DropDefaultSingleTableRuleUpdaterTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/DropDefaultSingleTableRuleUpdaterTest.java
@@ -45,7 +45,7 @@ public final class DropDefaultSingleTableRuleUpdaterTest {
@Before
public void setUp() {
when(database.getName()).thenReturn("sharding_db");
- when(database.getResource().getDataSources()).thenReturn(Collections.singletonMap("ds_0", new MockedDataSource()));
+ when(database.getResourceMetaData().getDataSources()).thenReturn(Collections.singletonMap("ds_0", new MockedDataSource()));
}
@Test(expected = MissingRequiredRuleException.class)
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/DataSourceQueryResultSetTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/DataSourceQueryResultSetTest.java
index ec7aeaf494a..e6cd79255d5 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/DataSourceQueryResultSetTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/DataSourceQueryResultSetTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.rql;
import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowResourcesStatement;
import org.apache.shardingsphere.infra.distsql.query.DatabaseDistSQLResultSet;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.proxy.backend.handler.distsql.rql.resource.DataSourceQueryResultSet;
import org.apache.shardingsphere.test.mock.MockedDataSource;
import org.junit.Before;
@@ -46,8 +46,8 @@ public final class DataSourceQueryResultSetTest {
@Before
public void before() {
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", Collections.singletonMap("foo_ds", createDataSource()));
- when(database.getResource()).thenReturn(resource);
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("foo_ds", createDataSource()));
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
}
private MockedDataSource createDataSource() {
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RulesUsedResourceQueryResultSetTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RulesUsedResourceQueryResultSetTest.java
index 21915d02e4f..ea7a35ad6ff 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RulesUsedResourceQueryResultSetTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RulesUsedResourceQueryResultSetTest.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.infra.distsql.query.DatabaseDistSQLResultSet;
import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.proxy.backend.handler.distsql.rql.rule.RulesUsedResourceQueryResultSet;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
@@ -78,8 +78,8 @@ public final class RulesUsedResourceQueryResultSetTest {
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(
Arrays.asList(mockShardingRule(), mockReadwriteSplittingRule(), mockDatabaseDiscoveryRule(), mockEncryptRule(), mockShadowRule()));
when(result.getRuleMetaData()).thenReturn(ruleMetaData);
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource()));
- when(result.getResource()).thenReturn(resource);
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource()));
+ when(result.getResourceMetaData()).thenReturn(resourceMetaData);
return result;
}
@@ -181,8 +181,8 @@ public final class RulesUsedResourceQueryResultSetTest {
private ShardingSphereDatabase mockEmptyDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class);
when(result.getRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.emptyList()));
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", Collections.singletonMap("empty_ds", new MockedDataSource()));
- when(result.getResource()).thenReturn(resource);
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", Collections.singletonMap("empty_ds", new MockedDataSource()));
+ when(result.getResourceMetaData()).thenReturn(resourceMetaData);
return result;
}
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/UnusedDataSourceQueryResultSetTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/UnusedDataSourceQueryResultSetTest.java
index b5362be9f93..e99a74ff9e4 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/UnusedDataSourceQueryResultSetTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/UnusedDataSourceQueryResultSetTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowUnusedRes
import org.apache.shardingsphere.infra.distsql.query.DatabaseDistSQLResultSet;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.proxy.backend.handler.distsql.rql.resource.UnusedDataSourceQueryResultSet;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -57,9 +57,9 @@ public final class UnusedDataSourceQueryResultSetTest {
@Before
public void before() {
- ShardingSphereResource resource = new ShardingSphereResource("sharding_db", createDataSources());
+ ShardingSphereResourceMetaData resourceMetaData = new ShardingSphereResourceMetaData("sharding_db", createDataSources());
ShardingSphereRuleMetaData metaData = new ShardingSphereRuleMetaData(Collections.singleton(createShardingRule()));
- when(database.getResource()).thenReturn(resource);
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(database.getRuleMetaData()).thenReturn(metaData);
}
diff --git a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/protocol/FrontDatabaseProtocolTypeFactory.java b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/protocol/FrontDatabaseProtocolTypeFactory.java
index f871320805e..7e78cafaf53 100644
--- a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/protocol/FrontDatabaseProtocolTypeFactory.java
+++ b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/protocol/FrontDatabaseProtocolTypeFactory.java
@@ -51,7 +51,7 @@ public final class FrontDatabaseProtocolTypeFactory {
return DatabaseTypeEngine.getTrunkDatabaseType(DEFAULT_FRONTEND_DATABASE_PROTOCOL_TYPE);
}
Optional<ShardingSphereDatabase> database = metaDataContexts.getMetaData().getDatabases().values().stream().filter(ShardingSphereDatabase::containsDataSource).findFirst();
- return database.isPresent() ? database.get().getResource().getDatabaseType() : DatabaseTypeEngine.getTrunkDatabaseType(DEFAULT_FRONTEND_DATABASE_PROTOCOL_TYPE);
+ return database.isPresent() ? database.get().getResourceMetaData().getDatabaseType() : DatabaseTypeEngine.getTrunkDatabaseType(DEFAULT_FRONTEND_DATABASE_PROTOCOL_TYPE);
}
private static Optional<DatabaseType> findConfiguredDatabaseType() {
diff --git a/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/protocol/FrontDatabaseProtocolTypeFactoryTest.java b/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/protocol/FrontDatabaseProtocolTypeFactoryTest.java
index e6d3aa721b3..2f1931803c0 100644
--- a/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/protocol/FrontDatabaseProtocolTypeFactoryTest.java
+++ b/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/protocol/FrontDatabaseProtocolTypeFactoryTest.java
@@ -85,7 +85,7 @@ public final class FrontDatabaseProtocolTypeFactoryTest extends ProxyContextRest
DatabaseType databaseType = FrontDatabaseProtocolTypeFactory.getDatabaseType();
assertThat(databaseType, instanceOf(DatabaseType.class));
assertThat(databaseType.getType(), is("PostgreSQL"));
- assertThat(metaDataContexts.getMetaData().getDatabase(DefaultDatabase.LOGIC_NAME).getResource().getDatabaseType(), instanceOf(MySQLDatabaseType.class));
+ assertThat(metaDataContexts.getMetaData().getDatabase(DefaultDatabase.LOGIC_NAME).getResourceMetaData().getDatabaseType(), instanceOf(MySQLDatabaseType.class));
}
private Properties createProperties() {
@@ -96,7 +96,7 @@ public final class FrontDatabaseProtocolTypeFactoryTest extends ProxyContextRest
private Map<String, ShardingSphereDatabase> mockDatabases() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1);
result.put(DefaultDatabase.LOGIC_NAME, database);
return result;
diff --git a/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandler.java b/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandler.java
index 96c56aee815..9cec6009e95 100644
--- a/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandler.java
+++ b/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandler.java
@@ -166,7 +166,7 @@ public final class MySQLMultiStatementsHandler implements ProxyBackendHandler {
private UpdateResponseHeader executeBatchedStatements(final ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext) throws SQLException {
boolean isExceptionThrown = SQLExecutorExceptionHandler.isExceptionThrown();
- DatabaseType databaseType = metaDataContexts.getMetaData().getDatabase(connectionSession.getDatabaseName()).getResource().getDatabaseType();
+ DatabaseType databaseType = metaDataContexts.getMetaData().getDatabase(connectionSession.getDatabaseName()).getResourceMetaData().getDatabaseType();
JDBCExecutorCallback<int[]> callback = new BatchedJDBCExecutorCallback(databaseType, sqlStatementSample, isExceptionThrown);
List<int[]> executeResults = jdbcExecutor.execute(executionGroupContext, callback);
int updated = 0;
diff --git a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
index 86798e6f348..afaece6ca44 100644
--- a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
+++ b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
@@ -182,7 +182,7 @@ public final class MySQLFrontendEngineTest extends ProxyContextRestorer {
Map<String, ShardingSphereDatabase> result = new HashMap<>(10, 1);
for (int i = 0; i < 10; i++) {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
result.put(String.format(SCHEMA_PATTERN, i), database);
}
return result;
diff --git a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
index 68506cb59bd..9f0be2a3b3b 100644
--- a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
+++ b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
@@ -100,7 +100,7 @@ public final class MySQLCommandExecutorFactoryTest extends ProxyContextRestorer
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
- when(result.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(result.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(result.getProtocolType()).thenReturn(new MySQLDatabaseType());
return result;
}
diff --git a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
index 88af659c848..aed6326f968 100644
--- a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
+++ b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
@@ -132,7 +132,7 @@ public final class MySQLComStmtExecuteExecutorTest extends ProxyContextRestorer
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
- when(result.getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(result.getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(result.getProtocolType()).thenReturn(new MySQLDatabaseType());
return result;
}
diff --git a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
index 0d3ab7ce23b..1c1f2309d8d 100644
--- a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
+++ b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
@@ -110,7 +110,7 @@ public final class MySQLComQueryPacketExecutorTest {
try (MockedStatic<ProxyContext> mockedStatic = mockStatic(ProxyContext.class)) {
ProxyContext mockedProxyContext = mock(ProxyContext.class, RETURNS_DEEP_STUBS);
mockedStatic.when(ProxyContext::getInstance).thenReturn(mockedProxyContext);
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase("db_name").getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase("db_name").getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase("db_name").getProtocolType()).thenReturn(new MySQLDatabaseType());
ShardingSphereRuleMetaData globalRuleMetaData = mock(ShardingSphereRuleMetaData.class);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(globalRuleMetaData);
diff --git a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
index 4f052c2280f..f8f1734bf24 100644
--- a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
+++ b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
@@ -88,7 +88,7 @@ public final class MySQLMultiStatementsHandlerTest {
MySQLUpdateStatement expectedStatement = mock(MySQLUpdateStatement.class);
try (MockedStatic<ProxyContext> mockedStatic = mockStatic(ProxyContext.class)) {
mockedStatic.when(ProxyContext::getInstance).thenReturn(proxyContext);
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase("").getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
+ when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase("").getResourceMetaData().getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase("").getProtocolType()).thenReturn(new MySQLDatabaseType());
ShardingSphereRuleMetaData globalRuleMetaData = mock(ShardingSphereRuleMetaData.class);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(globalRuleMetaData);
diff --git a/proxy/frontend/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java b/proxy/frontend/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
index 9c3a95b8e96..345003b4c9a 100644
--- a/proxy/frontend/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
+++ b/proxy/frontend/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
@@ -36,7 +36,7 @@ import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.data.ShardingSphereData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
@@ -132,7 +132,7 @@ public final class OpenGaussAuthenticationHandlerTest extends ProxyContextRestor
for (int i = 0; i < 10; i++) {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
- when(database.getResource()).thenReturn(new ShardingSphereResource("sharding_db", Collections.emptyMap()));
+ when(database.getResourceMetaData()).thenReturn(new ShardingSphereResourceMetaData("sharding_db", Collections.emptyMap()));
when(database.getRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.emptyList()));
when(database.getSchema(DefaultDatabase.LOGIC_NAME)).thenReturn(schema);
when(schema.getTables()).thenReturn(Collections.emptyMap());
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortal.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortal.java
index 9a2a54c9ce0..ce899f718ba 100644
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortal.java
+++ b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortal.java
@@ -104,7 +104,7 @@ public final class JDBCPortal implements Portal<Void> {
private static DatabaseType getDatabaseType(final String databaseName) {
ShardingSphereDatabase database = ProxyContext.getInstance().getDatabase(databaseName);
- return null != database.getResource().getDatabaseType() ? database.getResource().getDatabaseType() : database.getProtocolType();
+ return null != database.getResourceMetaData().getDatabaseType() ? database.getResourceMetaData().getDatabaseType() : database.getProtocolType();
}
@SneakyThrows(SQLException.class)
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutor.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutor.java
index 65bb95b282f..0ae3cd38033 100644
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutor.java
+++ b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutor.java
@@ -176,7 +176,7 @@ public final class PostgreSQLBatchedStatementsExecutor {
private int executeBatchedPreparedStatements() throws SQLException {
boolean isExceptionThrown = SQLExecutorExceptionHandler.isExceptionThrown();
ShardingSphereDatabase database = metaDataContexts.getMetaData().getDatabase(connectionSession.getDatabaseName());
- DatabaseType databaseType = database.getResource().getDatabaseType();
+ DatabaseType databaseType = database.getResourceMetaData().getDatabaseType();
DatabaseType protocolType = database.getProtocolType();
JDBCExecutorCallback<int[]> callback = new BatchedStatementsJDBCExecutorCallback(protocolType, databaseType, preparedStatement.getSqlStatement(), isExceptionThrown);
List<int[]> executeResults = jdbcExecutor.execute(executionGroupContext, callback);
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
index 4665d7283c6..fff71163a1a 100644
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
+++ b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
@@ -132,7 +132,7 @@ public final class PostgreSQLComDescribeExecutor implements CommandExecutor {
String logicTableName = insertStatement.getTable().getTableName().getIdentifier().getValue();
ShardingSphereDatabase database = ProxyContext.getInstance().getDatabase(databaseName);
String schemaName = insertStatement.getTable().getOwner().map(optional -> optional.getIdentifier()
- .getValue()).orElseGet(() -> DatabaseTypeEngine.getDefaultSchemaName(database.getResource().getDatabaseType(), databaseName));
+ .getValue()).orElseGet(() -> DatabaseTypeEngine.getDefaultSchemaName(database.getResourceMetaData().getDatabaseType(), databaseName));
ShardingSphereTable table = database.getSchema(schemaName).getTable(logicTableName);
Map<String, ShardingSphereColumn> columns = table.getColumns();
Map<String, ShardingSphereColumn> caseInsensitiveColumns = null;
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
index 95750b3447d..36d16b49fea 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
@@ -36,7 +36,7 @@ import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.data.ShardingSphereData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
@@ -139,7 +139,7 @@ public final class PostgreSQLAuthenticationHandlerTest extends ProxyContextResto
for (int i = 0; i < 10; i++) {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
- when(database.getResource()).thenReturn(new ShardingSphereResource("sharding_db", Collections.emptyMap()));
+ when(database.getResourceMetaData()).thenReturn(new ShardingSphereResourceMetaData("sharding_db", Collections.emptyMap()));
when(database.getRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.emptyList()));
when(database.getSchema(DefaultDatabase.LOGIC_NAME)).thenReturn(schema);
when(schema.getTables()).thenReturn(Collections.emptyMap());
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortalTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortalTest.java
index a56aa9759a2..3e05602b13c 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortalTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortalTest.java
@@ -106,7 +106,7 @@ public final class JDBCPortalTest extends ProxyContextRestorer {
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.SQL_SHOW)).thenReturn(false);
when(connectionSession.getDefaultDatabaseName()).thenReturn("db");
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
- when(database.getResource().getDatabaseType()).thenReturn(new PostgreSQLDatabaseType());
+ when(database.getResourceMetaData().getDatabaseType()).thenReturn(new PostgreSQLDatabaseType());
when(ProxyContext.getInstance().getDatabase("db")).thenReturn(database);
when(backendConnection.getConnectionSession()).thenReturn(connectionSession);
mockedStatic = mockStatic(ProxyBackendHandlerFactory.class);
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
index c3ee0a05616..91253791a91 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
@@ -127,7 +127,7 @@ public final class PostgreSQLComDescribeExecutorTest extends ProxyContextRestore
new ShardingSphereColumn("pad", Types.CHAR, true, false, false, true));
ShardingSphereTable table = new ShardingSphereTable(TABLE_NAME, columnMetaData, Collections.emptyList(), Collections.emptyList());
when(contextManager.getMetaDataContexts().getMetaData().getDatabase(DATABASE_NAME).getSchema("public").getTable(TABLE_NAME)).thenReturn(table);
- when(contextManager.getMetaDataContexts().getMetaData().getDatabase(DATABASE_NAME).getResource().getDatabaseType()).thenReturn(new PostgreSQLDatabaseType());
+ when(contextManager.getMetaDataContexts().getMetaData().getDatabase(DATABASE_NAME).getResourceMetaData().getDatabaseType()).thenReturn(new PostgreSQLDatabaseType());
when(contextManager.getMetaDataContexts().getMetaData().containsDatabase(DATABASE_NAME)).thenReturn(true);
}
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
index 940a0077c21..752bf4370af 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
@@ -101,7 +101,7 @@ public final class PostgreSQLComParseExecutorTest extends ProxyContextRestorer {
when(parsePacket.getSql()).thenReturn(rawSQL);
when(parsePacket.getStatementId()).thenReturn(statementId);
when(parsePacket.readParameterTypes()).thenReturn(Collections.singletonList(PostgreSQLColumnType.POSTGRESQL_TYPE_INT4));
- when(mockedContextManager.getMetaDataContexts().getMetaData().getDatabase("db").getResource().getDatabaseType()).thenReturn(new PostgreSQLDatabaseType());
+ when(mockedContextManager.getMetaDataContexts().getMetaData().getDatabase("db").getResourceMetaData().getDatabaseType()).thenReturn(new PostgreSQLDatabaseType());
when(mockedContextManager.getMetaDataContexts().getMetaData().getDatabase("db").getProtocolType()).thenReturn(new PostgreSQLDatabaseType());
ShardingSphereRuleMetaData globalRuleMetaData = mock(ShardingSphereRuleMetaData.class);
when(mockedContextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(globalRuleMetaData);
@@ -132,7 +132,7 @@ public final class PostgreSQLComParseExecutorTest extends ProxyContextRestorer {
when(parsePacket.getSql()).thenReturn(sql);
when(parsePacket.getStatementId()).thenReturn(statementId);
when(connectionSession.getDatabaseName()).thenReturn("db");
- when(mockedContextManager.getMetaDataContexts().getMetaData().getDatabase("db").getResource().getDatabaseType()).thenReturn(new PostgreSQLDatabaseType());
+ when(mockedContextManager.getMetaDataContexts().getMetaData().getDatabase("db").getResourceMetaData().getDatabaseType()).thenReturn(new PostgreSQLDatabaseType());
when(mockedContextManager.getMetaDataContexts().getMetaData().getDatabase("db").getProtocolType()).thenReturn(new PostgreSQLDatabaseType());
ShardingSphereRuleMetaData globalRuleMetaData = mock(ShardingSphereRuleMetaData.class);
when(mockedContextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(globalRuleMetaData);
diff --git a/test/rewrite/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/engine/AbstractSQLRewriterParameterizedTest.java b/test/rewrite/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/engine/AbstractSQLRewriterParameterizedTest.java
index 3cb5e9bca65..19fc0902ba8 100644
--- a/test/rewrite/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/engine/AbstractSQLRewriterParameterizedTest.java
+++ b/test/rewrite/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/engine/AbstractSQLRewriterParameterizedTest.java
@@ -36,7 +36,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.parser.sql.SQLStatementParserEngine;
@@ -105,15 +105,15 @@ public abstract class AbstractSQLRewriterParameterizedTest {
DatabaseConfiguration databaseConfig = new DataSourceProvidedDatabaseConfiguration(
new YamlDataSourceConfigurationSwapper().swapToDataSources(rootConfig.getDataSources()), new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(rootConfig.getRules()));
mockDataSource(databaseConfig.getDataSources());
- ShardingSphereResource resource = mock(ShardingSphereResource.class);
+ ShardingSphereResourceMetaData resourceMetaData = mock(ShardingSphereResourceMetaData.class);
DatabaseType databaseType = DatabaseTypeFactory.getInstance(getTestParameters().getDatabaseType());
- when(resource.getDatabaseType()).thenReturn(databaseType);
+ when(resourceMetaData.getDatabaseType()).thenReturn(databaseType);
String schemaName = DatabaseTypeEngine.getDefaultSchemaName(databaseType, DefaultDatabase.LOGIC_NAME);
Map<String, ShardingSphereSchema> schemas = mockSchemas(schemaName);
Collection<ShardingSphereRule> databaseRules = DatabaseRulesBuilder.build(DefaultDatabase.LOGIC_NAME, databaseConfig, mock(InstanceContext.class));
mockRules(databaseRules, schemaName);
databaseRules.add(sqlParserRule);
- ShardingSphereDatabase database = new ShardingSphereDatabase(schemaName, databaseType, resource, new ShardingSphereRuleMetaData(databaseRules), schemas);
+ ShardingSphereDatabase database = new ShardingSphereDatabase(schemaName, databaseType, resourceMetaData, new ShardingSphereRuleMetaData(databaseRules), schemas);
Map<String, ShardingSphereDatabase> databases = new HashMap<>(2, 1);
databases.put(schemaName, database);
SQLStatementParserEngine sqlStatementParserEngine = new SQLStatementParserEngine(getTestParameters().getDatabaseType(),