From ed3ac5362dd1504cea7fa061fb4eeb0156360931 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Thu, 25 Jan 2024 22:15:17 +0800 Subject: [PATCH] Refactor DatabaseAwareQueryableRALExecutor (#29859) * Rename DataSourcePoolPropertiesValidator * Move DatabaseAwareQueryableRALExecutor * Refactor DatabaseAwareQueryableRALExecutor --- .../ConnectionSizeAwareQueryableRALExecutor.java | 3 ++- .../{ => aware}/DatabaseAwareQueryableRALExecutor.java | 9 +++++---- .../InstanceContextAwareQueryableRALExecutor.java | 3 ++- ...ler.java => DataSourcePoolPropertiesValidator.java} | 7 +++---- .../RegisterMigrationSourceStorageUnitExecutor.java | 4 ++-- .../distsql/ral/QueryableRALBackendHandler.java | 8 ++++---- .../queryable/ExportDatabaseConfigurationExecutor.java | 10 +++++----- .../ral/queryable/ShowComputeNodeInfoExecutor.java | 2 +- .../ral/queryable/ShowComputeNodeModeExecutor.java | 2 +- .../ral/queryable/ShowComputeNodesExecutor.java | 2 +- .../ral/queryable/ShowDistVariableExecutor.java | 2 +- .../ral/queryable/ShowDistVariablesExecutor.java | 2 +- .../ral/queryable/ShowTableMetaDataExecutor.java | 10 +++++----- .../rdl/resource/type/AlterStorageUnitExecutor.java | 4 ++-- .../rdl/resource/type/RegisterStorageUnitExecutor.java | 4 ++-- .../util/YamlDatabaseConfigurationImportExecutor.java | 4 ++-- .../ExportDatabaseConfigurationExecutorTest.java | 4 ++-- .../ral/queryable/ShowTableMetaDataExecutorTest.java | 2 +- .../ImportDatabaseConfigurationUpdaterTest.java | 4 ++-- .../rdl/resource/AlterStorageUnitExecutorTest.java | 4 ++-- .../rdl/resource/RegisterStorageUnitExecutorTest.java | 4 ++-- 21 files changed, 48 insertions(+), 46 deletions(-) rename infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/{ => aware}/ConnectionSizeAwareQueryableRALExecutor.java (93%) rename infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/{ => aware}/DatabaseAwareQueryableRALExecutor.java (86%) rename infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/{ => aware}/InstanceContextAwareQueryableRALExecutor.java (93%) rename infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/validate/{DataSourcePoolPropertiesValidateHandler.java => DataSourcePoolPropertiesValidator.java} (85%) diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/ConnectionSizeAwareQueryableRALExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/aware/ConnectionSizeAwareQueryableRALExecutor.java similarity index 93% rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/ConnectionSizeAwareQueryableRALExecutor.java rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/aware/ConnectionSizeAwareQueryableRALExecutor.java index 1ff46ea78f602..de452f45a572e 100644 --- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/ConnectionSizeAwareQueryableRALExecutor.java +++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/aware/ConnectionSizeAwareQueryableRALExecutor.java @@ -15,8 +15,9 @@ * limitations under the License. */ -package org.apache.shardingsphere.distsql.handler.type.ral.query; +package org.apache.shardingsphere.distsql.handler.type.ral.query.aware; +import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor; import org.apache.shardingsphere.distsql.statement.ral.queryable.QueryableRALStatement; /** diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/DatabaseAwareQueryableRALExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/aware/DatabaseAwareQueryableRALExecutor.java similarity index 86% rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/DatabaseAwareQueryableRALExecutor.java rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/aware/DatabaseAwareQueryableRALExecutor.java index 8d87a54c8bc89..aced4c2331ed5 100644 --- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/DatabaseAwareQueryableRALExecutor.java +++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/aware/DatabaseAwareQueryableRALExecutor.java @@ -15,8 +15,9 @@ * limitations under the License. */ -package org.apache.shardingsphere.distsql.handler.type.ral.query; +package org.apache.shardingsphere.distsql.handler.type.ral.query.aware; +import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor; import org.apache.shardingsphere.distsql.statement.ral.queryable.QueryableRALStatement; import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; @@ -28,9 +29,9 @@ public interface DatabaseAwareQueryableRALExecutor extends QueryableRALExecutor { /** - * Set current database. + * Set database. * - * @param currentDatabase current database + * @param database database */ - void setCurrentDatabase(ShardingSphereDatabase currentDatabase); + void setDatabase(ShardingSphereDatabase database); } diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/InstanceContextAwareQueryableRALExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/aware/InstanceContextAwareQueryableRALExecutor.java similarity index 93% rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/InstanceContextAwareQueryableRALExecutor.java rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/aware/InstanceContextAwareQueryableRALExecutor.java index cf25d907eb3f7..64a55bbcd8549 100644 --- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/InstanceContextAwareQueryableRALExecutor.java +++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/aware/InstanceContextAwareQueryableRALExecutor.java @@ -15,8 +15,9 @@ * limitations under the License. */ -package org.apache.shardingsphere.distsql.handler.type.ral.query; +package org.apache.shardingsphere.distsql.handler.type.ral.query.aware; +import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor; import org.apache.shardingsphere.distsql.statement.ral.queryable.QueryableRALStatement; import org.apache.shardingsphere.infra.instance.InstanceContext; diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/validate/DataSourcePoolPropertiesValidateHandler.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/validate/DataSourcePoolPropertiesValidator.java similarity index 85% rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/validate/DataSourcePoolPropertiesValidateHandler.java rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/validate/DataSourcePoolPropertiesValidator.java index a81c0ddd4e523..b55460a31a79c 100644 --- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/validate/DataSourcePoolPropertiesValidateHandler.java +++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/validate/DataSourcePoolPropertiesValidator.java @@ -19,16 +19,15 @@ import org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException; import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; -import org.apache.shardingsphere.infra.datasource.pool.props.validator.DataSourcePoolPropertiesValidator; import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions; import java.util.Collection; import java.util.Map; /** - * Data source pool properties validate handler. + * Data source pool properties validator. */ -public final class DataSourcePoolPropertiesValidateHandler { +public final class DataSourcePoolPropertiesValidator { /** * Validate data source properties map. @@ -37,7 +36,7 @@ public final class DataSourcePoolPropertiesValidateHandler { * @throws InvalidStorageUnitsException invalid storage units exception */ public void validate(final Map propsMap) { - Collection errorMessages = DataSourcePoolPropertiesValidator.validate(propsMap); + Collection errorMessages = org.apache.shardingsphere.infra.datasource.pool.props.validator.DataSourcePoolPropertiesValidator.validate(propsMap); ShardingSpherePreconditions.checkState(errorMessages.isEmpty(), () -> new InvalidStorageUnitsException(errorMessages)); } } diff --git a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/update/RegisterMigrationSourceStorageUnitExecutor.java b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/update/RegisterMigrationSourceStorageUnitExecutor.java index 4f3d4a6a4db40..5605090c774b2 100644 --- a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/update/RegisterMigrationSourceStorageUnitExecutor.java +++ b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/update/RegisterMigrationSourceStorageUnitExecutor.java @@ -21,7 +21,7 @@ import org.apache.shardingsphere.data.pipeline.core.job.api.TransmissionJobAPI; import org.apache.shardingsphere.data.pipeline.scenario.migration.api.MigrationJobAPI; import org.apache.shardingsphere.distsql.handler.type.ral.update.UpdatableRALExecutor; -import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidateHandler; +import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidator; import org.apache.shardingsphere.distsql.segment.DataSourceSegment; import org.apache.shardingsphere.distsql.segment.HostnameAndPortBasedDataSourceSegment; import org.apache.shardingsphere.distsql.segment.URLBasedDataSourceSegment; @@ -46,7 +46,7 @@ public final class RegisterMigrationSourceStorageUnitExecutor implements Updatab private final MigrationJobAPI jobAPI = (MigrationJobAPI) TypedSPILoader.getService(TransmissionJobAPI.class, "MIGRATION"); - private final DataSourcePoolPropertiesValidateHandler validateHandler = new DataSourcePoolPropertiesValidateHandler(); + private final DataSourcePoolPropertiesValidator validateHandler = new DataSourcePoolPropertiesValidator(); @Override public void executeUpdate(final RegisterMigrationSourceStorageUnitStatement sqlStatement) { diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandler.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandler.java index 34939e1eb26e8..df3c613651c79 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandler.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandler.java @@ -18,9 +18,9 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral; import lombok.RequiredArgsConstructor; -import org.apache.shardingsphere.distsql.handler.type.ral.query.ConnectionSizeAwareQueryableRALExecutor; -import org.apache.shardingsphere.distsql.handler.type.ral.query.DatabaseAwareQueryableRALExecutor; -import org.apache.shardingsphere.distsql.handler.type.ral.query.InstanceContextAwareQueryableRALExecutor; +import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.ConnectionSizeAwareQueryableRALExecutor; +import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.DatabaseAwareQueryableRALExecutor; +import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.InstanceContextAwareQueryableRALExecutor; import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor; import org.apache.shardingsphere.distsql.statement.ral.queryable.QueryableRALStatement; import org.apache.shardingsphere.infra.merge.result.MergedResult; @@ -74,7 +74,7 @@ private MergedResult getMergedResult(final QueryableRALExecutor executor) { ((InstanceContextAwareQueryableRALExecutor) executor).setInstanceContext(ProxyContext.getInstance().getContextManager().getInstanceContext()); } if (executor instanceof DatabaseAwareQueryableRALExecutor) { - ((DatabaseAwareQueryableRALExecutor) executor).setCurrentDatabase(ProxyContext.getInstance().getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement, connectionSession))); + ((DatabaseAwareQueryableRALExecutor) executor).setDatabase(ProxyContext.getInstance().getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement, connectionSession))); } if (executor instanceof ConnectionSizeAwareQueryableRALExecutor) { ((ConnectionSizeAwareQueryableRALExecutor) executor).setConnectionSize(connectionSession.getDatabaseConnectionManager().getConnectionSize()); diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationExecutor.java index 751e13b4f8b5a..e489d4c1a26d3 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationExecutor.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable; import lombok.Setter; -import org.apache.shardingsphere.distsql.handler.type.ral.query.DatabaseAwareQueryableRALExecutor; +import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.DatabaseAwareQueryableRALExecutor; import org.apache.shardingsphere.distsql.statement.ral.queryable.export.ExportDatabaseConfigurationStatement; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; @@ -34,7 +34,7 @@ @Setter public final class ExportDatabaseConfigurationExecutor implements DatabaseAwareQueryableRALExecutor { - private ShardingSphereDatabase currentDatabase; + private ShardingSphereDatabase database; @Override public Collection getColumnNames() { @@ -43,7 +43,7 @@ public Collection getColumnNames() { @Override public Collection getRows(final ExportDatabaseConfigurationStatement sqlStatement, final ShardingSphereMetaData metaData) { - String exportedData = ExportUtils.generateExportDatabaseData(currentDatabase); + String exportedData = ExportUtils.generateExportDatabaseData(database); if (!sqlStatement.getFilePath().isPresent()) { return Collections.singleton(new LocalDataQueryResultRow(exportedData)); } @@ -53,8 +53,8 @@ public Collection getRows(final ExportDatabaseConfigura } @Override - public void setCurrentDatabase(final ShardingSphereDatabase currentDatabase) { - this.currentDatabase = currentDatabase; + public void setDatabase(final ShardingSphereDatabase database) { + this.database = database; } @Override diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeInfoExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeInfoExecutor.java index 8a64931cb1816..9bddab19a00a3 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeInfoExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeInfoExecutor.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable; import lombok.Setter; -import org.apache.shardingsphere.distsql.handler.type.ral.query.InstanceContextAwareQueryableRALExecutor; +import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.InstanceContextAwareQueryableRALExecutor; import org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowComputeNodeInfoStatement; import org.apache.shardingsphere.infra.instance.ComputeNodeInstance; import org.apache.shardingsphere.infra.instance.InstanceContext; diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeModeExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeModeExecutor.java index c89a66363f773..31f39c32418ef 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeModeExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeModeExecutor.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable; import lombok.Setter; -import org.apache.shardingsphere.distsql.handler.type.ral.query.InstanceContextAwareQueryableRALExecutor; +import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.InstanceContextAwareQueryableRALExecutor; import org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowComputeNodeModeStatement; import org.apache.shardingsphere.infra.config.mode.PersistRepositoryConfiguration; import org.apache.shardingsphere.infra.instance.InstanceContext; diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java index 4ddefea0b41ec..fa323ec4a92e7 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable; import lombok.Setter; -import org.apache.shardingsphere.distsql.handler.type.ral.query.InstanceContextAwareQueryableRALExecutor; +import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.InstanceContextAwareQueryableRALExecutor; import org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowComputeNodesStatement; import org.apache.shardingsphere.infra.instance.ComputeNodeInstance; import org.apache.shardingsphere.infra.instance.InstanceContext; diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariableExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariableExecutor.java index b5669cd21decc..af5e2c44d3453 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariableExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariableExecutor.java @@ -30,7 +30,7 @@ import org.apache.shardingsphere.logging.util.LoggingUtils; import org.apache.shardingsphere.proxy.backend.exception.UnsupportedVariableException; import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.DistSQLVariable; -import org.apache.shardingsphere.distsql.handler.type.ral.query.ConnectionSizeAwareQueryableRALExecutor; +import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.ConnectionSizeAwareQueryableRALExecutor; import java.util.Arrays; import java.util.Collection; diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariablesExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariablesExecutor.java index 6854c1d41244e..fbffb6649c82a 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariablesExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariablesExecutor.java @@ -28,7 +28,7 @@ import org.apache.shardingsphere.logging.logger.ShardingSphereLogger; import org.apache.shardingsphere.logging.util.LoggingUtils; import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.DistSQLVariable; -import org.apache.shardingsphere.distsql.handler.type.ral.query.ConnectionSizeAwareQueryableRALExecutor; +import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.ConnectionSizeAwareQueryableRALExecutor; import org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtils; import java.util.Arrays; diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutor.java index 771291b726894..c66dd20317f3a 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutor.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable; import lombok.Setter; -import org.apache.shardingsphere.distsql.handler.type.ral.query.DatabaseAwareQueryableRALExecutor; +import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.DatabaseAwareQueryableRALExecutor; import org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowTableMetaDataStatement; import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; @@ -41,7 +41,7 @@ @Setter public final class ShowTableMetaDataExecutor implements DatabaseAwareQueryableRALExecutor { - private ShardingSphereDatabase currentDatabase; + private ShardingSphereDatabase database; @Override public Collection getColumnNames() { @@ -50,10 +50,10 @@ public Collection getColumnNames() { @Override public Collection getRows(final ShowTableMetaDataStatement sqlStatement, final ShardingSphereMetaData metaData) { - String defaultSchema = new DatabaseTypeRegistry(currentDatabase.getProtocolType()).getDefaultSchemaName(currentDatabase.getName()); - ShardingSphereSchema schema = currentDatabase.getSchema(defaultSchema); + String defaultSchema = new DatabaseTypeRegistry(database.getProtocolType()).getDefaultSchemaName(database.getName()); + ShardingSphereSchema schema = database.getSchema(defaultSchema); return sqlStatement.getTableNames().stream().filter(each -> schema.getAllTableNames().contains(each.toLowerCase())) - .map(each -> buildTableRows(currentDatabase.getName(), schema, each.toLowerCase())).flatMap(Collection::stream).collect(Collectors.toList()); + .map(each -> buildTableRows(database.getName(), schema, each.toLowerCase())).flatMap(Collection::stream).collect(Collectors.toList()); } private Collection buildTableRows(final String databaseName, final ShardingSphereSchema schema, final String tableName) { diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/type/AlterStorageUnitExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/type/AlterStorageUnitExecutor.java index 4fe67c747fb8d..f8b003fc60527 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/type/AlterStorageUnitExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/type/AlterStorageUnitExecutor.java @@ -23,7 +23,7 @@ import org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException; import org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException; import org.apache.shardingsphere.distsql.handler.type.rdl.resource.aware.DatabaseAwareResourceDefinitionExecutor; -import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidateHandler; +import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidator; import org.apache.shardingsphere.distsql.segment.DataSourceSegment; import org.apache.shardingsphere.distsql.segment.HostnameAndPortBasedDataSourceSegment; import org.apache.shardingsphere.distsql.segment.URLBasedDataSourceSegment; @@ -54,7 +54,7 @@ @Setter public final class AlterStorageUnitExecutor implements DatabaseAwareResourceDefinitionExecutor { - private final DataSourcePoolPropertiesValidateHandler validateHandler = new DataSourcePoolPropertiesValidateHandler(); + private final DataSourcePoolPropertiesValidator validateHandler = new DataSourcePoolPropertiesValidator(); private ShardingSphereDatabase database; diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/type/RegisterStorageUnitExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/type/RegisterStorageUnitExecutor.java index e02b5e36ed01f..2feabee9966f3 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/type/RegisterStorageUnitExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/type/RegisterStorageUnitExecutor.java @@ -22,7 +22,7 @@ import org.apache.shardingsphere.distsql.handler.exception.storageunit.DuplicateStorageUnitException; import org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException; import org.apache.shardingsphere.distsql.handler.type.rdl.resource.aware.DatabaseAwareResourceDefinitionExecutor; -import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidateHandler; +import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidator; import org.apache.shardingsphere.distsql.segment.DataSourceSegment; import org.apache.shardingsphere.distsql.segment.converter.DataSourceSegmentsConverter; import org.apache.shardingsphere.distsql.statement.rdl.resource.unit.type.RegisterStorageUnitStatement; @@ -48,7 +48,7 @@ @Slf4j public final class RegisterStorageUnitExecutor implements DatabaseAwareResourceDefinitionExecutor { - private final DataSourcePoolPropertiesValidateHandler validateHandler = new DataSourcePoolPropertiesValidateHandler(); + private final DataSourcePoolPropertiesValidator validateHandler = new DataSourcePoolPropertiesValidator(); private ShardingSphereDatabase database; diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java index f510c7cb376c7..1eb0bfb4c28ff 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java @@ -23,7 +23,7 @@ import org.apache.shardingsphere.broadcast.yaml.swapper.YamlBroadcastRuleConfigurationSwapper; import org.apache.shardingsphere.distsql.handler.exception.datasource.MissingRequiredDataSourcesException; import org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException; -import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidateHandler; +import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidator; import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration; import org.apache.shardingsphere.encrypt.rule.EncryptRule; import org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration; @@ -106,7 +106,7 @@ public final class YamlDatabaseConfigurationImportExecutor { private final YamlProxyDataSourceConfigurationSwapper dataSourceConfigSwapper = new YamlProxyDataSourceConfigurationSwapper(); - private final DataSourcePoolPropertiesValidateHandler validateHandler = new DataSourcePoolPropertiesValidateHandler(); + private final DataSourcePoolPropertiesValidator validateHandler = new DataSourcePoolPropertiesValidator(); /** * Import proxy database from yaml configuration. diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationExecutorTest.java index a99c11c6774ec..7165d1b1708f6 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ExportDatabaseConfigurationExecutorTest.java @@ -75,7 +75,7 @@ void assertExecute() { when(database.getResourceMetaData().getStorageUnits()).thenReturn(storageUnits); when(database.getRuleMetaData().getConfigurations()).thenReturn(Collections.singleton(createShardingRuleConfiguration())); ExportDatabaseConfigurationExecutor executor = new ExportDatabaseConfigurationExecutor(); - executor.setCurrentDatabase(database); + executor.setDatabase(database); Collection actual = executor.getRows(new ExportDatabaseConfigurationStatement(mock(DatabaseSegment.class), null), mock(ShardingSphereMetaData.class)); assertThat(actual.size(), is(1)); LocalDataQueryResultRow row = actual.iterator().next(); @@ -101,7 +101,7 @@ void assertExecuteWithEmptyDatabase() { when(database.getRuleMetaData().getConfigurations()).thenReturn(Collections.emptyList()); ExportDatabaseConfigurationStatement sqlStatement = new ExportDatabaseConfigurationStatement(new DatabaseSegment(0, 0, new IdentifierValue("empty_db")), null); ExportDatabaseConfigurationExecutor executor = new ExportDatabaseConfigurationExecutor(); - executor.setCurrentDatabase(database); + executor.setDatabase(database); Collection actual = executor.getRows(sqlStatement, mock(ShardingSphereMetaData.class)); assertThat(actual.size(), is(1)); LocalDataQueryResultRow row = actual.iterator().next(); diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutorTest.java index 504d0bd0e425a..22431885c7675 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutorTest.java @@ -55,7 +55,7 @@ class ShowTableMetaDataExecutorTest { void assertExecute() { ShardingSphereDatabase database = mockDatabase(); ShowTableMetaDataExecutor executor = new ShowTableMetaDataExecutor(); - executor.setCurrentDatabase(database); + executor.setDatabase(database); Collection actual = executor.getRows(createSqlStatement(), mock(ShardingSphereMetaData.class)); assertThat(actual.size(), is(2)); Iterator iterator = actual.iterator(); diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java index 86396c8ef27bc..fbf81231cce8f 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java @@ -20,7 +20,7 @@ import lombok.SneakyThrows; import org.apache.shardingsphere.distsql.handler.exception.datasource.MissingRequiredDataSourcesException; import org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException; -import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidateHandler; +import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidator; import org.apache.shardingsphere.distsql.statement.ral.updatable.ImportDatabaseConfigurationStatement; import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey; @@ -131,7 +131,7 @@ private void init(final String databaseName) { importDatabaseConfigUpdater = new ImportDatabaseConfigurationExecutor(); YamlDatabaseConfigurationImportExecutor databaseConfigImportExecutor = new YamlDatabaseConfigurationImportExecutor(); Plugins.getMemberAccessor().set(importDatabaseConfigUpdater.getClass().getDeclaredField("databaseConfigImportExecutor"), importDatabaseConfigUpdater, databaseConfigImportExecutor); - Plugins.getMemberAccessor().set(databaseConfigImportExecutor.getClass().getDeclaredField("validateHandler"), databaseConfigImportExecutor, mock(DataSourcePoolPropertiesValidateHandler.class)); + Plugins.getMemberAccessor().set(databaseConfigImportExecutor.getClass().getDeclaredField("validateHandler"), databaseConfigImportExecutor, mock(DataSourcePoolPropertiesValidator.class)); } private ContextManager mockContextManager(final String databaseName) { diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterStorageUnitExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterStorageUnitExecutorTest.java index 2a54850581cc6..c86e57726a083 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterStorageUnitExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterStorageUnitExecutorTest.java @@ -20,7 +20,7 @@ import org.apache.shardingsphere.distsql.handler.exception.storageunit.DuplicateStorageUnitException; import org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException; import org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException; -import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidateHandler; +import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidator; import org.apache.shardingsphere.distsql.segment.HostnameAndPortBasedDataSourceSegment; import org.apache.shardingsphere.distsql.segment.URLBasedDataSourceSegment; import org.apache.shardingsphere.distsql.statement.rdl.resource.unit.type.AlterStorageUnitStatement; @@ -63,7 +63,7 @@ class AlterStorageUnitExecutorTest { @BeforeEach void setUp() throws ReflectiveOperationException { executor = new AlterStorageUnitExecutor(); - Plugins.getMemberAccessor().set(executor.getClass().getDeclaredField("validateHandler"), executor, mock(DataSourcePoolPropertiesValidateHandler.class)); + Plugins.getMemberAccessor().set(executor.getClass().getDeclaredField("validateHandler"), executor, mock(DataSourcePoolPropertiesValidator.class)); } @Test diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/RegisterStorageUnitExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/RegisterStorageUnitExecutorTest.java index 39723bd220ccd..d1583ecc570a3 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/RegisterStorageUnitExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/RegisterStorageUnitExecutorTest.java @@ -19,7 +19,7 @@ import org.apache.shardingsphere.distsql.handler.exception.storageunit.DuplicateStorageUnitException; import org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException; -import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidateHandler; +import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidator; import org.apache.shardingsphere.distsql.segment.DataSourceSegment; import org.apache.shardingsphere.distsql.segment.HostnameAndPortBasedDataSourceSegment; import org.apache.shardingsphere.distsql.segment.URLBasedDataSourceSegment; @@ -67,7 +67,7 @@ void setUp() throws ReflectiveOperationException { when(database.getName()).thenReturn("foo_db"); when(database.getRuleMetaData()).thenReturn(mock(RuleMetaData.class)); executor = new RegisterStorageUnitExecutor(); - Plugins.getMemberAccessor().set(executor.getClass().getDeclaredField("validateHandler"), executor, mock(DataSourcePoolPropertiesValidateHandler.class)); + Plugins.getMemberAccessor().set(executor.getClass().getDeclaredField("validateHandler"), executor, mock(DataSourcePoolPropertiesValidator.class)); } @Test