You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/02/22 14:11:03 UTC
[GitHub] [shardingsphere] dongzl commented on a change in pull request #15567: [DistSQL] Add a syntax SHOW UNUSED RESOURCES
dongzl commented on a change in pull request #15567:
URL: https://github.com/apache/shardingsphere/pull/15567#discussion_r811986480
##########
File path: shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/resource/UnusedDataSourceQueryResultSet.java
##########
@@ -0,0 +1,161 @@
+/*
+ * 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.text.distsql.rql.resource;
+
+import com.google.common.collect.LinkedListMultimap;
+import com.google.common.collect.Multimap;
+import com.google.gson.Gson;
+import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowResourcesStatement;
+import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
+import org.apache.shardingsphere.infra.datanode.DataNode;
+import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
+import org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesCreator;
+import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
+import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+
+import javax.sql.DataSource;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Result set for show unused data source.
+ */
+public final class UnusedDataSourceQueryResultSet implements DistSQLResultSet {
+
+ private static final String CONNECTION_TIMEOUT_MILLISECONDS = "connectionTimeoutMilliseconds";
+
+ private static final String IDLE_TIMEOUT_MILLISECONDS = "idleTimeoutMilliseconds";
+
+ private static final String MAX_LIFETIME_MILLISECONDS = "maxLifetimeMilliseconds";
+
+ private static final String MAX_POOL_SIZE = "maxPoolSize";
+
+ private static final String MIN_POOL_SIZE = "minPoolSize";
+
+ private static final String READ_ONLY = "readOnly";
+
+ private ShardingSphereResource resource;
+
+ private Map<String, DataSourceProperties> dataSourcePropsMap;
+
+ private Iterator<String> dataSourceNames;
+
+ @Override
+ public void init(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement) {
+ resource = metaData.getResource();
+ dataSourcePropsMap = new LinkedHashMap<>(metaData.getResource().getDataSources().size(), 1);
+ Multimap<String, String> inUsedMultiMap = getInUsedResources(metaData.getRuleMetaData());
+ for (Map.Entry<String, DataSource> entry : metaData.getResource().getDataSources().entrySet()) {
Review comment:
@totalo Thanks, fix it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org