Skip to content

Commit

Permalink
fix:add license header and fix spotless error
Browse files Browse the repository at this point in the history
  • Loading branch information
lujx98 committed Sep 30, 2023
1 parent 4441e85 commit 4f3774b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
*/

public final class MySQLShardingSphereStatisticsBuilder implements ShardingSphereStatisticsBuilder {

private static final Set<String> 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();
Expand All @@ -66,7 +66,7 @@ public ShardingSphereStatistics build(final ShardingSphereMetaData metaData) {
databaseData.getSchemaData().put(SHARDING_SPHERE, schemaData);
result.getDatabaseData().put(SHARDING_SPHERE, databaseData);
}

Optional<ShardingSphereSchema> informationSchemaSchema = Optional.ofNullable(metaData.getDatabase("information_schema")).map(database -> database.getSchema("information_schema"));
if (informationSchemaSchema.isPresent()) {
ShardingSphereSchemaData schemaData = new ShardingSphereSchemaData();
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<ShardingSphereTableData> collect(String databaseName, ShardingSphereTable table, Map<String, ShardingSphereDatabase> shardingSphereDatabases) throws SQLException {
Optional<String> databaseWithDatasource = ProxyContext.getInstance().getAllDatabaseNames().stream().filter(MySQLInformationSchemaParameterTableCollector::hasDataSource).findFirst();
Expand All @@ -35,14 +51,14 @@ public Optional<ShardingSphereTableData> 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;
}

}

0 comments on commit 4f3774b

Please sign in to comment.