diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/builder/dialect/MySQLShardingSphereStatisticsBuilder.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/builder/dialect/MySQLShardingSphereStatisticsBuilder.java index 869ab756fc67e..7527fd4cc5d0c 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/builder/dialect/MySQLShardingSphereStatisticsBuilder.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/builder/dialect/MySQLShardingSphereStatisticsBuilder.java @@ -40,15 +40,15 @@ */ public final class MySQLShardingSphereStatisticsBuilder implements ShardingSphereStatisticsBuilder { - + private static final Set CURRENT_SUPPORT = new HashSet<>(Arrays.asList("PARAMETERS")); - + private static final String SHARDING_SPHERE = "shardingsphere"; - + private static final String INFORMATION_SCHEMA = "information_schema"; - + private static final String CLUSTER_INFORMATION = "cluster_information"; - + @Override public ShardingSphereStatistics build(final ShardingSphereMetaData metaData) { ShardingSphereStatistics result = new ShardingSphereStatistics(); @@ -66,7 +66,7 @@ public ShardingSphereStatistics build(final ShardingSphereMetaData metaData) { databaseData.getSchemaData().put(SHARDING_SPHERE, schemaData); result.getDatabaseData().put(SHARDING_SPHERE, databaseData); } - + Optional informationSchemaSchema = Optional.ofNullable(metaData.getDatabase("information_schema")).map(database -> database.getSchema("information_schema")); if (informationSchemaSchema.isPresent()) { ShardingSphereSchemaData schemaData = new ShardingSphereSchemaData(); @@ -81,10 +81,10 @@ public ShardingSphereStatistics build(final ShardingSphereMetaData metaData) { informationSchemaResult.getSchemaData().put(INFORMATION_SCHEMA, schemaData); result.getDatabaseData().put(INFORMATION_SCHEMA, informationSchemaResult); } - + return result; } - + @Override public String getDatabaseType() { return "MySQL"; diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/collector/MySQLInformationSchemaParameterTableCollector.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/collector/MySQLInformationSchemaParameterTableCollector.java index e86a5be4cc076..6325efd64ac0b 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/collector/MySQLInformationSchemaParameterTableCollector.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/collector/MySQLInformationSchemaParameterTableCollector.java @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apache.shardingsphere.proxy.backend.collector; import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; @@ -14,15 +31,14 @@ import java.util.Optional; /** - * @author sheldon - * @date 2023-09-28 + * MySQLInformationSchemaParameterTableCollector */ public final class MySQLInformationSchemaParameterTableCollector implements ShardingSphereStatisticsCollector { - + private final static String PARAMETER_TABLE_NAME = "PARAMETERS"; - + private final static String COLLECT_SQL = "select * from information_schema.PARAMETERS"; - + @Override public Optional collect(String databaseName, ShardingSphereTable table, Map shardingSphereDatabases) throws SQLException { Optional databaseWithDatasource = ProxyContext.getInstance().getAllDatabaseNames().stream().filter(MySQLInformationSchemaParameterTableCollector::hasDataSource).findFirst(); @@ -35,14 +51,14 @@ public Optional collect(String databaseName, ShardingSp } return Optional.empty(); } - + private static Boolean hasDataSource(final String databaseName) { return ProxyContext.getInstance().getDatabase(databaseName).containsDataSource(); } - + @Override public Object getType() { return PARAMETER_TABLE_NAME; } - + }