This is an automated email from the ASF dual-hosted git repository.

sunnianjun 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 327fe6dd124 Remove DuplicateDataSourceException (#30737)
327fe6dd124 is described below

commit 327fe6dd1245dd9dbdee0bd7dcfa2589dd12f823
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Apr 1 23:26:50 2024 +0800

    Remove DuplicateDataSourceException (#30737)
---
 .../user-manual/error-code/sql-error-code.cn.md    |  1 -
 .../user-manual/error-code/sql-error-code.en.md    |  1 -
 .../datasource/DuplicateDataSourceException.java   | 35 ----------------------
 .../storageunit/DuplicateStorageUnitException.java |  4 +--
 .../rdl/resource/AlterStorageUnitExecutor.java     |  2 +-
 .../rdl/resource/RegisterStorageUnitExecutor.java  |  4 +--
 .../checker/YamlProxyConfigurationChecker.java     |  4 +--
 7 files changed, 7 insertions(+), 44 deletions(-)

diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md 
b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index 3d812d07acf..c4f3584ad3d 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -27,7 +27,6 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 08000     | 10110       | Storage units can not connect, error messages are: 
%s.                              |
 | 0A000     | 10111       | Can not alter connection info in storage units: 
'%s'.                               |
 | 44000     | 10120       | Invalid storage unit status, error message is: %s. 
                                 |
-| 42S01     | 10130       | Duplicate data sources '%s' in database '%s' and 
global data sources.               |
 | 44000     | 10200       | Invalid '%s' rule '%s', error message is: %s       
                                 |
 | 42S02     | 10201       | There is no rule in database '%s'.                 
                                 |
 | 42S02     | 10202       | %s rules '%s' do not exist in database '%s'.       
                                 |
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md 
b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index 1a830aefc6f..93139ff32af 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -27,7 +27,6 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | 08000     | 10110       | Storage units can not connect, error messages are: 
%s.                              |
 | 0A000     | 10111       | Can not alter connection info in storage units: 
'%s'.                               |
 | 44000     | 10120       | Invalid storage unit status, error message is: %s. 
                                 |
-| 42S01     | 10130       | Duplicate data sources '%s' in database '%s' and 
global data sources.               |
 | 44000     | 10200       | Invalid '%s' rule '%s', error message is: %s       
                                 |
 | 42S02     | 10201       | There is no rule in database '%s'.                 
                                 |
 | 42S02     | 10202       | %s rules '%s' do not exist in database '%s'.       
                                 |
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/resource/datasource/DuplicateDataSourceException.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/resource/datasource/DuplicateDataSourceException.java
deleted file mode 100644
index f4034277f06..00000000000
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/resource/datasource/DuplicateDataSourceException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.infra.exception.metadata.resource.datasource;
-
-import 
org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import 
org.apache.shardingsphere.infra.exception.metadata.resource.ResourceDefinitionException;
-
-import java.util.Collection;
-
-/**
- * Duplicate data source exception.
- */
-public final class DuplicateDataSourceException extends 
ResourceDefinitionException {
-    
-    private static final long serialVersionUID = -8215195072425201836L;
-    
-    public DuplicateDataSourceException(final String databaseName, final 
Collection<String> dataSourceNames) {
-        super(XOpenSQLState.DUPLICATE, 30, "Duplicate data sources '%s' in 
database '%s' and global data sources.", String.join(", ", dataSourceNames), 
databaseName);
-    }
-}
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/resource/storageunit/DuplicateStorageUnitException.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/resource/storageunit/DuplicateStorageUnitException.java
index 5682f547634..04c890ab0f0 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/resource/storageunit/DuplicateStorageUnitException.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/resource/storageunit/DuplicateStorageUnitException.java
@@ -29,7 +29,7 @@ public final class DuplicateStorageUnitException extends 
ResourceDefinitionExcep
     
     private static final long serialVersionUID = 2103793827572264148L;
     
-    public DuplicateStorageUnitException(final Collection<String> 
storageUnitNames) {
-        super(XOpenSQLState.DUPLICATE, 4, "Duplicate storage unit names 
'%s'.", String.join(", ", storageUnitNames));
+    public DuplicateStorageUnitException(final String databaseName, final 
Collection<String> storageUnitNames) {
+        super(XOpenSQLState.DUPLICATE, 4, "Duplicate storage unit names '%s' 
on database '%s'.", String.join(", ", storageUnitNames), databaseName);
     }
 }
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/AlterStorageUnitExecutor.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/AlterStorageUnitExecutor.java
index d74b06cb825..ba32b4cfb80 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/AlterStorageUnitExecutor.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/AlterStorageUnitExecutor.java
@@ -80,7 +80,7 @@ public final class AlterStorageUnitExecutor implements 
DistSQLUpdateExecutor<Alt
     
     private void checkDuplicatedStorageUnitNames(final Collection<String> 
storageUnitNames) {
         Collection<String> duplicatedStorageUnitNames = 
storageUnitNames.stream().filter(each -> 
storageUnitNames.stream().filter(each::equals).count() > 
1).collect(Collectors.toList());
-        
ShardingSpherePreconditions.checkState(duplicatedStorageUnitNames.isEmpty(), () 
-> new DuplicateStorageUnitException(duplicatedStorageUnitNames));
+        
ShardingSpherePreconditions.checkState(duplicatedStorageUnitNames.isEmpty(), () 
-> new DuplicateStorageUnitException(database.getName(), 
duplicatedStorageUnitNames));
     }
     
     private void checkStorageUnitNameExisted(final Collection<String> 
storageUnitNames) {
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/RegisterStorageUnitExecutor.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/RegisterStorageUnitExecutor.java
index d6239baf6ad..04bae642b92 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/RegisterStorageUnitExecutor.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/RegisterStorageUnitExecutor.java
@@ -89,7 +89,7 @@ public final class RegisterStorageUnitExecutor implements 
DistSQLUpdateExecutor<
             }
             dataSourceNames.add(each.getName());
         }
-        
ShardingSpherePreconditions.checkState(duplicatedDataSourceNames.isEmpty(), () 
-> new DuplicateStorageUnitException(duplicatedDataSourceNames));
+        
ShardingSpherePreconditions.checkState(duplicatedDataSourceNames.isEmpty(), () 
-> new DuplicateStorageUnitException(database.getName(), 
duplicatedDataSourceNames));
     }
     
     private void checkDuplicatedLogicalDataSourceNames(final 
Collection<String> requiredDataSourceNames) {
@@ -98,7 +98,7 @@ public final class RegisterStorageUnitExecutor implements 
DistSQLUpdateExecutor<
             return;
         }
         Collection<String> duplicatedDataSourceNames = 
requiredDataSourceNames.stream().filter(logicalDataSourceNames::contains).collect(Collectors.toSet());
-        
ShardingSpherePreconditions.checkState(duplicatedDataSourceNames.isEmpty(), () 
-> new DuplicateStorageUnitException(duplicatedDataSourceNames));
+        
ShardingSpherePreconditions.checkState(duplicatedDataSourceNames.isEmpty(), () 
-> new DuplicateStorageUnitException(database.getName(), 
duplicatedDataSourceNames));
     }
     
     private Collection<String> getCurrentStorageUnitNames(final ContextManager 
contextManager) {
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/checker/YamlProxyConfigurationChecker.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/checker/YamlProxyConfigurationChecker.java
index 86b4009fbd2..b642886495c 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/checker/YamlProxyConfigurationChecker.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/checker/YamlProxyConfigurationChecker.java
@@ -20,9 +20,9 @@ package 
org.apache.shardingsphere.proxy.backend.config.checker;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
+import 
org.apache.shardingsphere.infra.exception.metadata.resource.storageunit.DuplicateStorageUnitException;
 import 
org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
 import 
org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
-import 
org.apache.shardingsphere.infra.exception.metadata.resource.datasource.DuplicateDataSourceException;
 
 import java.util.Collection;
 import java.util.Map;
@@ -47,6 +47,6 @@ public final class YamlProxyConfigurationChecker {
     private static void checkDataSources(final Map<String, 
YamlProxyDataSourceConfiguration> globalDataSources,
                                          final Map<String, 
YamlProxyDataSourceConfiguration> databaseDataSources, final String 
databaseName) {
         Collection<String> duplicatedDataSourceNames = 
globalDataSources.keySet().stream().filter(databaseDataSources.keySet()::contains).collect(Collectors.toSet());
-        
ShardingSpherePreconditions.checkState(duplicatedDataSourceNames.isEmpty(), () 
-> new DuplicateDataSourceException(databaseName, duplicatedDataSourceNames));
+        
ShardingSpherePreconditions.checkState(duplicatedDataSourceNames.isEmpty(), () 
-> new DuplicateStorageUnitException(databaseName, duplicatedDataSourceNames));
     }
 }

Reply via email to