You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/09/22 14:07:32 UTC
[shardingsphere] branch master updated: Refactor DistSQLException (#21142)
This is an automated email from the ASF dual-hosted git repository.
panjuan 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 3bd14bda407 Refactor DistSQLException (#21142)
3bd14bda407 is described below
commit 3bd14bda407e09505269178ad8f9efaa6795939e
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Sep 22 22:07:18 2022 +0800
Refactor DistSQLException (#21142)
---
.../user-manual/error-code/sql-error-code.cn.md | 20 +++++++++
.../user-manual/error-code/sql-error-code.en.md | 20 +++++++++
...DatabaseDiscoveryHeartbeatStatementUpdater.java | 6 +--
...AlterDatabaseDiscoveryRuleStatementUpdater.java | 14 +++---
...AlterDatabaseDiscoveryTypeStatementUpdater.java | 6 +--
...reateDatabaseDiscoveryRuleStatementUpdater.java | 12 +++---
...DatabaseDiscoveryHeartbeatStatementUpdater.java | 6 +--
.../DropDatabaseDiscoveryRuleStatementUpdater.java | 6 +--
.../DropDatabaseDiscoveryTypeStatementUpdater.java | 6 +--
...baseDiscoveryHeartbeatStatementUpdaterTest.java | 4 +-
...overyProviderAlgorithmStatementUpdaterTest.java | 4 +-
...rDatabaseDiscoveryRuleStatementUpdaterTest.java | 16 +++----
...eDatabaseDiscoveryRuleStatementUpdaterTest.java | 10 ++---
...baseDiscoveryHeartbeatStatementUpdaterTest.java | 6 +--
...overyProviderAlgorithmStatementUpdaterTest.java | 6 +--
...pDatabaseDiscoveryRuleStatementUpdaterTest.java | 6 +--
.../update/AlterEncryptRuleStatementUpdater.java | 8 ++--
.../update/DropEncryptRuleStatementUpdater.java | 6 +--
.../AlterEncryptRuleStatementUpdaterTest.java | 6 +--
.../DropEncryptRuleStatementUpdaterTest.java | 6 +--
...lterReadwriteSplittingRuleStatementUpdater.java | 16 +++----
...eateReadwriteSplittingRuleStatementUpdater.java | 6 +--
...DropReadwriteSplittingRuleStatementUpdater.java | 10 ++---
...ReadwriteSplittingRuleStatementUpdaterTest.java | 12 +++---
...ReadwriteSplittingRuleStatementUpdaterTest.java | 6 +--
...ReadwriteSplittingRuleStatementUpdaterTest.java | 6 +--
.../checker/ShadowRuleStatementChecker.java | 8 ++--
.../AlterShadowAlgorithmStatementUpdater.java | 6 +--
.../update/AlterShadowRuleStatementUpdater.java | 2 +-
...eateDefaultShadowAlgorithmStatementUpdater.java | 4 +-
...DropDefaultShadowAlgorithmStatementUpdater.java | 4 +-
.../DropShadowAlgorithmStatementUpdater.java | 8 ++--
.../update/DropShadowRuleStatementUpdater.java | 4 +-
.../AlterShadowAlgorithmStatementUpdaterTest.java | 8 ++--
.../AlterShadowRuleStatementUpdaterTest.java | 8 ++--
...DefaultShadowAlgorithmStatementUpdaterTest.java | 4 +-
.../CreateShadowRuleStatementUpdaterTest.java | 4 +-
...DefaultShadowAlgorithmStatementUpdaterTest.java | 4 +-
.../DropShadowAlgorithmStatementUpdaterTest.java | 4 +-
.../update/DropShadowRuleStatementUpdaterTest.java | 4 +-
.../checker/ShardingTableRuleStatementChecker.java | 14 +++---
...terDefaultShardingStrategyStatementUpdater.java | 12 +++---
.../AlterShardingAlgorithmStatementUpdater.java | 4 +-
.../AlterShardingAuditorStatementUpdater.java | 4 +-
...rShardingBindingTableRulesStatementUpdater.java | 6 +--
...ShardingBroadcastTableRuleStatementUpdater.java | 6 +--
.../AlterShardingKeyGeneratorStatementUpdater.java | 4 +-
.../AlterShardingTableRuleStatementUpdater.java | 4 +-
...ateDefaultShardingStrategyStatementUpdater.java | 10 ++---
.../CreateShardingAuditorStatementUpdater.java | 6 +--
...teShardingBindingTableRuleStatementUpdater.java | 8 ++--
...ShardingBroadcastTableRuleStatementUpdater.java | 4 +-
...CreateShardingKeyGeneratorStatementUpdater.java | 6 +--
.../DropDefaultStrategyStatementUpdater.java | 6 +--
.../DropShardingAlgorithmStatementUpdater.java | 17 +++-----
.../DropShardingAuditorStatementUpdater.java | 8 ++--
...opShardingBindingTableRuleStatementUpdater.java | 6 +--
...ShardingBroadcastTableRuleStatementUpdater.java | 6 +--
.../DropShardingKeyGeneratorStatementUpdater.java | 8 ++--
.../DropShardingTableRuleStatementUpdater.java | 10 ++---
.../checker/ShardingRuleStatementCheckerTest.java | 35 ++++++---------
...efaultShardingStrategyStatementUpdaterTest.java | 8 ++--
...AlterShardingAlgorithmStatementUpdaterTest.java | 4 +-
.../AlterShardingAuditorStatementUpdaterTest.java | 4 +-
...rdingBindingTableRulesStatementUpdaterTest.java | 4 +-
...dingBroadcastTableRuleStatementUpdaterTest.java | 4 +-
...erShardingKeyGeneratorStatementUpdaterTest.java | 4 +-
...efaultShardingStrategyStatementUpdaterTest.java | 4 +-
.../CreateShardingAuditorStatementUpdaterTest.java | 6 +--
...ardingBindingTableRuleStatementUpdaterTest.java | 4 +-
...teShardingKeyGeneratorStatementUpdaterTest.java | 6 +--
...efaultShardingStrategyStatementUpdaterTest.java | 6 +--
.../DropShardingAlgorithmStatementUpdaterTest.java | 6 +--
.../DropShardingAuditorStatementUpdaterTest.java | 8 ++--
...ardingBindingTableRuleStatementUpdaterTest.java | 6 +--
...dingBroadcastTableRuleStatementUpdaterTest.java | 8 ++--
...opShardingKeyGeneratorStatementUpdaterTest.java | 8 ++--
.../DropShardingTableRuleStatementUpdaterTest.java | 6 +--
.../infra/distsql/exception/DistSQLException.java | 11 +++--
.../resource/DuplicateResourceException.java | 4 +-
...sException.java => EmptyResourceException.java} | 12 +++---
.../resource/InvalidResourcesException.java | 4 +-
...java => MissingRequiredResourcesException.java} | 14 +++---
.../ResourceDefinitionViolationException.java | 5 ++-
.../resource/ResourceInUsedException.java | 8 ++--
.../exception/rule/AlgorithmInUsedException.java | 6 ++-
.../exception/rule/AuditorInUsedException.java | 32 --------------
...ption.java => DuplicateAlgorithmException.java} | 12 +++---
.../exception/rule/DuplicateAuditorException.java | 32 --------------
.../rule/DuplicateKeyGeneratorException.java | 32 --------------
.../exception/rule/DuplicateRuleException.java | 8 ++--
.../InvalidAlgorithmConfigurationException.java | 8 ++--
.../rule/InvalidRuleConfigurationException.java | 10 +++--
.../rule/MissingRequiredAlgorithmException.java | 46 ++++++++++++++++++++
.../rule/MissingRequiredRuleException.java | 50 ++++++++++++++++++++++
.../rule/RequiredAlgorithmMissedException.java | 44 -------------------
.../rule/RequiredAuditorMissedException.java | 29 -------------
.../rule/RequiredKeyGeneratorMissedException.java | 29 -------------
.../rule/RequiredRuleMissedException.java | 48 ---------------------
.../rule/RuleDefinitionViolationException.java | 5 ++-
.../exception/rule/RuleDisabledException.java | 4 +-
.../exception/rule/RuleEnabledException.java | 4 +-
.../exception/rule/RuleInUsedException.java | 8 ++--
.../update/AlterTrafficRuleStatementUpdater.java | 4 +-
.../update/DropTrafficRuleStatementUpdater.java | 4 +-
.../AlterTrafficRuleStatementUpdaterTest.java | 10 ++---
.../DropTrafficRuleStatementUpdaterTest.java | 8 ++--
.../communication/DatabaseCommunicationEngine.java | 11 ++---
...aseDiscoveryRuleConfigurationImportChecker.java | 8 ++--
...iteSplittingRuleConfigurationImportChecker.java | 6 +--
.../ShardingRuleConfigurationImportChecker.java | 4 +-
.../SetReadwriteSplittingStatusHandler.java | 4 +-
.../rdl/resource/AlterResourceBackendHandler.java | 4 +-
.../rdl/resource/DropResourceBackendHandler.java | 4 +-
...lterDefaultSingleTableRuleStatementUpdater.java | 10 ++---
...eateDefaultSingleTableRuleStatementUpdater.java | 4 +-
...DropDefaultSingleTableRuleStatementUpdater.java | 4 +-
.../distsql/DistSQLBackendHandlerFactoryTest.java | 6 +--
.../resource/AlterResourceBackendHandlerTest.java | 6 +--
.../AlterDefaultSingleTableRuleUpdaterTest.java | 16 +++----
.../CreateDefaultSingleTableRuleUpdaterTest.java | 8 ++--
.../DropDefaultSingleTableRuleUpdaterTest.java | 12 +++---
122 files changed, 537 insertions(+), 643 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 edd11a95b36..31ceeac5379 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
@@ -114,6 +114,26 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| HY000 | 18093 | Can not poll event because of binlog sync channel already closed |
| HY000 | 18094 | Task \`%s\` execute failed |
+### DistSQL
+
+| SQL State | Vendor Code | 错误信息 |
+| --------- | ----------- | ------ |
+| 44000 | 19000 | Can not process invalid resources, error message is: %s |
+| 44000 | 19001 | Resources \`%s\` do not exist in database \`%s\` |
+| 44000 | 19002 | There is no resource in the database \`%s\` |
+| 44000 | 19003 | Resource \`%s\` is still used by \`%s\` |
+| 44000 | 19004 | Duplicate resource names \`%s\` |
+| 44000 | 19100 | Invalid \`%s\` rule \`%s\`, error message is: %s |
+| 44000 | 19101 | %s rules \`%s\` do not exist in database \`%s\` |
+| 44000 | 19102 | %s rules \`%s\` in database \`%s\` are still in used |
+| 44000 | 19103 | %s rule \`%s\` has been enabled in database \`%s\` |
+| 44000 | 19104 | %s rule \`%s\` has been disabled in database \`%s\` |
+| 44000 | 19105 | Duplicate %s rule names \`%s\` in database \`%s\` |
+| 44000 | 19150 | Invalid %s algorithm(s) \`%s\` |
+| 44000 | 19151 | %s algorithm(s) \`%s\` do not exist in database \`%s\` |
+| 44000 | 19152 | %s algorithms \`%s\` in database \`%s\` are still in used |
+| 44000 | 19153 | Duplicate %s algorithms \`%s\` 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 e66f92311bd..83c147bfb8c 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
@@ -114,6 +114,26 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
| HY000 | 18093 | Can not poll event because of binlog sync channel already closed |
| HY000 | 18094 | Task \`%s\` execute failed |
+### DistSQL
+
+| SQL State | Vendor Code | Reason |
+| --------- | ----------- | ------ |
+| 44000 | 19000 | Can not process invalid resources, error message is: %s |
+| 44000 | 19001 | Resources \`%s\` do not exist in database \`%s\` |
+| 44000 | 19002 | There is no resource in the database \`%s\` |
+| 44000 | 19003 | Resource \`%s\` is still used by \`%s\` |
+| 44000 | 19004 | Duplicate resource names \`%s\` |
+| 44000 | 19100 | Invalid \`%s\` rule \`%s\`, error message is: %s |
+| 44000 | 19101 | %s rules \`%s\` do not exist in database \`%s\` |
+| 44000 | 19102 | %s rules \`%s\` in database \`%s\` are still in used |
+| 44000 | 19103 | %s rule \`%s\` has been enabled in database \`%s\` |
+| 44000 | 19104 | %s rule \`%s\` has been disabled in database \`%s\` |
+| 44000 | 19105 | Duplicate %s rule names \`%s\` in database \`%s\` |
+| 44000 | 19150 | Invalid %s algorithm(s) \`%s\` |
+| 44000 | 19151 | %s algorithm(s) \`%s\` do not exist in database \`%s\` |
+| 44000 | 19152 | %s algorithms \`%s\` in database \`%s\` are still in used |
+| 44000 | 19153 | Duplicate %s algorithms \`%s\` in database \`%s\` |
+
## Feature Exception
### Data Sharding
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryHeartbeatStatementUpdater.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDataba [...]
index 96ce1a8dc23..755bade35c5 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryHeartbeatStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryHeartbeatStatementUpdater.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDisc
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.AlterDatabaseDiscoveryHeartbeatStatement;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -52,7 +52,7 @@ public final class AlterDatabaseDiscoveryHeartbeatStatementUpdater implements Ru
public void checkSQLStatement(final ShardingSphereDatabase database, final AlterDatabaseDiscoveryHeartbeatStatement sqlStatement,
final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws DistSQLException {
String databaseName = database.getName();
- ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new RequiredRuleMissedException(RULE_TYPE, databaseName));
+ ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new MissingRequiredRuleException(RULE_TYPE, databaseName));
checkDuplicateHeartbeat(databaseName, sqlStatement);
checkNotExistHeartbeat(databaseName, sqlStatement, currentRuleConfig);
}
@@ -62,7 +62,7 @@ public final class AlterDatabaseDiscoveryHeartbeatStatementUpdater implements Ru
Collection<String> currentHeartbeats = currentRuleConfig.getDiscoveryHeartbeats().keySet();
Collection<String> notExistHeartbeats = sqlStatement.getHeartbeats().stream().map(DatabaseDiscoveryHeartbeatSegment::getHeartbeatName)
.filter(each -> !currentHeartbeats.contains(each)).collect(Collectors.toSet());
- ShardingSpherePreconditions.checkState(notExistHeartbeats.isEmpty(), () -> new RequiredRuleMissedException(RULE_TYPE, databaseName, notExistHeartbeats));
+ ShardingSpherePreconditions.checkState(notExistHeartbeats.isEmpty(), () -> new MissingRequiredRuleException(RULE_TYPE, databaseName, notExistHeartbeats));
}
private void checkDuplicateHeartbeat(final String databaseName, final AlterDatabaseDiscoveryHeartbeatStatement sqlStatement) throws DistSQLException {
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDis [...]
index d2141f21d18..9f3d52fab78 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdater.java
@@ -28,10 +28,10 @@ import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.AlterDatab
import org.apache.shardingsphere.dbdiscovery.factory.DatabaseDiscoveryProviderAlgorithmFactory;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
@@ -61,14 +61,14 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdater implements RuleDef
}
private void checkCurrentRuleConfiguration(final String databaseName, final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws DistSQLException {
- ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new RequiredRuleMissedException("database discovery", databaseName));
+ ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new MissingRequiredRuleException("database discovery", databaseName));
}
private void checkToBeAlteredRules(final String databaseName,
final AlterDatabaseDiscoveryRuleStatement sqlStatement, final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws DistSQLException {
Collection<String> currentRuleNames = currentRuleConfig.getDataSources().stream().map(DatabaseDiscoveryDataSourceRuleConfiguration::getGroupName).collect(Collectors.toSet());
Collection<String> notExistedRuleNames = getToBeAlteredRuleNames(sqlStatement).stream().filter(each -> !currentRuleNames.contains(each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistedRuleNames.isEmpty(), () -> new RequiredRuleMissedException("database discovery", databaseName, notExistedRuleNames));
+ ShardingSpherePreconditions.checkState(notExistedRuleNames.isEmpty(), () -> new MissingRequiredRuleException("database discovery", databaseName, notExistedRuleNames));
}
private Collection<String> getToBeAlteredRuleNames(final AlterDatabaseDiscoveryRuleStatement sqlStatement) {
@@ -77,7 +77,7 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdater implements RuleDef
private void checkToBeAlteredResources(final String databaseName, final AlterDatabaseDiscoveryRuleStatement sqlStatement, final ShardingSphereResource resource) throws DistSQLException {
Collection<String> notExistedResources = resource.getNotExistedResources(getToBeAlteredResourceNames(sqlStatement));
- ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new RequiredResourceMissedException(databaseName, notExistedResources));
+ ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistedResources));
}
private Collection<String> getToBeAlteredResourceNames(final AlterDatabaseDiscoveryRuleStatement sqlStatement) {
@@ -101,7 +101,7 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdater implements RuleDef
invalidInput.add(each.getDiscoveryHeartbeatName());
}
});
- ShardingSpherePreconditions.checkState(invalidInput.isEmpty(), () -> new RequiredAlgorithmMissedException("database discovery", invalidInput));
+ ShardingSpherePreconditions.checkState(invalidInput.isEmpty(), () -> new MissingRequiredAlgorithmException("database discovery", invalidInput));
}
@Override
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryTypeStatementUpdater.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDis [...]
index 60f7a19e02e..c65c51b869b 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryTypeStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryTypeStatementUpdater.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -57,12 +57,12 @@ public final class AlterDatabaseDiscoveryTypeStatementUpdater implements RuleDef
Collection<String> existTypes = currentRuleConfig.getDiscoveryTypes().keySet();
Collection<String> notExistTypes = sqlStatement.getProviders().stream().map(DatabaseDiscoveryProviderAlgorithmSegment::getDiscoveryProviderName)
.filter(each -> !existTypes.contains(each)).collect(Collectors.toSet());
- ShardingSpherePreconditions.checkState(notExistTypes.isEmpty(), () -> new RequiredRuleMissedException(RULE_TYPE, databaseName));
+ ShardingSpherePreconditions.checkState(notExistTypes.isEmpty(), () -> new MissingRequiredRuleException(RULE_TYPE, databaseName));
}
private void checkCurrentRuleConfiguration(final String databaseName, final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws DistSQLException {
- ShardingSpherePreconditions.checkState(null != currentRuleConfig, () -> new RequiredRuleMissedException(RULE_TYPE, databaseName));
+ ShardingSpherePreconditions.checkState(null != currentRuleConfig, () -> new MissingRequiredRuleException(RULE_TYPE, databaseName));
}
private void checkDuplicateDiscoveryType(final String databaseName, final AlterDatabaseDiscoveryTypeStatement sqlStatement) throws DistSQLException {
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseD [...]
index ea7cbbb8125..575edbab967 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdater.java
@@ -26,10 +26,10 @@ import org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDisc
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.CreateDatabaseDiscoveryRuleStatement;
import org.apache.shardingsphere.dbdiscovery.factory.DatabaseDiscoveryProviderAlgorithmFactory;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionCreateUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
@@ -75,13 +75,11 @@ public final class CreateDatabaseDiscoveryRuleStatementUpdater implements RuleDe
.entrySet().stream().filter(entry -> entry.getValue() > 1).map(Entry::getKey).collect(Collectors.toSet());
}
- private void checkResources(final String databaseName, final CreateDatabaseDiscoveryRuleStatement sqlStatement, final ShardingSphereResource resource) throws RequiredResourceMissedException {
+ private void checkResources(final String databaseName, final CreateDatabaseDiscoveryRuleStatement sqlStatement, final ShardingSphereResource resource) throws MissingRequiredResourcesException {
Collection<String> resources = new LinkedHashSet<>();
sqlStatement.getRules().forEach(each -> resources.addAll(each.getDataSources()));
Collection<String> notExistResources = resource.getNotExistedResources(resources);
- if (!notExistResources.isEmpty()) {
- throw new RequiredResourceMissedException(databaseName, notExistResources);
- }
+ ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistResources));
}
private void checkDiscoverTypeAndHeartbeat(final String databaseName,
@@ -100,7 +98,7 @@ public final class CreateDatabaseDiscoveryRuleStatementUpdater implements RuleDe
invalidInput.add(each.getDiscoveryHeartbeatName());
}
});
- ShardingSpherePreconditions.checkState(invalidInput.isEmpty(), () -> new RequiredAlgorithmMissedException(RULE_TYPE, databaseName, invalidInput));
+ ShardingSpherePreconditions.checkState(invalidInput.isEmpty(), () -> new MissingRequiredAlgorithmException(RULE_TYPE, databaseName, invalidInput));
}
@Override
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryHeartbeatStatementUpdater.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabase [...]
index 85d659a341f..770a1605e94 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryHeartbeatStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryHeartbeatStatementUpdater.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.dbdiscovery.api.config.DatabaseDiscoveryRuleCon
import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.DropDatabaseDiscoveryHeartbeatStatement;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleInUsedException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -50,7 +50,7 @@ public final class DropDatabaseDiscoveryHeartbeatStatementUpdater implements Rul
if (sqlStatement.isIfExists()) {
return;
}
- ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new RequiredRuleMissedException(RULE_TYPE, databaseName));
+ ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new MissingRequiredRuleException(RULE_TYPE, databaseName));
checkIsExist(databaseName, sqlStatement, currentRuleConfig);
}
@@ -58,7 +58,7 @@ public final class DropDatabaseDiscoveryHeartbeatStatementUpdater implements Rul
final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws DistSQLException {
Collection<String> currentRuleNames = currentRuleConfig.getDiscoveryHeartbeats().keySet();
Collection<String> notExistedRuleNames = sqlStatement.getHeartbeatNames().stream().filter(each -> !currentRuleNames.contains(each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistedRuleNames.isEmpty(), () -> new RequiredRuleMissedException(RULE_TYPE, databaseName, notExistedRuleNames));
+ ShardingSpherePreconditions.checkState(notExistedRuleNames.isEmpty(), () -> new MissingRequiredRuleException(RULE_TYPE, databaseName, notExistedRuleNames));
}
private void checkIsInUse(final String databaseName, final DropDatabaseDiscoveryHeartbeatStatement sqlStatement,
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDisco [...]
index 79c3a166ceb..663145b4b15 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryRuleStatementUpdater.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.DropDataba
import org.apache.shardingsphere.infra.distsql.constant.ExportableConstants;
import org.apache.shardingsphere.infra.distsql.constant.ExportableItemConstants;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleInUsedException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -58,7 +58,7 @@ public final class DropDatabaseDiscoveryRuleStatementUpdater implements RuleDefi
if (sqlStatement.isIfExists()) {
return;
}
- ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new RequiredRuleMissedException(RULE_TYPE, databaseName));
+ ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new MissingRequiredRuleException(RULE_TYPE, databaseName));
checkIsExist(databaseName, sqlStatement, currentRuleConfig);
}
@@ -66,7 +66,7 @@ public final class DropDatabaseDiscoveryRuleStatementUpdater implements RuleDefi
final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws DistSQLException {
Collection<String> currentRuleNames = currentRuleConfig.getDataSources().stream().map(DatabaseDiscoveryDataSourceRuleConfiguration::getGroupName).collect(Collectors.toList());
Collection<String> notExistedRuleNames = sqlStatement.getRuleNames().stream().filter(each -> !currentRuleNames.contains(each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistedRuleNames.isEmpty(), () -> new RequiredRuleMissedException(RULE_TYPE, databaseName));
+ ShardingSpherePreconditions.checkState(notExistedRuleNames.isEmpty(), () -> new MissingRequiredRuleException(RULE_TYPE, databaseName));
}
private void checkIsInUse(final String databaseName, final DropDatabaseDiscoveryRuleStatement sqlStatement, final ShardingSphereDatabase database) throws DistSQLException {
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryTypeStatementUpdater.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDisco [...]
index 14f0c66f207..4b5599425d8 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryTypeStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryTypeStatementUpdater.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.dbdiscovery.api.config.DatabaseDiscoveryRuleCon
import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.DropDatabaseDiscoveryTypeStatement;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleInUsedException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -50,7 +50,7 @@ public final class DropDatabaseDiscoveryTypeStatementUpdater implements RuleDefi
if (sqlStatement.isIfExists()) {
return;
}
- ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new RequiredRuleMissedException(RULE_TYPE, databaseName));
+ ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new MissingRequiredRuleException(RULE_TYPE, databaseName));
checkIsExist(databaseName, sqlStatement, currentRuleConfig);
}
@@ -58,7 +58,7 @@ public final class DropDatabaseDiscoveryTypeStatementUpdater implements RuleDefi
final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws DistSQLException {
Collection<String> currentRuleNames = currentRuleConfig.getDiscoveryTypes().keySet();
Collection<String> notExistedRuleNames = sqlStatement.getTypes().stream().filter(each -> !currentRuleNames.contains(each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistedRuleNames.isEmpty(), () -> new RequiredRuleMissedException(RULE_TYPE, databaseName, notExistedRuleNames));
+ ShardingSpherePreconditions.checkState(notExistedRuleNames.isEmpty(), () -> new MissingRequiredRuleException(RULE_TYPE, databaseName, notExistedRuleNames));
}
private void checkIsInUse(final String databaseName, final DropDatabaseDiscoveryTypeStatement sqlStatement,
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryHeartbeatStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDa [...]
index b271a1b874a..4727ad5bc6b 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryHeartbeatStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryHeartbeatStatementUpdaterTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDisc
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.AlterDatabaseDiscoveryHeartbeatStatement;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -55,7 +55,7 @@ public final class AlterDatabaseDiscoveryHeartbeatStatementUpdaterTest {
new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap()));
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithNotExistDiscoveryHeartbeatName() throws DistSQLException {
DatabaseDiscoveryHeartbeatSegment segment = new DatabaseDiscoveryHeartbeatSegment("heartbeat", createProperties("key", "value"));
DatabaseDiscoveryRuleConfiguration config = new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.singletonMap("heartbeat1", null), Collections.emptyMap());
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update [...]
index d69e548d85c..1643129cf8c 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -64,7 +64,7 @@ public final class AlterDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest {
new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceRuleConfig), Collections.emptyMap(), Collections.emptyMap()));
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithNotExist() throws DistSQLException {
List<DatabaseDiscoveryProviderAlgorithmSegment> algorithmSegments =
Collections.singletonList(new DatabaseDiscoveryProviderAlgorithmSegment("discovery_type_1", new AlgorithmSegment("DISTSQL.FIXTURE", new Properties())));
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabas [...]
index e1f1c07eb81..189a1d49d93 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
@@ -24,10 +24,10 @@ import org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDisc
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.AlterDatabaseDiscoveryRuleStatement;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
import org.junit.Before;
@@ -66,19 +66,19 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdaterTest {
when(database.getResource()).thenReturn(resource);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws DistSQLException {
updater.checkSQLStatement(database, new AlterDatabaseDiscoveryRuleStatement(Collections.emptyList()), null);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutToBeAlteredDatabaseDiscoveryRule() throws DistSQLException {
DatabaseDiscoveryConstructionSegment segment = new DatabaseDiscoveryConstructionSegment("readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), "", "");
updater.checkSQLStatement(database, new AlterDatabaseDiscoveryRuleStatement(Collections.singletonList(segment)),
new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap()));
}
- @Test(expected = RequiredResourceMissedException.class)
+ @Test(expected = MissingRequiredResourcesException.class)
public void assertCheckSQLStatementWithoutExistedResources() throws DistSQLException {
when(resource.getNotExistedResources(any())).thenReturn(Collections.singleton("ds0"));
DatabaseDiscoveryConstructionSegment segment = new DatabaseDiscoveryConstructionSegment("readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), "readwrite_ds_mgr", "readwrite_ds_heartbeat");
@@ -98,7 +98,7 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdaterTest {
updater.checkSQLStatement(database, new AlterDatabaseDiscoveryRuleStatement(Collections.singleton(segment)), ruleConfig);
}
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertCheckSQLStatementWithNotExistDiscoveryTypeName() throws DistSQLException {
DatabaseDiscoveryConstructionSegment segment = new DatabaseDiscoveryConstructionSegment("readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), "not_exist_discovery_type_name", "");
DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("readwrite_ds", Collections.emptyList(), "ha-heartbeat", "TEST");
@@ -107,7 +107,7 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdaterTest {
updater.checkSQLStatement(database, new AlterDatabaseDiscoveryRuleStatement(Collections.singleton(segment)), ruleConfig);
}
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertCheckSQLStatementWithNotExistDiscoveryHeartbeatName() throws DistSQLException {
DatabaseDiscoveryConstructionSegment segment = new DatabaseDiscoveryConstructionSegment(
"readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), "discovery_type_name", "not_exist_heartbeat_name");
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatab [...]
index c06455c2769..8698dba5b63 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java
@@ -24,10 +24,10 @@ import org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDisc
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.CreateDatabaseDiscoveryRuleStatement;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
import org.junit.Before;
@@ -74,7 +74,7 @@ public final class CreateDatabaseDiscoveryRuleStatementUpdaterTest {
new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceRuleConfig), Collections.emptyMap(), Collections.emptyMap()));
}
- @Test(expected = RequiredResourceMissedException.class)
+ @Test(expected = MissingRequiredResourcesException.class)
public void assertCheckSQLStatementWithoutExistedResources() throws DistSQLException {
when(resource.getNotExistedResources(any())).thenReturn(Collections.singleton("ds_read_0"));
DatabaseDiscoveryConstructionSegment segment = new DatabaseDiscoveryConstructionSegment("readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), "", "");
@@ -88,14 +88,14 @@ public final class CreateDatabaseDiscoveryRuleStatementUpdaterTest {
updater.checkSQLStatement(database, new CreateDatabaseDiscoveryRuleStatement(Collections.singleton(segment)), null);
}
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertCheckSQLStatementWithNotExistDiscoveryTypeName() throws DistSQLException {
DatabaseDiscoveryConstructionSegment segment = new DatabaseDiscoveryConstructionSegment("readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), "not_exist_discovery_type_name", "");
DatabaseDiscoveryRuleConfiguration ruleConfig = new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap());
updater.checkSQLStatement(database, new CreateDatabaseDiscoveryRuleStatement(Collections.singleton(segment)), ruleConfig);
}
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertCheckSQLStatementWithNotExistDiscoveryHeartbeatName() throws DistSQLException {
DatabaseDiscoveryConstructionSegment segment = new DatabaseDiscoveryConstructionSegment(
"readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), "discovery_type_name", "not_exist_heartbeat_name");
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryHeartbeatStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropData [...]
index 984399c25c2..4905dec65fd 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryHeartbeatStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryHeartbeatStatementUpdaterTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDa
import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryHeartBeatConfiguration;
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.DropDatabaseDiscoveryHeartbeatStatement;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleInUsedException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.junit.Test;
@@ -49,12 +49,12 @@ public final class DropDatabaseDiscoveryHeartbeatStatementUpdaterTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ShardingSphereDatabase database;
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentHeartbeat() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement(), null);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutToBeDroppedHeartbeat() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement(), new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap()));
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/ [...]
index 8cb5a55dacd..0f949c7a850 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDa
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.DropDatabaseDiscoveryTypeStatement;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleInUsedException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.junit.Test;
@@ -49,12 +49,12 @@ public final class DropDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ShardingSphereDatabase database;
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentType() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement(), null);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutToBeDroppedTypes() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement(), new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap()));
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseD [...]
index bf550c593d9..99158634500 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryRuleStatementUpdaterTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.constant.ExportableConstants;
import org.apache.shardingsphere.infra.distsql.constant.ExportableItemConstants;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleInUsedException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
@@ -60,12 +60,12 @@ public final class DropDatabaseDiscoveryRuleStatementUpdaterTest {
when(database.getRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.emptyList()));
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement(), null);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutToBeDroppedRules() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement(), new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap()));
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdater.java
index 8d0fe617085..6c9c389cf32 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdater.java
@@ -29,7 +29,7 @@ import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidRuleConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -53,9 +53,9 @@ public final class AlterEncryptRuleStatementUpdater implements RuleDefinitionAlt
checkToBeAlteredEncryptors(sqlStatement);
}
- private void checkCurrentRuleConfiguration(final String databaseName, final EncryptRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
+ private void checkCurrentRuleConfiguration(final String databaseName, final EncryptRuleConfiguration currentRuleConfig) throws MissingRequiredRuleException {
if (null == currentRuleConfig) {
- throw new RequiredRuleMissedException("Encrypt", databaseName);
+ throw new MissingRequiredRuleException("Encrypt", databaseName);
}
}
@@ -63,7 +63,7 @@ public final class AlterEncryptRuleStatementUpdater implements RuleDefinitionAlt
Collection<String> currentEncryptTableNames = currentRuleConfig.getTables().stream().map(EncryptTableRuleConfiguration::getName).collect(Collectors.toList());
Collection<String> notExistEncryptTableNames = getToBeAlteredEncryptTableNames(sqlStatement).stream().filter(each -> !currentEncryptTableNames.contains(each)).collect(Collectors.toList());
if (!notExistEncryptTableNames.isEmpty()) {
- throw new RequiredRuleMissedException("Encrypt", databaseName, notExistEncryptTableNames);
+ throw new MissingRequiredRuleException("Encrypt", databaseName, notExistEncryptTableNames);
}
checkDataType(sqlStatement);
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleStatementUpdater.java
index 93e56b5698e..e8765a5f45b 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleStatementUpdater.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.distsql.parser.statement.DropEncryptRuleStatement;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -45,10 +45,10 @@ public final class DropEncryptRuleStatementUpdater implements RuleDefinitionDrop
if (sqlStatement.isIfExists()) {
return;
}
- ShardingSpherePreconditions.checkState(isExistRuleConfig(currentRuleConfig), () -> new RequiredRuleMissedException("Encrypt", databaseName));
+ ShardingSpherePreconditions.checkState(isExistRuleConfig(currentRuleConfig), () -> new MissingRequiredRuleException("Encrypt", databaseName));
Collection<String> currentEncryptTableNames = currentRuleConfig.getTables().stream().map(EncryptTableRuleConfiguration::getName).collect(Collectors.toList());
Collection<String> notExistedTableNames = sqlStatement.getTables().stream().filter(each -> !currentEncryptTableNames.contains(each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistedTableNames.isEmpty(), () -> new RequiredRuleMissedException("Encrypt", databaseName, notExistedTableNames));
+ ShardingSpherePreconditions.checkState(notExistedTableNames.isEmpty(), () -> new MissingRequiredRuleException("Encrypt", databaseName, notExistedTableNames));
}
@Override
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdaterTest.java
index d341964d2cc..92d0ceeb51e 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdaterTest.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.encrypt.distsql.parser.statement.AlterEncryptRu
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidRuleConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,12 +46,12 @@ public final class AlterEncryptRuleStatementUpdaterTest {
private final AlterEncryptRuleStatementUpdater updater = new AlterEncryptRuleStatementUpdater();
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("MD5"), null);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutToBeAlteredRules() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("MD5"), new EncryptRuleConfiguration(Collections.emptyList(), Collections.emptyMap()));
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleStatementUpdaterTest.java
index 25b3906f62e..bd1976fa346 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleStatementUpdaterTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfigu
import org.apache.shardingsphere.encrypt.distsql.parser.statement.DropEncryptRuleStatement;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -52,12 +52,12 @@ public final class DropEncryptRuleStatementUpdaterTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ShardingSphereDatabase database;
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("t_encrypt"), null);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutToBeDroppedRule() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("t_encrypt"), new EncryptRuleConfiguration(Collections.emptyList(), Collections.emptyMap()));
}
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/r [...]
index 8b5c3f929fe..b93ea12f0b5 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdater.java
@@ -22,9 +22,9 @@ import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.distsql.constant.ExportableConstants;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.identifier.type.exportable.ExportableRule;
@@ -64,18 +64,18 @@ public final class AlterReadwriteSplittingRuleStatementUpdater implements RuleDe
checkToBeAlteredLoadBalancer(sqlStatement);
}
- private void checkCurrentRuleConfiguration(final String databaseName, final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
+ private void checkCurrentRuleConfiguration(final String databaseName, final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws MissingRequiredRuleException {
if (null == currentRuleConfig) {
- throw new RequiredRuleMissedException("Readwrite splitting", databaseName);
+ throw new MissingRequiredRuleException("Readwrite splitting", databaseName);
}
}
private void checkToBeAlteredRules(final String databaseName, final AlterReadwriteSplittingRuleStatement sqlStatement,
- final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
+ final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws MissingRequiredRuleException {
Collection<String> currentRuleNames = currentRuleConfig.getDataSources().stream().map(ReadwriteSplittingDataSourceRuleConfiguration::getName).collect(Collectors.toSet());
Collection<String> notExistedRuleNames = getToBeAlteredRuleNames(sqlStatement).stream().filter(each -> !currentRuleNames.contains(each)).collect(Collectors.toList());
if (!notExistedRuleNames.isEmpty()) {
- throw new RequiredRuleMissedException("Readwrite splitting", databaseName, notExistedRuleNames);
+ throw new MissingRequiredRuleException("Readwrite splitting", databaseName, notExistedRuleNames);
}
}
@@ -103,10 +103,10 @@ public final class AlterReadwriteSplittingRuleStatementUpdater implements RuleDe
}
});
Collection<String> notExistResources = database.getResource().getNotExistedResources(requireResources);
- ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new RequiredResourceMissedException(databaseName, notExistResources));
+ ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistResources));
Collection<String> logicResources = getLogicResources(database);
Set<String> notExistLogicResources = requireDiscoverableResources.stream().filter(each -> !logicResources.contains(each)).collect(Collectors.toSet());
- ShardingSpherePreconditions.checkState(notExistLogicResources.isEmpty(), () -> new RequiredResourceMissedException(databaseName, notExistLogicResources));
+ ShardingSpherePreconditions.checkState(notExistLogicResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistLogicResources));
}
@SuppressWarnings("unchecked")
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/ [...]
index c689ee33d04..c004041a2e0 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdater.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.distsql.constant.ExportableConstants;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidRuleConfigurationException;
@@ -94,10 +94,10 @@ public final class CreateReadwriteSplittingRuleStatementUpdater implements RuleD
}
});
Collection<String> notExistResources = database.getResource().getNotExistedResources(requireResources);
- ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new RequiredResourceMissedException(databaseName, notExistResources));
+ ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistResources));
Collection<String> logicResources = getLogicResources(database);
Collection<String> notExistLogicResources = requireDiscoverableResources.stream().filter(each -> !logicResources.contains(each)).collect(Collectors.toSet());
- ShardingSpherePreconditions.checkState(notExistLogicResources.isEmpty(), () -> new RequiredResourceMissedException(databaseName, notExistLogicResources));
+ ShardingSpherePreconditions.checkState(notExistLogicResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistLogicResources));
}
@SuppressWarnings("unchecked")
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/re [...]
index 7321aa8d00c..d714413c931 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleStatementUpdater.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleInUsedException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
@@ -53,21 +53,21 @@ public final class DropReadwriteSplittingRuleStatementUpdater implements RuleDef
checkToBeDroppedInUsed(database, sqlStatement);
}
- private void checkCurrentRuleConfiguration(final String databaseName, final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
+ private void checkCurrentRuleConfiguration(final String databaseName, final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws MissingRequiredRuleException {
if (null == currentRuleConfig) {
- throw new RequiredRuleMissedException("Readwrite splitting", databaseName);
+ throw new MissingRequiredRuleException("Readwrite splitting", databaseName);
}
}
private void checkToBeDroppedRuleNames(final String databaseName, final DropReadwriteSplittingRuleStatement sqlStatement,
- final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
+ final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws MissingRequiredRuleException {
if (sqlStatement.isIfExists()) {
return;
}
Collection<String> currentRuleNames = currentRuleConfig.getDataSources().stream().map(ReadwriteSplittingDataSourceRuleConfiguration::getName).collect(Collectors.toList());
Collection<String> notExistedRuleNames = sqlStatement.getRuleNames().stream().filter(each -> !currentRuleNames.contains(each)).collect(Collectors.toList());
if (!notExistedRuleNames.isEmpty()) {
- throw new RequiredRuleMissedException("Readwrite splitting", databaseName, sqlStatement.getRuleNames());
+ throw new MissingRequiredRuleException("Readwrite splitting", databaseName, sqlStatement.getRuleNames());
}
}
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphe [...]
index 12f9d04f8a1..837d4486455 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
@@ -19,10 +19,10 @@ package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import org.apache.shardingsphere.infra.distsql.constant.ExportableConstants;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidRuleConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.rule.identifier.type.exportable.ExportableRule;
@@ -65,23 +65,23 @@ public final class AlterReadwriteSplittingRuleStatementUpdaterTest {
when(database.getResource()).thenReturn(resource);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("TEST"), null);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutToBeAlteredRules() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("TEST"), new ReadwriteSplittingRuleConfiguration(Collections.emptyList(), Collections.emptyMap()));
}
- @Test(expected = RequiredResourceMissedException.class)
+ @Test(expected = MissingRequiredResourcesException.class)
public void assertCheckSQLStatementWithoutExistedResources() throws DistSQLException {
when(resource.getNotExistedResources(any())).thenReturn(Collections.singleton("read_ds_0"));
updater.checkSQLStatement(database, createSQLStatement("TEST"), createCurrentRuleConfiguration());
}
- @Test(expected = RequiredResourceMissedException.class)
+ @Test(expected = MissingRequiredResourcesException.class)
public void assertCheckSQLStatementWithoutExistedAutoAwareResources() throws DistSQLException {
ExportableRule exportableRule = mock(ExportableRule.class);
when(exportableRule.getExportData()).thenReturn(Collections.singletonMap(ExportableConstants.EXPORT_DB_DISCOVERY_PRIMARY_DATA_SOURCES, Collections.singletonMap("ms_group", "ds_0")));
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsph [...]
index fb06504deff..46b13158c4d 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import org.apache.shardingsphere.infra.distsql.constant.ExportableConstants;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidRuleConfigurationException;
@@ -89,13 +89,13 @@ public final class CreateReadwriteSplittingRuleStatementUpdaterTest {
updater.checkSQLStatement(database, createSQLStatement("write_ds", "TEST"), createCurrentRuleConfiguration());
}
- @Test(expected = RequiredResourceMissedException.class)
+ @Test(expected = MissingRequiredResourcesException.class)
public void assertCheckSQLStatementWithoutExistedResources() throws DistSQLException {
when(resource.getNotExistedResources(any())).thenReturn(Arrays.asList("read_ds_0", "read_ds_1"));
updater.checkSQLStatement(database, createSQLStatement("TEST"), null);
}
- @Test(expected = RequiredResourceMissedException.class)
+ @Test(expected = MissingRequiredResourcesException.class)
public void assertCheckSQLStatementWithoutExistedAutoAwareResources() throws DistSQLException {
ExportableRule exportableRule = mock(ExportableRule.class);
when(exportableRule.getExportData()).thenReturn(Collections.singletonMap(ExportableConstants.EXPORT_DB_DISCOVERY_PRIMARY_DATA_SOURCES, Collections.singletonMap("ms_group", "ds_0")));
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingspher [...]
index df9a41d9f64..2838ba75778 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleStatementUpdaterTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleInUsedException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -56,12 +56,12 @@ public final class DropReadwriteSplittingRuleStatementUpdaterTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ShardingSphereDatabase database;
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement(database, createSQLStatement(), null);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutToBeDroppedRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement(database, createSQLStatement(), new ReadwriteSplittingRuleConfiguration(Collections.emptyList(), Collections.emptyMap()));
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
index 4a085af444e..1125dae7748 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
@@ -19,9 +19,9 @@ package org.apache.shardingsphere.shadow.distsql.handler.checker;
import org.apache.shardingsphere.infra.config.rule.scope.DatabaseRuleConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.shadow.distsql.parser.segment.ShadowAlgorithmSegment;
@@ -47,7 +47,7 @@ public class ShadowRuleStatementChecker {
* @throws DistSQLException DistSQL exception
*/
public static void checkConfigurationExist(final String databaseName, final DatabaseRuleConfiguration config) throws DistSQLException {
- ShardingSpherePreconditions.checkNotNull(config, () -> new RequiredRuleMissedException(SHADOW, databaseName));
+ ShardingSpherePreconditions.checkNotNull(config, () -> new MissingRequiredRuleException(SHADOW, databaseName));
}
/**
@@ -59,7 +59,7 @@ public class ShadowRuleStatementChecker {
*/
public static void checkResourceExist(final Collection<String> resources, final ShardingSphereDatabase database) throws DistSQLException {
Collection<String> notExistedResources = database.getResource().getNotExistedResources(resources);
- ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new RequiredResourceMissedException(database.getName(), notExistedResources));
+ ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new MissingRequiredResourcesException(database.getName(), notExistedResources));
}
/**
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowAlgorithmStatementUpdater.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowAlgorithmStatementUpdater.java
index 88fbc4ce8ae..a1841f9deff 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowAlgorithmStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowAlgorithmStatementUpdater.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
@@ -70,8 +70,8 @@ public final class AlterShadowAlgorithmStatementUpdater implements RuleDefinitio
private void checkAlgorithms(final String databaseName, final AlterShadowAlgorithmStatement sqlStatement, final ShadowRuleConfiguration currentRuleConfig) throws DistSQLException {
ShadowRuleStatementChecker.checkAlgorithmCompleteness(sqlStatement.getAlgorithms());
Collection<String> requireAlgorithmNames = sqlStatement.getAlgorithms().stream().map(ShadowAlgorithmSegment::getAlgorithmName).collect(Collectors.toList());
- ShadowRuleStatementChecker.checkAnyDuplicate(requireAlgorithmNames, duplicated -> new AlgorithmInUsedException(databaseName, duplicated));
- ShadowRuleStatementChecker.checkAlgorithmExist(requireAlgorithmNames, currentRuleConfig.getShadowAlgorithms().keySet(), different -> new RequiredAlgorithmMissedException(
+ ShadowRuleStatementChecker.checkAnyDuplicate(requireAlgorithmNames, duplicated -> new AlgorithmInUsedException("Shadow", databaseName, duplicated));
+ ShadowRuleStatementChecker.checkAlgorithmExist(requireAlgorithmNames, currentRuleConfig.getShadowAlgorithms().keySet(), different -> new MissingRequiredAlgorithmException(
SHADOW, databaseName, different));
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleStatementUpdater.java
index d8d51281f91..56c0232e8d4 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleStatementUpdater.java
@@ -96,7 +96,7 @@ public final class AlterShadowRuleStatementUpdater implements RuleDefinitionAlte
Collection<ShadowAlgorithmSegment> shadowAlgorithmSegment = ShadowRuleStatementSupporter.getShadowAlgorithmSegment(rules);
ShadowRuleStatementChecker.checkAlgorithmCompleteness(shadowAlgorithmSegment);
Collection<String> requireAlgorithms = ShadowRuleStatementSupporter.getAlgorithmNames(rules);
- ShadowRuleStatementChecker.checkAnyDuplicate(requireAlgorithms, duplicated -> new AlgorithmInUsedException(databaseName, duplicated));
+ ShadowRuleStatementChecker.checkAnyDuplicate(requireAlgorithms, duplicated -> new AlgorithmInUsedException("Shadow", databaseName, duplicated));
}
@Override
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateDefaultShadowAlgorithmStatementUpdater.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateDefaultShadowAlgorithmStatementUpdater.java
index e4f82389f28..434204d0da3 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateDefaultShadowAlgorithmStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateDefaultShadowAlgorithmStatementUpdater.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.shadow.distsql.handler.update;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionCreateUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -53,7 +53,7 @@ public final class CreateDefaultShadowAlgorithmStatementUpdater implements RuleD
private void checkAlgorithmExist(final String databaseName, final CreateDefaultShadowAlgorithmStatement sqlStatement, final ShadowRuleConfiguration currentRuleConfig) throws DistSQLException {
ShardingSpherePreconditions.checkState(currentRuleConfig.getShadowAlgorithms().containsKey(sqlStatement.getAlgorithmName()),
- () -> new RequiredAlgorithmMissedException(databaseName, Collections.singleton(sqlStatement.getAlgorithmName())));
+ () -> new MissingRequiredAlgorithmException(databaseName, Collections.singleton(sqlStatement.getAlgorithmName())));
}
@Override
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmStatementUpdater.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmStatementUpdater.java
index e81c6c7738b..2bea4dd41d8 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmStatementUpdater.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.shadow.distsql.handler.update;
import org.apache.shardingsphere.infra.config.rule.scope.DatabaseRuleConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -53,7 +53,7 @@ public final class DropDefaultShadowAlgorithmStatementUpdater implements RuleDef
private void checkAlgorithm(final String databaseName, final DropDefaultShadowAlgorithmStatement sqlStatement, final ShadowRuleConfiguration currentRuleConfig) throws DistSQLException {
if (!sqlStatement.isIfExists()) {
ShardingSpherePreconditions.checkNotNull(currentRuleConfig.getDefaultShadowAlgorithmName(),
- () -> new RequiredAlgorithmMissedException(SHADOW, databaseName, Collections.singleton("default")));
+ () -> new MissingRequiredAlgorithmException(SHADOW, databaseName, Collections.singleton("default")));
}
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmStatementUpdater.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmStatementUpdater.java
index a517900dc6e..ce24e3f3f45 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmStatementUpdater.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.shadow.distsql.handler.update;
import org.apache.shardingsphere.infra.config.rule.scope.DatabaseRuleConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -62,11 +62,11 @@ public final class DropShadowAlgorithmStatementUpdater implements RuleDefinition
Collection<String> requireAlgorithms = sqlStatement.getAlgorithmNames();
String defaultShadowAlgorithmName = currentRuleConfig.getDefaultShadowAlgorithmName();
if (!sqlStatement.isIfExists()) {
- ShadowRuleStatementChecker.checkAlgorithmExist(requireAlgorithms, currentAlgorithms, different -> new RequiredAlgorithmMissedException(SHADOW, databaseName, different));
+ ShadowRuleStatementChecker.checkAlgorithmExist(requireAlgorithms, currentAlgorithms, different -> new MissingRequiredAlgorithmException(SHADOW, databaseName, different));
}
- checkAlgorithmInUsed(requireAlgorithms, getAlgorithmInUse(currentRuleConfig), identical -> new AlgorithmInUsedException(databaseName, identical));
+ checkAlgorithmInUsed(requireAlgorithms, getAlgorithmInUse(currentRuleConfig), identical -> new AlgorithmInUsedException("Sharding", databaseName, identical));
ShardingSpherePreconditions.checkState(!requireAlgorithms.contains(defaultShadowAlgorithmName),
- () -> new AlgorithmInUsedException(databaseName, Collections.singleton(defaultShadowAlgorithmName)));
+ () -> new AlgorithmInUsedException("Shadow", databaseName, Collections.singleton(defaultShadowAlgorithmName)));
}
private void checkAlgorithmInUsed(final Collection<String> requireAlgorithms, final Collection<String> currentAlgorithms,
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleStatementUpdater.java
index 13c4d650d34..4c7a60d65f1 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleStatementUpdater.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.distsql.handler.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
@@ -51,7 +51,7 @@ public final class DropShadowRuleStatementUpdater implements RuleDefinitionDropU
private void checkRuleNames(final String databaseName, final DropShadowRuleStatement sqlStatement, final ShadowRuleConfiguration currentRuleConfig) throws DistSQLException {
Collection<String> currentRuleNames = currentRuleConfig.getDataSources().keySet();
if (!sqlStatement.isIfExists()) {
- ShadowRuleStatementChecker.checkRulesExist(sqlStatement.getRuleNames(), currentRuleNames, different -> new RequiredRuleMissedException(SHADOW, databaseName, different));
+ ShadowRuleStatementChecker.checkRulesExist(sqlStatement.getRuleNames(), currentRuleNames, different -> new MissingRequiredRuleException(SHADOW, databaseName, different));
}
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowAlgorithmStatementUpdaterTest.java
index b36ca38c62f..1bdcf831780 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowAlgorithmStatementUpdaterTest.java
@@ -21,8 +21,8 @@ import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.distsql.handler.update.AlterShadowAlgorithmStatementUpdater;
@@ -60,7 +60,7 @@ public final class AlterShadowAlgorithmStatementUpdaterTest {
updater.checkSQLStatement(database, sqlStatement, currentConfig);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertExecuteAlgorithmWithoutConfiguration() throws DistSQLException {
Properties prop = new Properties();
prop.setProperty("type", "value");
@@ -68,7 +68,7 @@ public final class AlterShadowAlgorithmStatementUpdaterTest {
updater.checkSQLStatement(database, sqlStatement, null);
}
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertExecuteAlgorithmNotInMetaData() throws DistSQLException {
Properties prop = new Properties();
prop.setProperty("type", "value");
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
index ad00fdd6e3d..85223a39224 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
@@ -19,11 +19,11 @@ package org.apache.shardingsphere.shadow.distsql.update;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
@@ -72,7 +72,7 @@ public final class AlterShadowRuleStatementUpdaterTest {
when(currentConfig.getDataSources()).thenReturn(map);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertExecuteWithoutCurrentConfiguration() throws DistSQLException {
ShadowRuleSegment ruleSegment = new ShadowRuleSegment("ruleName", null, null, null);
updater.checkSQLStatement(database, createSQLStatement(ruleSegment, ruleSegment), null);
@@ -90,7 +90,7 @@ public final class AlterShadowRuleStatementUpdaterTest {
updater.checkSQLStatement(database, createSQLStatement(ruleSegment), currentConfig);
}
- @Test(expected = RequiredResourceMissedException.class)
+ @Test(expected = MissingRequiredResourcesException.class)
public void assertExecuteWithNotExistResource() throws DistSQLException {
List<String> dataSources = Arrays.asList("ds", "ds0");
when(resource.getNotExistedResources(any())).thenReturn(dataSources);
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateDefaultShadowAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateDefaultShadowAlgorithmStatementUpdaterTest.java
index f7e3768189e..35938453926 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateDefaultShadowAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateDefaultShadowAlgorithmStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.distsql.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.distsql.handler.update.CreateDefaultShadowAlgorithmStatementUpdater;
@@ -44,7 +44,7 @@ public final class CreateDefaultShadowAlgorithmStatementUpdaterTest {
private final CreateDefaultShadowAlgorithmStatementUpdater updater = new CreateDefaultShadowAlgorithmStatementUpdater();
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertExecuteWithNotExistAlgorithm() throws DistSQLException {
when(currentConfig.getShadowAlgorithms()).thenReturn(Collections.singletonMap("default_name", null));
updater.checkSQLStatement(database, new CreateDefaultShadowAlgorithmStatement("input_default_name"), currentConfig);
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
index 6e5af6c1d92..4ef3ab5fca4 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.shadow.distsql.update;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
@@ -78,7 +78,7 @@ public final class CreateShadowRuleStatementUpdaterTest {
updater.checkSQLStatement(database, createSQLStatement(ruleSegment), currentConfig);
}
- @Test(expected = RequiredResourceMissedException.class)
+ @Test(expected = MissingRequiredResourcesException.class)
public void assertExecuteWithNotExistResource() throws DistSQLException {
List<String> dataSources = Arrays.asList("ds0", "ds1");
when(resource.getNotExistedResources(any())).thenReturn(dataSources);
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropDefaultShadowAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropDefaultShadowAlgorithmStatementUpdaterTest.java
index 3d1a0cc377f..d419870c68d 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropDefaultShadowAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropDefaultShadowAlgorithmStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.distsql.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.distsql.handler.update.DropDefaultShadowAlgorithmStatementUpdater;
@@ -43,7 +43,7 @@ public final class DropDefaultShadowAlgorithmStatementUpdaterTest {
private final DropDefaultShadowAlgorithmStatementUpdater updater = new DropDefaultShadowAlgorithmStatementUpdater();
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertCheckWithoutDefaultAlgorithm() throws DistSQLException {
updater.checkSQLStatement(database, new DropDefaultShadowAlgorithmStatement(false), currentConfig);
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowAlgorithmStatementUpdaterTest.java
index adbbf0cde62..fe74a54a2dd 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowAlgorithmStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.distsql.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
@@ -45,7 +45,7 @@ public final class DropShadowAlgorithmStatementUpdaterTest {
private final DropShadowAlgorithmStatementUpdater updater = new DropShadowAlgorithmStatementUpdater();
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertExecuteWithoutAlgorithmNameInMetaData() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("ruleSegment"), null);
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowRuleStatementUpdaterTest.java
index f62c414691a..08e23fcfa9c 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowRuleStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.distsql.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
@@ -55,7 +55,7 @@ public final class DropShadowRuleStatementUpdaterTest {
when(currentConfig.getDataSources()).thenReturn(Collections.singletonMap("initRuleName", null));
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertExecuteWithoutRuleNameInMetaData() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("ruleSegment"), null);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
index 3e3cb17edc2..cf08bbed4e0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
@@ -23,12 +23,12 @@ import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidRuleConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -149,7 +149,7 @@ public final class ShardingTableRuleStatementChecker {
Collection<String> notExistedResources = database.getResource().getNotExistedResources(requiredResource);
Collection<String> logicResources = getLogicResources(database);
notExistedResources.removeIf(logicResources::contains);
- ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new RequiredResourceMissedException(databaseName, notExistedResources));
+ ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistedResources));
}
private static Collection<String> getLogicResources(final ShardingSphereDatabase database) {
@@ -213,7 +213,7 @@ public final class ShardingTableRuleStatementChecker {
ShardingSpherePreconditions.checkState(identical.isEmpty(), () -> new DuplicateRuleException("sharding", databaseName, identical));
} else {
Collection<String> different = getDifferent(requiredTables, currentShardingTables);
- ShardingSpherePreconditions.checkState(different.isEmpty(), () -> new RequiredRuleMissedException("sharding", databaseName, different));
+ ShardingSpherePreconditions.checkState(different.isEmpty(), () -> new MissingRequiredRuleException("sharding", databaseName, different));
}
}
@@ -249,7 +249,7 @@ public final class ShardingTableRuleStatementChecker {
.peek(each -> each.getKeyGenerateAlgorithmName()
.filter(optional -> null == currentRuleConfig || !currentRuleConfig.getKeyGenerators().containsKey(optional)).ifPresent(notExistKeyGenerator::add))
.filter(each -> !each.getKeyGenerateAlgorithmName().isPresent()).forEach(each -> requiredKeyGenerators.add(each.getKeyGenerateAlgorithmSegment().getName()));
- ShardingSpherePreconditions.checkState(notExistKeyGenerator.isEmpty(), () -> new RequiredAlgorithmMissedException("key generator", notExistKeyGenerator));
+ ShardingSpherePreconditions.checkState(notExistKeyGenerator.isEmpty(), () -> new MissingRequiredAlgorithmException("key generator", notExistKeyGenerator));
Collection<String> invalidKeyGenerators = requiredKeyGenerators.stream().distinct().filter(each -> !KeyGenerateAlgorithmFactory.contains(each)).collect(Collectors.toList());
ShardingSpherePreconditions.checkState(invalidKeyGenerators.isEmpty(), () -> new InvalidAlgorithmConfigurationException("key generator", invalidKeyGenerators));
}
@@ -263,7 +263,7 @@ public final class ShardingTableRuleStatementChecker {
auditorNames.addAll(each.getAuditorNames());
}
auditorNames.stream().filter(each -> null == currentRuleConfig || !currentRuleConfig.getAuditors().containsKey(each)).collect(Collectors.toList()).forEach(notExistAuditors::add);
- ShardingSpherePreconditions.checkState(notExistAuditors.isEmpty(), () -> new RequiredAlgorithmMissedException("auditor", notExistAuditors));
+ ShardingSpherePreconditions.checkState(notExistAuditors.isEmpty(), () -> new MissingRequiredAlgorithmException("auditor", notExistAuditors));
for (AuditStrategySegment each : auditStrategySegments) {
requiredAuditors.addAll(each.getShardingAuditorSegments().stream().map(ShardingAuditorSegment::getAlgorithmSegment).collect(Collectors.toList())
.stream().map(AlgorithmSegment::getName).collect(Collectors.toList()));
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyStatementUpdater.java
index 7e67ef4d895..0289edce232 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyStatementUpdater.java
@@ -21,8 +21,8 @@ import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -51,19 +51,19 @@ public final class AlterDefaultShardingStrategyStatementUpdater implements RuleD
}
private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
- ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new RequiredRuleMissedException("Sharding", databaseName));
+ ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new MissingRequiredRuleException("Sharding", databaseName));
}
private void checkAlgorithm(final String databaseName, final ShardingRuleConfiguration currentRuleConfig, final AlterDefaultShardingStrategyStatement sqlStatement) throws DistSQLException {
ShardingSpherePreconditions.checkState(ShardingStrategyType.contain(sqlStatement.getStrategyType()), () -> new InvalidAlgorithmConfigurationException(sqlStatement.getStrategyType()));
ShardingSpherePreconditions.checkState(ShardingStrategyType.getValueOf(sqlStatement.getStrategyType()).isValid(sqlStatement.getShardingColumn()),
() -> new InvalidAlgorithmConfigurationException(sqlStatement.getStrategyType()));
- ShardingSpherePreconditions.checkState(isAlgorithmDefinitionExists(sqlStatement), RequiredAlgorithmMissedException::new);
+ ShardingSpherePreconditions.checkState(isAlgorithmDefinitionExists(sqlStatement), MissingRequiredAlgorithmException::new);
if (null == sqlStatement.getShardingAlgorithmName() && null != sqlStatement.getAlgorithmSegment()) {
return;
}
boolean isAlgorithmExist = currentRuleConfig.getShardingAlgorithms().containsKey(sqlStatement.getShardingAlgorithmName());
- ShardingSpherePreconditions.checkState(isAlgorithmExist, () -> new RequiredAlgorithmMissedException(databaseName, Collections.singleton(sqlStatement.getShardingAlgorithmName())));
+ ShardingSpherePreconditions.checkState(isAlgorithmExist, () -> new MissingRequiredAlgorithmException(databaseName, Collections.singleton(sqlStatement.getShardingAlgorithmName())));
}
private boolean isAlgorithmDefinitionExists(final AlterDefaultShardingStrategyStatement sqlStatement) {
@@ -73,7 +73,7 @@ public final class AlterDefaultShardingStrategyStatementUpdater implements RuleD
private void checkExist(final String databaseName, final AlterDefaultShardingStrategyStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
Optional<ShardingStrategyConfiguration> strategyConfig = getStrategyConfiguration(currentRuleConfig, sqlStatement.getDefaultType());
ShardingSpherePreconditions.checkState(strategyConfig.isPresent(),
- () -> new RequiredRuleMissedException(String.format("Default sharding %s strategy", sqlStatement.getDefaultType().toLowerCase()), databaseName));
+ () -> new MissingRequiredRuleException(String.format("Default sharding %s strategy", sqlStatement.getDefaultType().toLowerCase()), databaseName));
}
private Optional<ShardingStrategyConfiguration> getStrategyConfiguration(final ShardingRuleConfiguration currentRuleConfig, final String type) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingAlgorithmStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingAlgorithmStatementUpdater.java
index 8c3ad0f3b67..a5a7865ddd8 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingAlgorithmStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingAlgorithmStatementUpdater.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -58,7 +58,7 @@ public final class AlterShardingAlgorithmStatementUpdater implements RuleDefinit
private void checkExist(final Collection<String> requireNames, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
Collection<String> notExistAlgorithms = requireNames.stream().filter(each -> !currentRuleConfig.getShardingAlgorithms().containsKey(each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistAlgorithms.isEmpty(), () -> new RequiredAlgorithmMissedException("sharding", notExistAlgorithms));
+ ShardingSpherePreconditions.checkState(notExistAlgorithms.isEmpty(), () -> new MissingRequiredAlgorithmException("sharding", notExistAlgorithms));
}
private void checkAlgorithmType(final AlterShardingAlgorithmStatement sqlStatement) throws DistSQLException {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingAuditorStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingAuditorStatementUpdater.java
index 1d852765c32..a960090717e 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingAuditorStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingAuditorStatementUpdater.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -59,7 +59,7 @@ public final class AlterShardingAuditorStatementUpdater implements RuleDefinitio
private void checkExist(final Collection<String> requireNames, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
Collection<String> notExistAlgorithms = requireNames.stream().filter(each -> !currentRuleConfig.getAuditors().containsKey(each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistAlgorithms.isEmpty(), () -> new RequiredAlgorithmMissedException("sharding", notExistAlgorithms));
+ ShardingSpherePreconditions.checkState(notExistAlgorithms.isEmpty(), () -> new MissingRequiredAlgorithmException("sharding", notExistAlgorithms));
}
private void checkAlgorithmType(final AlterShardingAuditorStatement sqlStatement) throws DistSQLException {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingBindingTableRulesStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingBindingTableRulesStatementUpd [...]
index 3257092aae2..c120d256996 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingBindingTableRulesStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingBindingTableRulesStatementUpdater.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -47,9 +47,9 @@ public final class AlterShardingBindingTableRulesStatementUpdater implements Rul
checkToBeAlteredDuplicateBindingTables(databaseName, sqlStatement);
}
- private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
+ private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws MissingRequiredRuleException {
if (null == currentRuleConfig) {
- throw new RequiredRuleMissedException("Sharding", databaseName);
+ throw new MissingRequiredRuleException("Sharding", databaseName);
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingBroadcastTableRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingBroadcastTableRuleStatementU [...]
index 00619e33f86..d105749eea3 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingBroadcastTableRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingBroadcastTableRuleStatementUpdater.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -35,9 +35,9 @@ public final class AlterShardingBroadcastTableRuleStatementUpdater implements Ru
checkCurrentRuleConfiguration(database.getName(), currentRuleConfig);
}
- private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
+ private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws MissingRequiredRuleException {
if (null == currentRuleConfig) {
- throw new RequiredRuleMissedException("Sharding", databaseName);
+ throw new MissingRequiredRuleException("Sharding", databaseName);
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingKeyGeneratorStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingKeyGeneratorStatementUpdater.java
index 6d6f807fd73..8e49ac440f4 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingKeyGeneratorStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingKeyGeneratorStatementUpdater.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -59,7 +59,7 @@ public final class AlterShardingKeyGeneratorStatementUpdater implements RuleDefi
private void checkExist(final Collection<String> requireNames, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
Collection<String> notExistAlgorithms = requireNames.stream().filter(each -> !currentRuleConfig.getKeyGenerators().containsKey(each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistAlgorithms.isEmpty(), () -> new RequiredAlgorithmMissedException("sharding", notExistAlgorithms));
+ ShardingSpherePreconditions.checkState(notExistAlgorithms.isEmpty(), () -> new MissingRequiredAlgorithmException("sharding", notExistAlgorithms));
}
private void checkAlgorithmType(final AlterShardingKeyGeneratorStatement sqlStatement) throws DistSQLException {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableRuleStatementUpdater.java
index 07e9fa7b2fb..5a1f67b6556 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableRuleStatementUpdater.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -40,7 +40,7 @@ public final class AlterShardingTableRuleStatementUpdater implements RuleDefinit
@Override
public void checkSQLStatement(final ShardingSphereDatabase database,
final AlterShardingTableRuleStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
- ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new RequiredRuleMissedException("Sharding", database.getName()));
+ ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new MissingRequiredRuleException("Sharding", database.getName()));
ShardingTableRuleStatementChecker.checkAlteration(database, sqlStatement.getRules(), currentRuleConfig);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyStatementUpdater.java
index c320d4c9a7d..85bf55fcc22 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyStatementUpdater.java
@@ -22,8 +22,8 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionCreateUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -52,19 +52,19 @@ public final class CreateDefaultShardingStrategyStatementUpdater implements Rule
}
private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
- ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new RequiredRuleMissedException("Sharding", databaseName));
+ ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new MissingRequiredRuleException("Sharding", databaseName));
}
private void checkAlgorithm(final String databaseName, final ShardingRuleConfiguration currentRuleConfig, final CreateDefaultShardingStrategyStatement sqlStatement) throws DistSQLException {
ShardingSpherePreconditions.checkState(ShardingStrategyType.contain(sqlStatement.getStrategyType()), () -> new InvalidAlgorithmConfigurationException(sqlStatement.getStrategyType()));
ShardingSpherePreconditions.checkState(ShardingStrategyType.getValueOf(sqlStatement.getStrategyType())
.isValid(sqlStatement.getShardingColumn()), () -> new InvalidAlgorithmConfigurationException(sqlStatement.getStrategyType()));
- ShardingSpherePreconditions.checkState(isAlgorithmDefinitionExists(sqlStatement), RequiredAlgorithmMissedException::new);
+ ShardingSpherePreconditions.checkState(isAlgorithmDefinitionExists(sqlStatement), MissingRequiredAlgorithmException::new);
if (null == sqlStatement.getShardingAlgorithmName() && null != sqlStatement.getAlgorithmSegment()) {
return;
}
boolean isAlgorithmExist = currentRuleConfig.getShardingAlgorithms().containsKey(sqlStatement.getShardingAlgorithmName());
- ShardingSpherePreconditions.checkState(isAlgorithmExist, () -> new RequiredAlgorithmMissedException(databaseName, Collections.singleton(sqlStatement.getShardingAlgorithmName())));
+ ShardingSpherePreconditions.checkState(isAlgorithmExist, () -> new MissingRequiredAlgorithmException(databaseName, Collections.singleton(sqlStatement.getShardingAlgorithmName())));
}
private boolean isAlgorithmDefinitionExists(final CreateDefaultShardingStrategyStatement sqlStatement) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingAuditorStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingAuditorStatementUpdater.java
index d1b137ea060..fb30e1c830d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingAuditorStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingAuditorStatementUpdater.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateAuditorException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateAlgorithmException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionCreateUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -50,9 +50,9 @@ public final class CreateShardingAuditorStatementUpdater implements RuleDefiniti
private void checkDuplicate(final String databaseName, final CreateShardingAuditorStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
Collection<String> auditorNames = sqlStatement.getAuditorSegments().stream().map(ShardingAuditorSegment::getAuditorName).collect(Collectors.toList());
- checkDuplicateInput(auditorNames, duplicated -> new DuplicateAuditorException("sharding", databaseName, duplicated));
+ checkDuplicateInput(auditorNames, duplicated -> new DuplicateAlgorithmException("Sharding auditor", databaseName, duplicated));
if (null != currentRuleConfig) {
- checkExist(auditorNames, currentRuleConfig.getAuditors().keySet(), duplicated -> new DuplicateAuditorException("sharding", databaseName, duplicated));
+ checkExist(auditorNames, currentRuleConfig.getAuditors().keySet(), duplicated -> new DuplicateAlgorithmException("Sharding auditor", databaseName, duplicated));
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingBindingTableRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingBindingTableRuleStatementUpd [...]
index 98e19896015..e0ea0b5cf71 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingBindingTableRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingBindingTableRuleStatementUpdater.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionCreateUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -48,9 +48,9 @@ public final class CreateShardingBindingTableRuleStatementUpdater implements Rul
checkToBeCreatedDuplicateBindingTables(databaseName, sqlStatement, currentRuleConfig);
}
- private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
+ private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws MissingRequiredRuleException {
if (null == currentRuleConfig) {
- throw new RequiredRuleMissedException("Sharding", databaseName);
+ throw new MissingRequiredRuleException("Sharding", databaseName);
}
}
@@ -59,7 +59,7 @@ public final class CreateShardingBindingTableRuleStatementUpdater implements Rul
Collection<String> currentLogicTables = getCurrentLogicTables(currentRuleConfig);
Collection<String> notExistedBindingTables = sqlStatement.getBindingTables().stream()
.filter(each -> !containsIgnoreCase(currentLogicTables, each)).collect(Collectors.toSet());
- ShardingSpherePreconditions.checkState(notExistedBindingTables.isEmpty(), () -> new RequiredRuleMissedException("Sharding", databaseName, notExistedBindingTables));
+ ShardingSpherePreconditions.checkState(notExistedBindingTables.isEmpty(), () -> new MissingRequiredRuleException("Sharding", databaseName, notExistedBindingTables));
}
private boolean containsIgnoreCase(final Collection<String> collection, final String str) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingBroadcastTableRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingBroadcastTableRuleStatemen [...]
index 1b28cc21edb..47fe53483f0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingBroadcastTableRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingBroadcastTableRuleStatementUpdater.java
@@ -24,6 +24,8 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardingBroadcastTableRulesStatement;
+import java.util.Collections;
+
/**
* Create sharding broadcast table rule statement updater.
*/
@@ -37,7 +39,7 @@ public final class CreateShardingBroadcastTableRuleStatementUpdater implements R
private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws RuleInUsedException {
if (null != currentRuleConfig && !currentRuleConfig.getBroadcastTables().isEmpty()) {
- throw new RuleInUsedException("Broadcast", databaseName);
+ throw new RuleInUsedException("Broadcast", databaseName, Collections.emptyList());
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingKeyGeneratorStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingKeyGeneratorStatementUpdater.java
index 4e6165c54e9..4ef1ae039f8 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingKeyGeneratorStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingKeyGeneratorStatementUpdater.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateKeyGeneratorException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateAlgorithmException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionCreateUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -50,9 +50,9 @@ public final class CreateShardingKeyGeneratorStatementUpdater implements RuleDef
private void checkDuplicate(final String databaseName, final CreateShardingKeyGeneratorStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
Collection<String> keyGeneratorNames = sqlStatement.getKeyGeneratorSegments().stream().map(ShardingKeyGeneratorSegment::getKeyGeneratorName).collect(Collectors.toList());
- checkDuplicateInput(keyGeneratorNames, duplicated -> new DuplicateKeyGeneratorException("sharding", databaseName, duplicated));
+ checkDuplicateInput(keyGeneratorNames, duplicated -> new DuplicateAlgorithmException("Key generator", databaseName, duplicated));
if (null != currentRuleConfig) {
- checkExist(keyGeneratorNames, currentRuleConfig.getKeyGenerators().keySet(), duplicated -> new DuplicateKeyGeneratorException("sharding", databaseName, duplicated));
+ checkExist(keyGeneratorNames, currentRuleConfig.getKeyGenerators().keySet(), duplicated -> new DuplicateAlgorithmException("Key generator", databaseName, duplicated));
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultStrategyStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultStrategyStatementUpdater.java
index 0600c641789..427529c6589 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultStrategyStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultStrategyStatementUpdater.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -50,7 +50,7 @@ public final class DropDefaultStrategyStatementUpdater implements RuleDefinition
return;
}
Optional<ShardingStrategyConfiguration> strategyConfig = getStrategyConfiguration(currentRuleConfig, sqlStatement.getDefaultType());
- ShardingSpherePreconditions.checkState(strategyConfig.isPresent(), () -> new RequiredRuleMissedException(
+ ShardingSpherePreconditions.checkState(strategyConfig.isPresent(), () -> new MissingRequiredRuleException(
String.format("Default sharding %s strategy", sqlStatement.getDefaultType().toLowerCase()), databaseName));
}
@@ -62,7 +62,7 @@ public final class DropDefaultStrategyStatementUpdater implements RuleDefinition
}
private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
- ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new RequiredRuleMissedException("Sharding", databaseName));
+ ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new MissingRequiredRuleException("Sharding", databaseName));
}
@Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
index 5c8b7cc16b7..c3e052c3f99 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
@@ -18,10 +18,11 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
@@ -48,21 +49,19 @@ public final class DropShardingAlgorithmStatementUpdater implements RuleDefiniti
checkShardingAlgorithmsInUsed(databaseName, sqlStatement, currentRuleConfig);
}
- private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
- if (null == currentRuleConfig) {
- throw new RequiredAlgorithmMissedException(databaseName);
- }
+ private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws MissingRequiredAlgorithmException {
+ ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new MissingRequiredAlgorithmException("Sharding", databaseName));
}
private void checkToBeDroppedShardingAlgorithms(final String databaseName, final DropShardingAlgorithmStatement sqlStatement,
- final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+ final ShardingRuleConfiguration currentRuleConfig) throws MissingRequiredAlgorithmException {
if (sqlStatement.isIfExists()) {
return;
}
Collection<String> currentShardingAlgorithms = getCurrentShardingAlgorithms(currentRuleConfig);
Collection<String> notExistedAlgorithms = sqlStatement.getAlgorithmNames().stream().filter(each -> !currentShardingAlgorithms.contains(each)).collect(Collectors.toList());
if (!notExistedAlgorithms.isEmpty()) {
- throw new RequiredAlgorithmMissedException(databaseName, notExistedAlgorithms);
+ throw new MissingRequiredAlgorithmException(databaseName, notExistedAlgorithms);
}
}
@@ -70,9 +69,7 @@ public final class DropShardingAlgorithmStatementUpdater implements RuleDefiniti
final ShardingRuleConfiguration currentRuleConfig) throws AlgorithmInUsedException {
Collection<String> allInUsed = getAllOfAlgorithmsInUsed(currentRuleConfig);
Collection<String> usedAlgorithms = sqlStatement.getAlgorithmNames().stream().filter(allInUsed::contains).collect(Collectors.toList());
- if (!usedAlgorithms.isEmpty()) {
- throw new AlgorithmInUsedException(databaseName, usedAlgorithms);
- }
+ ShardingSpherePreconditions.checkState(usedAlgorithms.isEmpty(), () -> new AlgorithmInUsedException("Sharding", databaseName, usedAlgorithms));
}
private Collection<String> getAllOfAlgorithmsInUsed(final ShardingRuleConfiguration shardingRuleConfig) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorStatementUpdater.java
index d1fb99ca61d..98eef9df877 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorStatementUpdater.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.AuditorInUsedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAuditorMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -56,13 +56,13 @@ public final class DropShardingAuditorStatementUpdater implements RuleDefinition
return;
}
Collection<String> notExistAuditors = auditorNames.stream().filter(each -> !currentRuleConfig.getAuditors().containsKey(each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistAuditors.isEmpty(), () -> new RequiredAuditorMissedException("Sharding", databaseName, notExistAuditors));
+ ShardingSpherePreconditions.checkState(notExistAuditors.isEmpty(), () -> new MissingRequiredAlgorithmException("Sharding auditor", databaseName, notExistAuditors));
}
private void checkInUsed(final String databaseName, final Collection<String> auditorNames, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
Collection<String> usedAuditors = getUsedAuditors(currentRuleConfig);
Collection<String> inUsedNames = auditorNames.stream().filter(usedAuditors::contains).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(inUsedNames.isEmpty(), () -> new AuditorInUsedException("Sharding", databaseName, inUsedNames));
+ ShardingSpherePreconditions.checkState(inUsedNames.isEmpty(), () -> new AlgorithmInUsedException("Sharding auditor", databaseName, inUsedNames));
}
private Collection<String> getUsedAuditors(final ShardingRuleConfiguration shardingRuleConfig) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingBindingTableRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingBindingTableRuleStatementUpdater.java
index 4664527e62d..2f3be63e6c2 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingBindingTableRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingBindingTableRuleStatementUpdater.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -59,7 +59,7 @@ public final class DropShardingBindingTableRuleStatementUpdater implements RuleD
}
private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
- ShardingSpherePreconditions.checkState(null != currentRuleConfig && !currentRuleConfig.getBindingTableGroups().isEmpty(), () -> new RequiredRuleMissedException("Binding", databaseName));
+ ShardingSpherePreconditions.checkState(null != currentRuleConfig && !currentRuleConfig.getBindingTableGroups().isEmpty(), () -> new MissingRequiredRuleException("Binding", databaseName));
}
private Map<String, String> buildBindingTableRule(final ShardingRuleConfiguration config) {
@@ -79,7 +79,7 @@ public final class DropShardingBindingTableRuleStatementUpdater implements RuleD
notExistBindingGroups.add(each.getTableGroups());
}
}
- ShardingSpherePreconditions.checkState(notExistBindingGroups.isEmpty(), () -> new RequiredRuleMissedException("Binding", databaseName, notExistBindingGroups));
+ ShardingSpherePreconditions.checkState(notExistBindingGroups.isEmpty(), () -> new MissingRequiredRuleException("Binding", databaseName, notExistBindingGroups));
}
private boolean isToBeDroppedRuleExists(final BindingTableRuleSegment bindingRule, final Map<String, String> bindingRelationship) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingBroadcastTableRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingBroadcastTableRuleStatementUpd [...]
index c73168ccf8e..825728dd5ea 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingBroadcastTableRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingBroadcastTableRuleStatementUpdater.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -52,7 +52,7 @@ public final class DropShardingBroadcastTableRuleStatementUpdater implements Rul
if (!sqlStatement.getRules().isEmpty()) {
Collection<String> currentRules = currentRuleConfig.getBroadcastTables();
Collection<String> notExistRules = sqlStatement.getRules().stream().filter(each -> !containsIgnoreCase(currentRules, each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistRules.isEmpty(), () -> new RequiredRuleMissedException("Broadcast", databaseName, notExistRules));
+ ShardingSpherePreconditions.checkState(notExistRules.isEmpty(), () -> new MissingRequiredRuleException("Broadcast", databaseName, notExistRules));
}
}
@@ -61,7 +61,7 @@ public final class DropShardingBroadcastTableRuleStatementUpdater implements Rul
}
private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
- ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new RequiredRuleMissedException("Broadcast", databaseName));
+ ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new MissingRequiredRuleException("Broadcast", databaseName));
}
@Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorStatementUpdater.java
index daf15f4bba2..c0df44ef44a 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorStatementUpdater.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.KeyGeneratorInUsedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredKeyGeneratorMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -57,13 +57,13 @@ public final class DropShardingKeyGeneratorStatementUpdater implements RuleDefin
return;
}
Collection<String> notExistKeyGenerators = keyGeneratorNames.stream().filter(each -> !currentRuleConfig.getKeyGenerators().containsKey(each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistKeyGenerators.isEmpty(), () -> new RequiredKeyGeneratorMissedException("Sharding", databaseName, notExistKeyGenerators));
+ ShardingSpherePreconditions.checkState(notExistKeyGenerators.isEmpty(), () -> new MissingRequiredAlgorithmException("Key generator", databaseName, notExistKeyGenerators));
}
private void checkInUsed(final String databaseName, final Collection<String> keyGeneratorNames, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
Collection<String> usedKeyGenerators = getUsedKeyGenerators(currentRuleConfig);
Collection<String> inUsedNames = keyGeneratorNames.stream().filter(usedKeyGenerators::contains).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(inUsedNames.isEmpty(), () -> new KeyGeneratorInUsedException("Sharding", databaseName, inUsedNames));
+ ShardingSpherePreconditions.checkState(inUsedNames.isEmpty(), () -> new AlgorithmInUsedException("Key generator", databaseName, inUsedNames));
}
private Collection<String> getUsedKeyGenerators(final ShardingRuleConfiguration shardingRuleConfig) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleStatementUpdater.java
index 11adce50bef..e5c8b89b6fc 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleStatementUpdater.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
import com.google.common.base.Splitter;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleInUsedException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
@@ -53,9 +53,9 @@ public final class DropShardingTableRuleStatementUpdater implements RuleDefiniti
checkBindingTables(databaseName, sqlStatement, currentRuleConfig);
}
- private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
+ private void checkCurrentRuleConfiguration(final String databaseName, final ShardingRuleConfiguration currentRuleConfig) throws MissingRequiredRuleException {
if (null == currentRuleConfig) {
- throw new RequiredRuleMissedException("Sharding", databaseName);
+ throw new MissingRequiredRuleException("Sharding", databaseName);
}
}
@@ -64,7 +64,7 @@ public final class DropShardingTableRuleStatementUpdater implements RuleDefiniti
}
private void checkToBeDroppedShardingTableNames(final String databaseName, final DropShardingTableRuleStatement sqlStatement,
- final ShardingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
+ final ShardingRuleConfiguration currentRuleConfig) throws MissingRequiredRuleException {
if (sqlStatement.isIfExists()) {
return;
}
@@ -72,7 +72,7 @@ public final class DropShardingTableRuleStatementUpdater implements RuleDefiniti
Collection<String> notExistedTableNames =
getToBeDroppedShardingTableNames(sqlStatement).stream().filter(each -> !containsIgnoreCase(currentShardingTableNames, each)).collect(Collectors.toList());
if (!notExistedTableNames.isEmpty()) {
- throw new RequiredRuleMissedException("sharding", databaseName, notExistedTableNames);
+ throw new MissingRequiredRuleException("sharding", databaseName, notExistedTableNames);
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
index 8e82f0dc37f..c07010bc49a 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
@@ -20,11 +20,11 @@ package org.apache.shardingsphere.sharding.distsql.checker;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
@@ -119,13 +119,13 @@ public final class ShardingRuleStatementCheckerTest {
ShardingTableRuleStatementChecker.checkCreation(database, rules, shardingRuleConfig);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckAlterationWithRuleRequiredMissed() throws DistSQLException {
List<AbstractTableRuleSegment> rules = Collections.singletonList(new AutoTableRuleSegment("t_order_required_missed", Arrays.asList("ds_0", "ds_1")));
ShardingTableRuleStatementChecker.checkAlteration(database, rules, shardingRuleConfig);
}
- @Test(expected = RequiredResourceMissedException.class)
+ @Test(expected = MissingRequiredResourcesException.class)
public void assertCheckCreationWithResourceRequiredMissed() throws DistSQLException {
List<AbstractTableRuleSegment> rules = Collections.singletonList(new AutoTableRuleSegment("t_product", Arrays.asList("ds_required_missed", "ds_1")));
ShardingTableRuleStatementChecker.checkCreation(database, rules, shardingRuleConfig);
@@ -135,26 +135,23 @@ public final class ShardingRuleStatementCheckerTest {
public void assertCheckCreationWithInvalidKeyGenerateAlgorithm() throws DistSQLException {
AutoTableRuleSegment autoTableRuleSegment = new AutoTableRuleSegment("t_product", Arrays.asList("ds_0", "ds_1"));
autoTableRuleSegment.setKeyGenerateStrategySegment(new KeyGenerateStrategySegment("product_id", new AlgorithmSegment("invalid", newProperties("invalid", "invalid"))));
- List<AbstractTableRuleSegment> rules = Collections.singletonList(autoTableRuleSegment);
- ShardingTableRuleStatementChecker.checkCreation(database, rules, shardingRuleConfig);
+ ShardingTableRuleStatementChecker.checkCreation(database, Collections.singleton(autoTableRuleSegment), shardingRuleConfig);
}
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertCheckCreationWithMissedAuditAlgorithm() throws DistSQLException {
AutoTableRuleSegment autoTableRuleSegment = new AutoTableRuleSegment("t_product", Arrays.asList("ds_0", "ds_1"));
- autoTableRuleSegment.setAuditStrategySegment(new AuditStrategySegment(Arrays.asList("invalid"),
- Arrays.asList(new ShardingAuditorSegment("invalid", new AlgorithmSegment("DML_SHARDING_CONDITIONS", new Properties()))), true));
- List<AbstractTableRuleSegment> rules = Collections.singletonList(autoTableRuleSegment);
- ShardingTableRuleStatementChecker.checkCreation(database, rules, shardingRuleConfig);
+ autoTableRuleSegment.setAuditStrategySegment(new AuditStrategySegment(Collections.singleton("invalid"),
+ Collections.singletonList(new ShardingAuditorSegment("invalid", new AlgorithmSegment("DML_SHARDING_CONDITIONS", new Properties()))), true));
+ ShardingTableRuleStatementChecker.checkCreation(database, Collections.singleton(autoTableRuleSegment), shardingRuleConfig);
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
public void assertCheckCreationWithInvalidAuditAlgorithm() throws DistSQLException {
AutoTableRuleSegment autoTableRuleSegment = new AutoTableRuleSegment("t_product", Arrays.asList("ds_0", "ds_1"));
- autoTableRuleSegment.setAuditStrategySegment(new AuditStrategySegment(Arrays.asList("sharding_key_required_auditor"),
- Arrays.asList(new ShardingAuditorSegment("sharding_key_required_auditor", new AlgorithmSegment("invalid", new Properties()))), true));
- List<AbstractTableRuleSegment> rules = Collections.singletonList(autoTableRuleSegment);
- ShardingTableRuleStatementChecker.checkCreation(database, rules, shardingRuleConfig);
+ autoTableRuleSegment.setAuditStrategySegment(new AuditStrategySegment(Collections.singleton("sharding_key_required_auditor"),
+ Collections.singletonList(new ShardingAuditorSegment("sharding_key_required_auditor", new AlgorithmSegment("invalid", new Properties()))), true));
+ ShardingTableRuleStatementChecker.checkCreation(database, Collections.singleton(autoTableRuleSegment), shardingRuleConfig);
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
@@ -220,7 +217,7 @@ public final class ShardingRuleStatementCheckerTest {
@Test
public void assertCheckNullAlgorithmNameAndAlgorithmSegment() throws DistSQLException {
TableRuleSegment tableRuleSegment = new TableRuleSegment("t_product", Arrays.asList("ds_0", "ds_1"));
- AlgorithmSegment databaseAlgorithmSegment = getAutoCreativeAlgorithmSegment("inline", newProperties("algorithm-expression", "ds_${product_id% 2}"));
+ AlgorithmSegment databaseAlgorithmSegment = new AlgorithmSegment("inline", newProperties("algorithm-expression", "ds_${product_id% 2}"));
tableRuleSegment.setTableStrategySegment(new ShardingStrategySegment("standard", "product_id", null, databaseAlgorithmSegment));
List<AbstractTableRuleSegment> rules = Collections.singletonList(tableRuleSegment);
ShardingTableRuleStatementChecker.checkCreation(database, rules, shardingRuleConfig);
@@ -249,10 +246,6 @@ public final class ShardingRuleStatementCheckerTest {
return result;
}
- private AlgorithmSegment getAutoCreativeAlgorithmSegment(final String name, final Properties props) {
- return new AlgorithmSegment(name, props);
- }
-
private static Properties newProperties(final String key, final String value) {
Properties result = new Properties();
result.put(key, value);
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterDefaultShardingStrategyStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterDefaultShardingStrategyStatementUpdaterTest.java
index a91fe0c66c6..8e4f7a8794c 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterDefaultShardingStrategyStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterDefaultShardingStrategyStatementUpdaterTest.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
@@ -58,13 +58,13 @@ public final class AlterDefaultShardingStrategyStatementUpdaterTest {
updater.checkSQLStatement(database, new AlterDefaultShardingStrategyStatement("TABLE", "invalidType", null, "order_id_algorithm", null), new ShardingRuleConfiguration());
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertExecuteWithoutCurrentConfiguration() throws DistSQLException {
AlterDefaultShardingStrategyStatement statement = new AlterDefaultShardingStrategyStatement("TABLE", "standard", "order_id", "order_id_algorithm", null);
updater.checkSQLStatement(database, statement, null);
}
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertExecuteWithNotExist() throws DistSQLException {
AlterDefaultShardingStrategyStatement statement = new AlterDefaultShardingStrategyStatement("TABLE", "standard", "order_id", "order_id_algorithm", null);
ShardingRuleConfiguration currentRuleConfig = new ShardingRuleConfiguration();
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingAlgorithmStatementUpdaterTest.java
index 1c2989b2d81..7dac6900238 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingAlgorithmStatementUpdaterTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.distsql.handler.update.AlterShardingAlgorithmStatementUpdater;
@@ -63,7 +63,7 @@ public final class AlterShardingAlgorithmStatementUpdaterTest {
updater.checkSQLStatement(database, createSQLStatement(algorithmSegment, algorithmSegment), null);
}
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertExecuteWithNotExist() throws DistSQLException {
Properties props = new Properties();
props.put("input_key", "input_value");
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingAuditorStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingAuditorStatementUpdaterTest.java
index 75b2f6d8435..152e4fe2671 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingAuditorStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingAuditorStatementUpdaterTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.distsql.handler.update.AlterShardingAuditorStatementUpdater;
@@ -62,7 +62,7 @@ public final class AlterShardingAuditorStatementUpdaterTest {
updater.checkSQLStatement(database, new AlterShardingAuditorStatement(Arrays.asList(auditorSegment, auditorSegment)), null);
}
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertExecuteWithNotExist() throws DistSQLException {
Properties props = createProperties();
ShardingAuditorSegment auditorSegment = new ShardingAuditorSegment("not_exist_auditor_name", new AlgorithmSegment("DML_SHARDING_CONDITIONS", props));
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingBindingTableRulesStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingBindingTableRulesStatementUpdaterTest.java
index 5d5335da3f1..88e7366a9b5 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingBindingTableRulesStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingBindingTableRulesStatementUpdaterTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sharding.distsql.update;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -44,7 +44,7 @@ public final class AlterShardingBindingTableRulesStatementUpdaterTest {
private final AlterShardingBindingTableRulesStatementUpdater updater = new AlterShardingBindingTableRulesStatementUpdater();
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement(database, createSQLStatement(), null);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingBroadcastTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingBroadcastTableRuleStatementUpdaterTest.java
index 1e5bb057b21..465e4ce8967 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingBroadcastTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingBroadcastTableRuleStatementUpdaterTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sharding.distsql.update;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.distsql.handler.update.AlterShardingBroadcastTableRuleStatementUpdater;
@@ -33,7 +33,7 @@ public final class AlterShardingBroadcastTableRuleStatementUpdaterTest {
private final AlterShardingBroadcastTableRuleStatementUpdater updater = new AlterShardingBroadcastTableRuleStatementUpdater();
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement(mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS), createSQLStatement(), null);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingKeyGeneratorStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingKeyGeneratorStatementUpdaterTest.java
index 506f13178aa..c4e4df7e801 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingKeyGeneratorStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingKeyGeneratorStatementUpdaterTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.distsql.handler.update.AlterShardingKeyGeneratorStatementUpdater;
@@ -62,7 +62,7 @@ public final class AlterShardingKeyGeneratorStatementUpdaterTest {
updater.checkSQLStatement(database, new AlterShardingKeyGeneratorStatement(Arrays.asList(keyGeneratorSegment, keyGeneratorSegment)), null);
}
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertExecuteWithNotExist() throws DistSQLException {
Properties props = createProperties();
ShardingKeyGeneratorSegment keyGeneratorSegment = new ShardingKeyGeneratorSegment("not_exist_key_generator_name", new AlgorithmSegment("snowflake", props));
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateDefaultShardingStrategyStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateDefaultShardingStrategyStatementUpdaterTest.java
index 86f9008aa32..a9ac41e1361 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateDefaultShardingStrategyStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateDefaultShardingStrategyStatementUpdaterTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
@@ -58,7 +58,7 @@ public final class CreateDefaultShardingStrategyStatementUpdaterTest {
updater.checkSQLStatement(database, new CreateDefaultShardingStrategyStatement("TABLE", "invalidType", null, "order_id_algorithm", null), new ShardingRuleConfiguration());
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertExecuteWithoutCurrentConfiguration() throws DistSQLException {
CreateDefaultShardingStrategyStatement statement = new CreateDefaultShardingStrategyStatement("TABLE", "standard", "order_id", "order_id_algorithm", null);
updater.checkSQLStatement(database, statement, null);
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingAuditorStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingAuditorStatementUpdaterTest.java
index cc0c490dea5..91afda62b5f 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingAuditorStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingAuditorStatementUpdaterTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateAuditorException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateAlgorithmException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -52,13 +52,13 @@ public final class CreateShardingAuditorStatementUpdaterTest {
when(database.getName()).thenReturn("test");
}
- @Test(expected = DuplicateAuditorException.class)
+ @Test(expected = DuplicateAlgorithmException.class)
public void assertExecuteWithDuplicate() throws DistSQLException {
ShardingAuditorSegment auditorSegment = new ShardingAuditorSegment("sharding_key_required_auditor", new AlgorithmSegment("DML_SHARDING_CONDITIONS", new Properties()));
updater.checkSQLStatement(database, createSQLStatement(auditorSegment, auditorSegment), null);
}
- @Test(expected = DuplicateAuditorException.class)
+ @Test(expected = DuplicateAlgorithmException.class)
public void assertExecuteWithExist() throws DistSQLException {
ShardingAuditorSegment auditorSegment = new ShardingAuditorSegment("sharding_key_required_auditor", new AlgorithmSegment("DML_SHARDING_CONDITIONS", new Properties()));
ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingBindingTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingBindingTableRuleStatementUpdaterTest.java
index 7aa3e2079cf..069875bdaec 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingBindingTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingBindingTableRuleStatementUpdaterTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
@@ -43,7 +43,7 @@ public final class CreateShardingBindingTableRuleStatementUpdaterTest {
private final CreateShardingBindingTableRuleStatementUpdater updater = new CreateShardingBindingTableRuleStatementUpdater();
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentTableRule() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement(), new ShardingRuleConfiguration());
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingKeyGeneratorStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingKeyGeneratorStatementUpdaterTest.java
index 28d5c797518..d3ef9993364 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingKeyGeneratorStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingKeyGeneratorStatementUpdaterTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateKeyGeneratorException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateAlgorithmException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -52,13 +52,13 @@ public final class CreateShardingKeyGeneratorStatementUpdaterTest {
when(database.getName()).thenReturn("test");
}
- @Test(expected = DuplicateKeyGeneratorException.class)
+ @Test(expected = DuplicateAlgorithmException.class)
public void assertExecuteWithDuplicate() throws DistSQLException {
ShardingKeyGeneratorSegment keyGeneratorSegment = new ShardingKeyGeneratorSegment("uuid_key_generator", new AlgorithmSegment("uuid", new Properties()));
updater.checkSQLStatement(database, createSQLStatement(keyGeneratorSegment, keyGeneratorSegment), null);
}
- @Test(expected = DuplicateKeyGeneratorException.class)
+ @Test(expected = DuplicateAlgorithmException.class)
public void assertExecuteWithExist() throws DistSQLException {
ShardingKeyGeneratorSegment keyGeneratorSegment = new ShardingKeyGeneratorSegment("uuid_key_generator", new AlgorithmSegment("uuid", new Properties()));
ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropDefaultShardingStrategyStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropDefaultShardingStrategyStatementUpdaterTest.java
index 753cf551587..80f2c71c121 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropDefaultShardingStrategyStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropDefaultShardingStrategyStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
@@ -40,12 +40,12 @@ public final class DropDefaultShardingStrategyStatementUpdaterTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ShardingSphereDatabase database;
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws DistSQLException {
updater.checkSQLStatement(database, new DropDefaultShardingStrategyStatement(false, "TABLE"), null);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutExistedAlgorithm() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("table"), new ShardingRuleConfiguration());
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmStatementUpdaterTest.java
index 512fdc7221d..4f829be6a5a 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmStatementUpdaterTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -49,7 +49,7 @@ public final class DropShardingAlgorithmStatementUpdaterTest {
private final DropShardingAlgorithmStatementUpdater updater = new DropShardingAlgorithmStatementUpdater();
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement(database, new DropShardingAlgorithmStatement(false, Collections.emptyList()), null);
}
@@ -60,7 +60,7 @@ public final class DropShardingAlgorithmStatementUpdaterTest {
updater.checkSQLStatement(database, dropShardingAlgorithmStatement, null);
}
- @Test(expected = RequiredAlgorithmMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertCheckSQLStatementWithoutExistedAlgorithm() throws RuleDefinitionViolationException {
updater.checkSQLStatement(database, createSQLStatement("t_order"), new ShardingRuleConfiguration());
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorStatementUpdaterTest.java
index e39580d19f0..132820695f0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorStatementUpdaterTest.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.AuditorInUsedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAuditorMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -54,7 +54,7 @@ public final class DropShardingAuditorStatementUpdaterTest {
when(database.getName()).thenReturn("test");
}
- @Test(expected = RequiredAuditorMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertExecuteWithNotExist() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("sharding_key_required_auditor"), new ShardingRuleConfiguration());
}
@@ -73,7 +73,7 @@ public final class DropShardingAuditorStatementUpdaterTest {
assertTrue(currentRuleConfig.getAuditors().isEmpty());
}
- @Test(expected = AuditorInUsedException.class)
+ @Test(expected = AlgorithmInUsedException.class)
public void assertExecuteWithUsed() throws DistSQLException {
ShardingRuleConfiguration currentRuleConfig = new ShardingRuleConfiguration();
currentRuleConfig.getAuditors().put("sharding_key_required_auditor", new AlgorithmConfiguration("DML_SHARDING_CONDITIONS", null));
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBindingTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBindingTableRuleStatementUpdaterTest.java
index 1e32b5771bb..c8be8e6e3d0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBindingTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBindingTableRuleStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -50,12 +50,12 @@ public final class DropShardingBindingTableRuleStatementUpdaterTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ShardingSphereDatabase database;
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement(), null);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutExistedBindingTableRule() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement(), new ShardingRuleConfiguration());
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBroadcastTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBroadcastTableRuleStatementUpdaterTest.java
index b04fcd982a2..6785565e142 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBroadcastTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBroadcastTableRuleStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -44,12 +44,12 @@ public final class DropShardingBroadcastTableRuleStatementUpdaterTest {
private final DropShardingBroadcastTableRuleStatementUpdater updater = new DropShardingBroadcastTableRuleStatementUpdater();
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("t_order"), null);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutExistBroadcastTableRule() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("t_order"), new ShardingRuleConfiguration());
}
@@ -67,7 +67,7 @@ public final class DropShardingBroadcastTableRuleStatementUpdaterTest {
assertTrue(updater.hasAnyOneToBeDropped(createSQLStatement(true, "t_order"), createCurrentRuleConfiguration()));
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithBroadcastTableRuleAreNotTheSame() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("t_order_item"), createCurrentRuleConfiguration());
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorStatementUpdaterTest.java
index ca6a997ad6d..4a847f96441 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorStatementUpdaterTest.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.KeyGeneratorInUsedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredKeyGeneratorMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -54,7 +54,7 @@ public final class DropShardingKeyGeneratorStatementUpdaterTest {
when(database.getName()).thenReturn("test");
}
- @Test(expected = RequiredKeyGeneratorMissedException.class)
+ @Test(expected = MissingRequiredAlgorithmException.class)
public void assertExecuteWithNotExist() throws DistSQLException {
updater.checkSQLStatement(database, createSQLStatement("uuid_key_generator"), new ShardingRuleConfiguration());
}
@@ -73,7 +73,7 @@ public final class DropShardingKeyGeneratorStatementUpdaterTest {
assertTrue(currentRuleConfig.getKeyGenerators().isEmpty());
}
- @Test(expected = KeyGeneratorInUsedException.class)
+ @Test(expected = AlgorithmInUsedException.class)
public void assertExecuteWithUsed() throws DistSQLException {
ShardingRuleConfiguration currentRuleConfig = new ShardingRuleConfiguration();
currentRuleConfig.getKeyGenerators().put("uuid_key_generator", new AlgorithmConfiguration("UUID", null));
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableRuleStatementUpdaterTest.java
index 0142d581f3c..9904bbba55f 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableRuleStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.update;
import com.google.common.base.Splitter;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RuleInUsedException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -55,12 +55,12 @@ public final class DropShardingTableRuleStatementUpdaterTest {
private final DropShardingTableRuleStatementUpdater updater = new DropShardingTableRuleStatementUpdater();
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement(database, new DropShardingTableRuleStatement(Collections.emptyList()), null);
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertCheckSQLStatementWithoutExistedTableRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement(database, createSQLStatement("t_order"), new ShardingRuleConfiguration());
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/DistSQLException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/DistSQLException.java
index b859754ff23..e24abdeeb58 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/DistSQLException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/DistSQLException.java
@@ -17,16 +17,19 @@
package org.apache.shardingsphere.infra.distsql.exception;
-import java.sql.SQLException;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.SQLState;
+import org.apache.shardingsphere.infra.util.exception.external.sql.type.kernel.KernelSQLException;
/**
* Dist SQL exception.
*/
-public abstract class DistSQLException extends SQLException {
+public abstract class DistSQLException extends KernelSQLException {
private static final long serialVersionUID = -6464411607608071400L;
- public DistSQLException(final int errorCode, final String reason) {
- super(reason, "C" + errorCode, errorCode);
+ private static final int KERNEL_CODE = 9;
+
+ public DistSQLException(final SQLState sqlState, final int errorCode, final String reason, final Object... messageArguments) {
+ super(sqlState, KERNEL_CODE, errorCode, reason, messageArguments);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/DuplicateResourceException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/DuplicateResourceException.java
index 4886ea14d08..bde19f723cf 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/DuplicateResourceException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/DuplicateResourceException.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.infra.distsql.exception.resource;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
import java.util.Collection;
/**
@@ -27,6 +29,6 @@ public final class DuplicateResourceException extends ResourceDefinitionViolatio
private static final long serialVersionUID = 2103793827572264148L;
public DuplicateResourceException(final Collection<String> resourceNames) {
- super(1103, String.format("Duplicate resource names %s.", resourceNames));
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 4, "Duplicate resource names `%s`", resourceNames);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/InvalidResourcesException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/EmptyResourceException.java
similarity index 66%
copy from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/InvalidResourcesException.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/EmptyResourceException.java
index 1511dc41ce3..f85ef5bd643 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/InvalidResourcesException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/EmptyResourceException.java
@@ -17,16 +17,16 @@
package org.apache.shardingsphere.infra.distsql.exception.resource;
-import java.util.Collection;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
/**
- * Invalid resources exception.
+ * Empty resource exception.
*/
-public final class InvalidResourcesException extends ResourceDefinitionViolationException {
+public final class EmptyResourceException extends ResourceDefinitionViolationException {
- private static final long serialVersionUID = 7029641448948791509L;
+ private static final long serialVersionUID = 1704331180489268L;
- public InvalidResourcesException(final Collection<String> errorMessages) {
- super(1104, String.format("Can not process invalid resources, error messages are: %s.", errorMessages));
+ public EmptyResourceException(final String databaseName) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 2, "There is no resource in the database `%s`", databaseName);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/InvalidResourcesException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/InvalidResourcesException.java
index 1511dc41ce3..9d0f126d673 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/InvalidResourcesException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/InvalidResourcesException.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.infra.distsql.exception.resource;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
import java.util.Collection;
/**
@@ -27,6 +29,6 @@ public final class InvalidResourcesException extends ResourceDefinitionViolation
private static final long serialVersionUID = 7029641448948791509L;
public InvalidResourcesException(final Collection<String> errorMessages) {
- super(1104, String.format("Can not process invalid resources, error messages are: %s.", errorMessages));
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 0, "Can not process invalid resources, error message is: %s", errorMessages);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/RequiredResourceMissedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/MissingRequiredResourcesException.java
similarity index 64%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/RequiredResourceMissedException.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/MissingRequiredResourcesException.java
index d9d348e075c..7f1408a0590 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/RequiredResourceMissedException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/MissingRequiredResourcesException.java
@@ -17,20 +17,18 @@
package org.apache.shardingsphere.infra.distsql.exception.resource;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
import java.util.Collection;
/**
- * Required resource missed exception.
+ * Missing required resources exception.
*/
-public final class RequiredResourceMissedException extends ResourceDefinitionViolationException {
+public final class MissingRequiredResourcesException extends ResourceDefinitionViolationException {
private static final long serialVersionUID = 1704331180489268L;
- public RequiredResourceMissedException(final String databaseName, final Collection<String> resourceNames) {
- super(1102, String.format("Resources %s do not exist in database %s.", resourceNames, databaseName));
- }
-
- public RequiredResourceMissedException(final String databaseName) {
- super(1102, String.format("There are no resources in the database %s.", databaseName));
+ public MissingRequiredResourcesException(final String databaseName, final Collection<String> resourceNames) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 1, "Resources `%s` do not exist in database `%s`", resourceNames, databaseName);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/ResourceDefinitionViolationException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/ResourceDefinitionViolationException.java
index 3f45b4a14fb..469781dd932 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/ResourceDefinitionViolationException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/ResourceDefinitionViolationException.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.distsql.exception.resource;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.SQLState;
/**
* Resource definition violation exception.
@@ -26,7 +27,7 @@ public abstract class ResourceDefinitionViolationException extends DistSQLExcept
private static final long serialVersionUID = -2686784350802985974L;
- public ResourceDefinitionViolationException(final int errorCode, final String reason) {
- super(errorCode, reason);
+ public ResourceDefinitionViolationException(final SQLState sqlState, final int errorCode, final String reason, final Object... messageArguments) {
+ super(sqlState, errorCode, reason, messageArguments);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/ResourceInUsedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/ResourceInUsedException.java
index 906f7a4032a..2ae7cac2f5d 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/ResourceInUsedException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/resource/ResourceInUsedException.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.infra.distsql.exception.resource;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
import java.util.Collection;
/**
@@ -26,11 +28,7 @@ public final class ResourceInUsedException extends ResourceDefinitionViolationEx
private static final long serialVersionUID = -3427324685070457375L;
- public ResourceInUsedException(final Collection<String> resourceNames) {
- super(1101, String.format("Resources %s are still in used.", resourceNames));
- }
-
public ResourceInUsedException(final String resourceName, final Collection<String> ruleTypes) {
- super(1101, String.format("Resource [%s] is still used by %s.", resourceName, ruleTypes));
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 3, "Resource `%s` is still used by `%s`", resourceName, ruleTypes);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/AlgorithmInUsedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/AlgorithmInUsedException.java
index bff119d1fd5..5d4292d281c 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/AlgorithmInUsedException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/AlgorithmInUsedException.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.infra.distsql.exception.rule;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
import java.util.Collection;
/**
@@ -26,7 +28,7 @@ public final class AlgorithmInUsedException extends RuleDefinitionViolationExcep
private static final long serialVersionUID = -5748228542420285726L;
- public AlgorithmInUsedException(final String databaseName, final Collection<String> algorithmNames) {
- super(1116, String.format("Sharding algorithms `%s` in database `%s` are still in used.", algorithmNames, databaseName));
+ public AlgorithmInUsedException(final String type, final String databaseName, final Collection<String> algorithmNames) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 152, "%s algorithms `%s` in database `%s` are still in used", type, algorithmNames, databaseName);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/AuditorInUsedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/AuditorInUsedException.java
deleted file mode 100644
index c13adf0199b..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/AuditorInUsedException.java
+++ /dev/null
@@ -1,32 +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.distsql.exception.rule;
-
-import java.util.Collection;
-
-/**
- * Auditor in used exception.
- */
-public final class AuditorInUsedException extends RuleDefinitionViolationException {
-
- private static final long serialVersionUID = 367366381929736622L;
-
- public AuditorInUsedException(final String ruleType, final String databaseName, final Collection<String> auditorNames) {
- super(1128, String.format("%s auditor `%s` in database `%s` are still in used.", ruleType, auditorNames, databaseName));
- }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/KeyGeneratorInUsedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateAlgorithmException.java
similarity index 64%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/KeyGeneratorInUsedException.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateAlgorithmException.java
index facb546d9de..30e593eff69 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/KeyGeneratorInUsedException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateAlgorithmException.java
@@ -17,16 +17,18 @@
package org.apache.shardingsphere.infra.distsql.exception.rule;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
import java.util.Collection;
/**
- * Key generator in used exception.
+ * Duplicate algorithm exception.
*/
-public final class KeyGeneratorInUsedException extends RuleDefinitionViolationException {
+public final class DuplicateAlgorithmException extends RuleDefinitionViolationException {
- private static final long serialVersionUID = 477511600241124319L;
+ private static final long serialVersionUID = 4382238091103015055L;
- public KeyGeneratorInUsedException(final String ruleType, final String databaseName, final Collection<String> keyGeneratorNames) {
- super(1121, String.format("%s key generator `%s` in database `%s` are still in used.", ruleType, keyGeneratorNames, databaseName));
+ public DuplicateAlgorithmException(final String type, final String databaseName, final Collection<String> auditorNames) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 153, "Duplicate %s algorithms `%s` in database `%s`", type, auditorNames, databaseName);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateAuditorException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateAuditorException.java
deleted file mode 100644
index d8f3e1f7256..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateAuditorException.java
+++ /dev/null
@@ -1,32 +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.distsql.exception.rule;
-
-import java.util.Collection;
-
-/**
- * Duplicate auditor exception.
- */
-public final class DuplicateAuditorException extends RuleDefinitionViolationException {
-
- private static final long serialVersionUID = 4965160371403179153L;
-
- public DuplicateAuditorException(final String ruleType, final String databaseName, final Collection<String> auditorNames) {
- super(1123, String.format("Duplicate %s auditor names `%s` in database `%s`", ruleType, auditorNames, databaseName));
- }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateKeyGeneratorException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateKeyGeneratorException.java
deleted file mode 100644
index 035b7ed31ea..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateKeyGeneratorException.java
+++ /dev/null
@@ -1,32 +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.distsql.exception.rule;
-
-import java.util.Collection;
-
-/**
- * Duplicate key generator exception.
- */
-public final class DuplicateKeyGeneratorException extends RuleDefinitionViolationException {
-
- private static final long serialVersionUID = 4965160371403179153L;
-
- public DuplicateKeyGeneratorException(final String ruleType, final String databaseName, final Collection<String> keyGeneratorNames) {
- super(1117, String.format("Duplicate %s key generator names `%s` in database `%s`", ruleType, keyGeneratorNames, databaseName));
- }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateRuleException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateRuleException.java
index ba5fc7acc8b..e332623ed69 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateRuleException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/DuplicateRuleException.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.infra.distsql.exception.rule;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
import java.util.Collection;
/**
@@ -27,14 +29,14 @@ public final class DuplicateRuleException extends RuleDefinitionViolationExcepti
private static final long serialVersionUID = -1738699538105858939L;
public DuplicateRuleException(final String ruleType, final String databaseName, final Collection<String> ruleNames) {
- super(1113, String.format("Duplicate %s rule names `%s` in database `%s`", ruleType, ruleNames, databaseName));
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 105, String.format("Duplicate %s rule names `%s` in database `%s`", ruleType, ruleNames, databaseName));
}
public DuplicateRuleException(final String ruleType, final Collection<String> ruleNames) {
- super(1113, String.format("Duplicate %s rule names `%s`", ruleType, ruleNames));
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 105, String.format("Duplicate %s rule names `%s`", ruleType, ruleNames));
}
public DuplicateRuleException(final String type, final String databaseName) {
- super(1113, String.format("Duplicate `%s` in database `%s`", type, databaseName));
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 105, String.format("Duplicate `%s` in database `%s`", type, databaseName));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/InvalidAlgorithmConfigurationException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/InvalidAlgorithmConfigurationException.java
index ccb105060d9..c0b07502512 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/InvalidAlgorithmConfigurationException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/InvalidAlgorithmConfigurationException.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.infra.distsql.exception.rule;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
import java.util.Collection;
/**
@@ -27,14 +29,14 @@ public final class InvalidAlgorithmConfigurationException extends RuleDefinition
private static final long serialVersionUID = 9076740384552385180L;
public InvalidAlgorithmConfigurationException(final String algorithmType, final Collection<String> algorithms) {
- super(1114, String.format("Invalid %s algorithms %s.", algorithmType, algorithms));
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 150, String.format("Invalid %s algorithms `%s`", algorithmType, algorithms));
}
public InvalidAlgorithmConfigurationException(final String algorithmType, final String algorithm) {
- super(1114, String.format("Invalid %s algorithm %s.", algorithmType, algorithm));
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 150, String.format("Invalid %s algorithm `%s`", algorithmType, algorithm));
}
public InvalidAlgorithmConfigurationException(final String algorithmType) {
- super(1114, String.format("Invalid %s algorithms configuration.", algorithmType));
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 150, String.format("Invalid %s algorithm", algorithmType));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/InvalidRuleConfigurationException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/InvalidRuleConfigurationException.java
index c0f679d75d4..b64d3aef87a 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/InvalidRuleConfigurationException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/InvalidRuleConfigurationException.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.infra.distsql.exception.rule;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
import java.util.Collection;
/**
@@ -26,11 +28,11 @@ public final class InvalidRuleConfigurationException extends RuleDefinitionViola
private static final long serialVersionUID = 6085010920008859376L;
- public InvalidRuleConfigurationException(final String ruleType, final Collection<String> rules, final Collection<String> errorMessages) {
- super(1117, String.format("Invalid %s rule %s, error messages are: %s.", ruleType, rules, errorMessages));
+ public InvalidRuleConfigurationException(final String ruleType, final String rule, final String errorMessage) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 100, "Invalid `%s` rule `%s`, error message is: %s", ruleType, rule, errorMessage);
}
- public InvalidRuleConfigurationException(final String ruleType, final String rule, final String errorMessage) {
- super(1117, String.format("Invalid %s rule %s, error message is: %s.", ruleType, rule, errorMessage));
+ public InvalidRuleConfigurationException(final String ruleType, final Collection<String> rules, final Collection<String> errorMessages) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 100, "Invalid `%s` rules `%s`, error messages are: %s", ruleType, rules, errorMessages);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/MissingRequiredAlgorithmException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/MissingRequiredAlgorithmException.java
new file mode 100644
index 00000000000..f571213c2d1
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/MissingRequiredAlgorithmException.java
@@ -0,0 +1,46 @@
+/*
+ * 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.distsql.exception.rule;
+
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
+import java.util.Collection;
+
+/**
+ * Missing required algorithm exception.
+ */
+public final class MissingRequiredAlgorithmException extends RuleDefinitionViolationException {
+
+ private static final long serialVersionUID = -1952698375135777585L;
+
+ public MissingRequiredAlgorithmException() {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 151, "Algorithm does not exist");
+ }
+
+ public MissingRequiredAlgorithmException(final String type, final String databaseName) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 151, String.format("%s algorithm does not exist in database `%s`", type, databaseName));
+ }
+
+ public MissingRequiredAlgorithmException(final String type, final Collection<String> algorithmNames) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 151, String.format("%s algorithms `%s` do not exist", type, algorithmNames));
+ }
+
+ public MissingRequiredAlgorithmException(final String type, final String databaseName, final Collection<String> algorithmNames) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 151, String.format("%s algorithms `%s` do not exist in database `%s`", type, algorithmNames, databaseName));
+ }
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/MissingRequiredRuleException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/MissingRequiredRuleException.java
new file mode 100644
index 00000000000..2adf0e073ec
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/MissingRequiredRuleException.java
@@ -0,0 +1,50 @@
+/*
+ * 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.distsql.exception.rule;
+
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
+import java.util.Collection;
+
+/**
+ * Missing required rule exception.
+ */
+public final class MissingRequiredRuleException extends RuleDefinitionViolationException {
+
+ private static final long serialVersionUID = -8464574460917965546L;
+
+ public MissingRequiredRuleException(final String ruleType) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 101, String.format("%s rule does not exist", ruleType));
+ }
+
+ public MissingRequiredRuleException(final String ruleType, final String databaseName) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 101, String.format("%s rule does not exist in database `%s`", ruleType, databaseName));
+ }
+
+ public MissingRequiredRuleException(final String ruleType, final Collection<String> ruleNames) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 101, String.format("%s rules `%s` do not exist", ruleType, ruleNames));
+ }
+
+ public MissingRequiredRuleException(final String ruleType, final String databaseName, final String ruleName) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 101, String.format("%s rule `%s` do not exist in database `%s`", ruleType, ruleName, databaseName));
+ }
+
+ public MissingRequiredRuleException(final String ruleType, final String databaseName, final Collection<String> ruleNames) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 101, String.format("%s rules `%s` do not exist in database `%s`", ruleType, ruleNames, databaseName));
+ }
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredAlgorithmMissedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredAlgorithmMissedException.java
deleted file mode 100644
index 5f34844636b..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredAlgorithmMissedException.java
+++ /dev/null
@@ -1,44 +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.distsql.exception.rule;
-
-import java.util.Collection;
-
-/**
- * Required algorithm missed exception.
- */
-public final class RequiredAlgorithmMissedException extends RuleDefinitionViolationException {
-
- private static final long serialVersionUID = -1952698375135777585L;
-
- public RequiredAlgorithmMissedException() {
- super(1115, "No sharding algorithm definition in current statement");
- }
-
- public RequiredAlgorithmMissedException(final String databaseName) {
- super(1115, String.format("Sharding algorithm does not exist in database `%s`.", databaseName));
- }
-
- public RequiredAlgorithmMissedException(final String databaseName, final Collection<String> algorithmNames) {
- super(1115, String.format("Sharding algorithms `%s` do not exist in database `%s`.", algorithmNames, databaseName));
- }
-
- public RequiredAlgorithmMissedException(final String type, final String databaseName, final Collection<String> algorithmNames) {
- super(1115, String.format("%s algorithms `%s` do not exist in database `%s`.", type, algorithmNames, databaseName));
- }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredAuditorMissedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredAuditorMissedException.java
deleted file mode 100644
index 62939728a22..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredAuditorMissedException.java
+++ /dev/null
@@ -1,29 +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.distsql.exception.rule;
-
-import java.util.Collection;
-
-public class RequiredAuditorMissedException extends RuleDefinitionViolationException {
-
- private static final long serialVersionUID = -1347038187749832773L;
-
- public RequiredAuditorMissedException(final String type, final String databaseName, final Collection<String> auditorNames) {
- super(1127, String.format("%s auditor `%s` do not exist in database `%s`.", type, auditorNames, databaseName));
- }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredKeyGeneratorMissedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredKeyGeneratorMissedException.java
deleted file mode 100644
index 44563d511b2..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredKeyGeneratorMissedException.java
+++ /dev/null
@@ -1,29 +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.distsql.exception.rule;
-
-import java.util.Collection;
-
-public class RequiredKeyGeneratorMissedException extends RuleDefinitionViolationException {
-
- private static final long serialVersionUID = -2391552466149640249L;
-
- public RequiredKeyGeneratorMissedException(final String type, final String databaseName, final Collection<String> keyGeneratorNames) {
- super(1118, String.format("%s key generator `%s` do not exist in database `%s`.", type, keyGeneratorNames, databaseName));
- }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredRuleMissedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredRuleMissedException.java
deleted file mode 100644
index 6ce554e1d34..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredRuleMissedException.java
+++ /dev/null
@@ -1,48 +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.distsql.exception.rule;
-
-import java.util.Collection;
-
-/**
- * Required rule missed exception.
- */
-public final class RequiredRuleMissedException extends RuleDefinitionViolationException {
-
- private static final long serialVersionUID = -8464574460917965546L;
-
- public RequiredRuleMissedException(final String ruleType) {
- super(1112, String.format("%s rule does not exist", ruleType));
- }
-
- public RequiredRuleMissedException(final String ruleType, final String databaseName) {
- super(1112, String.format("%s rule does not exist in database `%s`.", ruleType, databaseName));
- }
-
- public RequiredRuleMissedException(final String ruleType, final Collection<String> ruleNames) {
- super(1112, String.format("%s rules `%s` do not exist.", ruleType, ruleNames));
- }
-
- public RequiredRuleMissedException(final String ruleType, final String databaseName, final String ruleName) {
- super(1112, String.format("%s rule `%s` do not exist in database `%s`.", ruleType, ruleName, databaseName));
- }
-
- public RequiredRuleMissedException(final String ruleType, final String databaseName, final Collection<String> ruleNames) {
- super(1112, String.format("%s rules `%s` do not exist in database `%s`.", ruleType, ruleNames, databaseName));
- }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleDefinitionViolationException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleDefinitionViolationException.java
index a3a3b7d8a5f..f7ee8c97e27 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleDefinitionViolationException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleDefinitionViolationException.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.distsql.exception.rule;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.SQLState;
/**
* Rule definition violation exception.
@@ -26,7 +27,7 @@ public abstract class RuleDefinitionViolationException extends DistSQLException
private static final long serialVersionUID = 1090914641996552474L;
- public RuleDefinitionViolationException(final int errorCode, final String reason) {
- super(errorCode, reason);
+ public RuleDefinitionViolationException(final SQLState sqlState, final int errorCode, final String reason, final Object... messageArguments) {
+ super(sqlState, errorCode, reason, messageArguments);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleDisabledException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleDisabledException.java
index f47a87fe114..f7b1cb73c50 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleDisabledException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleDisabledException.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.infra.distsql.exception.rule;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
/**
* Rule disabled exception.
*/
@@ -25,6 +27,6 @@ public final class RuleDisabledException extends RuleDefinitionViolationExceptio
private static final long serialVersionUID = -4024905659258386784L;
public RuleDisabledException(final String ruleType, final String databaseName, final String ruleName) {
- super(1119, String.format("%s rule `%s` has been disabled in database `%s`.", ruleType, ruleName, databaseName));
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 104, "%s rule `%s` has been disabled in database `%s`", ruleType, ruleName, databaseName);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleEnabledException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleEnabledException.java
index b6e93baea6b..3b790825f5b 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleEnabledException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleEnabledException.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.infra.distsql.exception.rule;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
/**
* Rule enabled exception.
*/
@@ -25,6 +27,6 @@ public final class RuleEnabledException extends RuleDefinitionViolationException
private static final long serialVersionUID = 2381983504661441914L;
public RuleEnabledException(final String ruleType, final String databaseName, final String ruleName) {
- super(1120, String.format("%s rule `%s` has been enabled in database `%s`.", ruleType, ruleName, databaseName));
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 103, "%s rule `%s` has been enabled in database `%s`", ruleType, ruleName, databaseName);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleInUsedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleInUsedException.java
index 4fee7572e9f..795e32fb28b 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleInUsedException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RuleInUsedException.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.infra.distsql.exception.rule;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
import java.util.Collection;
/**
@@ -26,11 +28,7 @@ public final class RuleInUsedException extends RuleDefinitionViolationException
private static final long serialVersionUID = 3308787279125477660L;
- public RuleInUsedException(final String ruleType, final String databaseName) {
- super(1111, String.format("%s rule in database `%s` is still in used.", ruleType, databaseName));
- }
-
public RuleInUsedException(final String ruleType, final String databaseName, final Collection<String> ruleNames) {
- super(1111, String.format("%s rules `%s` in database `%s` are still in used.", ruleType, ruleNames, databaseName));
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 102, "%s rules `%s` in database `%s` are still in used", ruleType, ruleNames, databaseName);
}
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdater.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdater.java
index d99bf37a77d..fc7bd1327ff 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdater.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdater.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.traffic.distsql.handler.update;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.GlobalRuleRALUpdater;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
@@ -62,7 +62,7 @@ public final class AlterTrafficRuleStatementUpdater implements GlobalRuleRALUpda
private void checkRuleNames(final ShardingSphereRuleMetaData ruleMetaData, final AlterTrafficRuleStatement sqlStatement) throws DistSQLException {
Collection<String> notExistRuleNames = getNotExistRuleNames(ruleMetaData, sqlStatement);
- ShardingSpherePreconditions.checkState(notExistRuleNames.isEmpty(), () -> new RequiredRuleMissedException("Traffic", notExistRuleNames));
+ ShardingSpherePreconditions.checkState(notExistRuleNames.isEmpty(), () -> new MissingRequiredRuleException("Traffic", notExistRuleNames));
}
private Collection<String> getNotExistRuleNames(final ShardingSphereRuleMetaData ruleMetaData, final AlterTrafficRuleStatement sqlStatement) {
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/DropTrafficRuleStatementUpdater.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/DropTrafficRuleStatementUpdater.java
index 7a2eff34fcc..fe77cd8e759 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/DropTrafficRuleStatementUpdater.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/DropTrafficRuleStatementUpdater.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.traffic.distsql.handler.update;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.GlobalRuleRALUpdater;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
@@ -60,7 +60,7 @@ public final class DropTrafficRuleStatementUpdater implements GlobalRuleRALUpdat
TrafficRuleConfiguration config = rule.getConfiguration();
Collection<String> currentRuleNames = config.getTrafficStrategies().stream().map(TrafficStrategyConfiguration::getName).collect(Collectors.toSet());
Collection<String> notExistRuleNames = sqlStatement.getRuleNames().stream().filter(each -> !currentRuleNames.contains(each)).collect(Collectors.toSet());
- ShardingSpherePreconditions.checkState(notExistRuleNames.isEmpty(), () -> new RequiredRuleMissedException("Traffic"));
+ ShardingSpherePreconditions.checkState(notExistRuleNames.isEmpty(), () -> new MissingRequiredRuleException("Traffic"));
}
private void replaceNewRule(final ShardingSphereRuleMetaData ruleMetaData, final DropTrafficRuleStatement sqlStatement) {
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdaterTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdaterTest.java
index 09d361bc6cb..1bcb18dac41 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdaterTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdaterTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.traffic.distsql.handler.update;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
@@ -45,8 +45,8 @@ import static org.mockito.Mockito.when;
public final class AlterTrafficRuleStatementUpdaterTest {
- @Test(expected = RequiredRuleMissedException.class)
- public void assertExecuteWithNotExistRuleName() throws SQLException {
+ @Test(expected = MissingRequiredRuleException.class)
+ public void assertExecuteWithNotExistRuleName() {
ShardingSphereMetaData metaData = createMetaData();
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment(
"rule_name_3", Arrays.asList("olap", "order_by"), new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
@@ -55,7 +55,7 @@ public final class AlterTrafficRuleStatementUpdaterTest {
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
- public void assertExecuteWithInvalidAlgorithmType() throws SQLException {
+ public void assertExecuteWithInvalidAlgorithmType() {
ShardingSphereMetaData metaData = createMetaData();
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment(
"rule_name_1", Arrays.asList("olap", "order_by"), new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
@@ -64,7 +64,7 @@ public final class AlterTrafficRuleStatementUpdaterTest {
}
@Test(expected = IllegalStateException.class)
- public void assertExecuteWithLoadBalancerCannotBeNull() throws SQLException {
+ public void assertExecuteWithLoadBalancerCannotBeNull() {
ShardingSphereMetaData metaData = createMetaData();
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("rule_name_1", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), null);
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/update/DropTrafficRuleStatementUpdaterTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/update/DropTrafficRuleStatementUpdaterTest.java
index 2a24c3053eb..bf0d056cae5 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/update/DropTrafficRuleStatementUpdaterTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/update/DropTrafficRuleStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.traffic.distsql.handler.update;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
@@ -42,15 +42,15 @@ import static org.mockito.Mockito.when;
public final class DropTrafficRuleStatementUpdaterTest {
- @Test(expected = RequiredRuleMissedException.class)
- public void assertExecuteForNotExistedRuleWithoutIfExists() throws SQLException {
+ @Test(expected = MissingRequiredRuleException.class)
+ public void assertExecuteForNotExistedRuleWithoutIfExists() {
ShardingSphereMetaData metaData = createMetaData();
DropTrafficRuleStatementUpdater updater = new DropTrafficRuleStatementUpdater();
updater.executeUpdate(metaData, new DropTrafficRuleStatement(false, Collections.singleton("not_existed_rule")));
}
@Test
- public void assertExecuteForNotExistedRuleWithIfExists() throws SQLException {
+ public void assertExecuteForNotExistedRuleWithIfExists() {
ShardingSphereMetaData metaData = createMetaData();
DropTrafficRuleStatementUpdater updater = new DropTrafficRuleStatementUpdater();
updater.executeUpdate(metaData, new DropTrafficRuleStatement(true, Collections.singleton("rule_name_3")));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
index f3069e78c7f..6b431d98794 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
@@ -21,7 +21,6 @@ import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.binder.QueryContext;
import org.apache.shardingsphere.infra.binder.aware.CursorDefinitionAware;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
@@ -31,8 +30,7 @@ import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementConte
import org.apache.shardingsphere.infra.binder.type.CursorAvailable;
import org.apache.shardingsphere.infra.context.kernel.KernelProcessor;
import org.apache.shardingsphere.infra.context.refresher.MetaDataRefreshEngine;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
-import org.apache.shardingsphere.proxy.backend.exception.RuleNotExistedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.EmptyResourceException;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResult;
import org.apache.shardingsphere.infra.executor.sql.execute.result.update.UpdateResult;
@@ -43,7 +41,9 @@ import org.apache.shardingsphere.infra.metadata.database.schema.event.MetaDataRe
import org.apache.shardingsphere.infra.metadata.database.schema.util.SystemSchemaUtil;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.exception.RuleNotExistedException;
import org.apache.shardingsphere.proxy.backend.handler.data.DatabaseBackendHandler;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
@@ -95,13 +95,10 @@ public abstract class DatabaseCommunicationEngine implements DatabaseBackendHand
}
}
- @SneakyThrows(SQLException.class)
private void failedIfBackendNotReady(final ConnectionSession connectionSession, final SQLStatementContext<?> sqlStatementContext) {
ShardingSphereDatabase database = ProxyContext.getInstance().getDatabase(connectionSession.getDatabaseName());
boolean isSystemSchema = SystemSchemaUtil.containsSystemSchema(sqlStatementContext.getDatabaseType(), sqlStatementContext.getTablesContext().getSchemaNames(), database);
- if (!isSystemSchema && !database.containsDataSource()) {
- throw new RequiredResourceMissedException(connectionSession.getDatabaseName());
- }
+ ShardingSpherePreconditions.checkState(isSystemSchema || database.containsDataSource(), () -> new EmptyResourceException(connectionSession.getDatabaseName()));
if (!isSystemSchema && !database.isComplete()) {
throw new RuleNotExistedException();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
index 71cc65d0aa5..e9dfa786853 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
@@ -21,9 +21,9 @@ import org.apache.shardingsphere.dbdiscovery.api.config.DatabaseDiscoveryRuleCon
import org.apache.shardingsphere.dbdiscovery.factory.DatabaseDiscoveryProviderAlgorithmFactory;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -58,7 +58,7 @@ public final class DatabaseDiscoveryRuleConfigurationImportChecker {
Collection<String> requireResources = new LinkedHashSet<>();
currentRuleConfig.getDataSources().forEach(each -> requireResources.addAll(each.getDataSourceNames()));
Collection<String> notExistResources = database.getResource().getNotExistedResources(requireResources);
- ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new RequiredResourceMissedException(databaseName, notExistResources));
+ ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistResources));
}
private void checkDiscoverTypeAndHeartbeat(final String databaseName, final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws DistSQLException {
@@ -73,6 +73,6 @@ public final class DatabaseDiscoveryRuleConfigurationImportChecker {
invalidInput.add(each.getDiscoveryHeartbeatName());
}
});
- ShardingSpherePreconditions.checkState(invalidInput.isEmpty(), () -> new RequiredAlgorithmMissedException(DB_DISCOVERY, databaseName, invalidInput));
+ ShardingSpherePreconditions.checkState(invalidInput.isEmpty(), () -> new MissingRequiredAlgorithmException(DB_DISCOVERY, databaseName, invalidInput));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportChecker.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportChecker.java
index 11998997273..5214b5e0d50 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportChecker.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportChecker.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.check
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
@@ -69,10 +69,10 @@ public final class ReadwriteSplittingRuleConfigurationImportChecker {
}
});
Collection<String> notExistResources = database.getResource().getNotExistedResources(requireResources);
- ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new RequiredResourceMissedException(databaseName, notExistResources));
+ ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistResources));
Collection<String> logicResources = getLogicResources(database);
Collection<String> notExistLogicResources = requireDiscoverableResources.stream().filter(each -> !logicResources.contains(each)).collect(Collectors.toSet());
- ShardingSpherePreconditions.checkState(notExistLogicResources.isEmpty(), () -> new RequiredResourceMissedException(databaseName, notExistLogicResources));
+ ShardingSpherePreconditions.checkState(notExistLogicResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistLogicResources));
}
private Collection<String> getLogicResources(final ShardingSphereDatabase database) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
index df4f2f957ef..7077950bd1b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -126,7 +126,7 @@ public final class ShardingRuleConfigurationImportChecker {
Collection<String> notExistedResources = database.getResource().getNotExistedResources(requiredResource);
Collection<String> logicResources = getLogicResources(database);
notExistedResources.removeIf(logicResources::contains);
- ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new RequiredResourceMissedException(databaseName, notExistedResources));
+ ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistedResources));
}
private Collection<String> getLogicResources(final ShardingSphereDatabase database) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java
index a76a1f4c54e..ca300edbdb8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDataba
import org.apache.shardingsphere.infra.distsql.constant.ExportableConstants;
import org.apache.shardingsphere.infra.distsql.constant.ExportableItemConstants;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedDatabase;
import org.apache.shardingsphere.infra.rule.identifier.type.exportable.RuleExportEngine;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -125,7 +125,7 @@ public final class SetReadwriteSplittingStatusHandler extends UpdatableRALBacken
private void checkResourceExists(final ContextManager contextManager, final String databaseName, final String toBeDisabledResource) throws DistSQLException {
Collection<String> notExistedResources = contextManager
.getMetaDataContexts().getMetaData().getDatabase(databaseName).getResource().getNotExistedResources(Collections.singleton(toBeDisabledResource));
- ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new RequiredResourceMissedException(databaseName, Collections.singleton(toBeDisabledResource)));
+ ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, Collections.singleton(toBeDisabledResource)));
}
private void checkIsNotDisabled(final Collection<String> disabledResources, final String toBeEnabledResource) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandler.java
index 300d6a675a9..34a2344c0e5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandler.java
@@ -31,7 +31,7 @@ import org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesVali
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.resource.DuplicateResourceException;
import org.apache.shardingsphere.infra.distsql.exception.resource.InvalidResourcesException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.util.exception.external.server.ShardingSphereServerException;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -109,7 +109,7 @@ public final class AlterResourceBackendHandler extends DatabaseRequiredBackendHa
private void checkResourceNameExisted(final String databaseName, final Collection<String> resourceNames) throws DistSQLException {
Map<String, DataSource> resources = ProxyContext.getInstance().getDatabase(databaseName).getResource().getDataSources();
Collection<String> notExistedResourceNames = resourceNames.stream().filter(each -> !resources.containsKey(each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistedResourceNames.isEmpty(), () -> new RequiredResourceMissedException(databaseName, notExistedResourceNames));
+ ShardingSpherePreconditions.checkState(notExistedResourceNames.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistedResourceNames));
}
private boolean isIdenticalDatabase(final DataSourceSegment segment, final DataSource dataSource) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/DropResourceBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/DropResourceBackendHandler.java
index 5c6f97a28aa..20dd3546126 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/DropResourceBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/DropResourceBackendHandler.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropResourceS
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.resource.InvalidResourcesException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.resource.ResourceInUsedException;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
@@ -80,7 +80,7 @@ public final class DropResourceBackendHandler extends DatabaseRequiredBackendHan
private void checkResourceNameExisted(final String databaseName, final Collection<String> resourceNames) throws DistSQLException {
Map<String, DataSource> resources = ProxyContext.getInstance().getDatabase(databaseName).getResource().getDataSources();
Collection<String> notExistedResourceNames = resourceNames.stream().filter(each -> !resources.containsKey(each)).collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(notExistedResourceNames.isEmpty(), () -> new RequiredResourceMissedException(databaseName, notExistedResourceNames));
+ ShardingSpherePreconditions.checkState(notExistedResourceNames.isEmpty(), () -> new MissingRequiredResourcesException(databaseName, notExistedResourceNames));
}
private void checkResourceNameNotInUse(final String databaseName, final Collection<String> toBeDroppedResourceNames, final boolean ignoreSingleTables) throws DistSQLException {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleStatementUpdater.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleStatementUpdater.java
index 280d65e3449..89a23106db2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleStatementUpdater.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleStatementUpdater.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule;
import org.apache.shardingsphere.distsql.parser.statement.rdl.alter.AlterDefaultSingleTableRuleStatement;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -44,17 +44,17 @@ public final class AlterDefaultSingleTableRuleStatementUpdater implements RuleDe
}
private void checkConfigurationExist(final String databaseName, final SingleTableRuleConfiguration currentRuleConfig) throws DistSQLException {
- ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new RequiredRuleMissedException(databaseName, "single table"));
+ ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new MissingRequiredRuleException(databaseName, "single table"));
}
private void checkResourceExist(final ShardingSphereDatabase database, final AlterDefaultSingleTableRuleStatement sqlStatement) throws DistSQLException {
Set<String> resourceNames = database.getResource().getDataSources().keySet();
ShardingSpherePreconditions.checkState(resourceNames.contains(sqlStatement.getDefaultResource()),
- () -> new RequiredResourceMissedException(database.getName(), Collections.singleton(sqlStatement.getDefaultResource())));
+ () -> new MissingRequiredResourcesException(database.getName(), Collections.singleton(sqlStatement.getDefaultResource())));
}
private void checkDefaultResourceExist(final String databaseName, final SingleTableRuleConfiguration currentRuleConfig) throws DistSQLException {
- ShardingSpherePreconditions.checkState(currentRuleConfig.getDefaultDataSource().isPresent(), () -> new RequiredRuleMissedException("single table", databaseName));
+ ShardingSpherePreconditions.checkState(currentRuleConfig.getDefaultDataSource().isPresent(), () -> new MissingRequiredRuleException("single table", databaseName));
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleStatementUpdater.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleStatementUpdater.java
index e9ac54e0375..1df04211f2b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleStatementUpdater.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleStatementUpdater.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule;
import org.apache.shardingsphere.distsql.parser.statement.rdl.create.CreateDefaultSingleTableRuleStatement;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionCreateUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -44,7 +44,7 @@ public final class CreateDefaultSingleTableRuleStatementUpdater implements RuleD
private void checkResourceExist(final ShardingSphereDatabase database, final CreateDefaultSingleTableRuleStatement sqlStatement) throws DistSQLException {
Collection<String> resourceNames = database.getResource().getDataSources().keySet();
ShardingSpherePreconditions.checkState(resourceNames.contains(sqlStatement.getDefaultResource()),
- () -> new RequiredResourceMissedException(database.getName(), Collections.singleton(sqlStatement.getDefaultResource())));
+ () -> new MissingRequiredResourcesException(database.getName(), Collections.singleton(sqlStatement.getDefaultResource())));
}
private void checkDefaultResourceDuplicate(final String databaseName, final SingleTableRuleConfiguration currentRuleConfig) throws DistSQLException {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/DropDefaultSingleTableRuleStatementUpdater.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/DropDefaultSingleTableRuleStatementUpdater.java
index 3ff7c5056ba..d53404771d9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/DropDefaultSingleTableRuleStatementUpdater.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/DropDefaultSingleTableRuleStatementUpdater.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule;
import org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropDefaultSingleTableRuleStatement;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -40,7 +40,7 @@ public final class DropDefaultSingleTableRuleStatementUpdater implements RuleDef
final DropDefaultSingleTableRuleStatement sqlStatement, final SingleTableRuleConfiguration currentRuleConfig) throws DistSQLException {
if (!sqlStatement.isIfExists()) {
ShardingSpherePreconditions.checkState(null != currentRuleConfig && currentRuleConfig.getDefaultDataSource().isPresent(),
- () -> new RequiredRuleMissedException("single table", databaseName));
+ () -> new MissingRequiredRuleException("single table", databaseName));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
index c407093fc33..f8ab741cb3f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowResources
import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowUnusedResourcesStatement;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
@@ -198,7 +198,7 @@ public final class DistSQLBackendHandlerFactoryTest extends ProxyContextRestorer
assertThat(response, instanceOf(UpdateResponseHeader.class));
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertExecuteDropReadwriteSplittingRuleContext() throws SQLException {
setContextManager(true);
ResponseHeader response = RDLBackendHandlerFactory.newInstance(mock(DropReadwriteSplittingRuleStatement.class), connectionSession).execute();
@@ -212,7 +212,7 @@ public final class DistSQLBackendHandlerFactoryTest extends ProxyContextRestorer
assertThat(response, instanceOf(UpdateResponseHeader.class));
}
- @Test(expected = RequiredRuleMissedException.class)
+ @Test(expected = MissingRequiredRuleException.class)
public void assertExecuteAlterReadwriteSplittingRuleContext() throws SQLException {
setContextManager(true);
ResponseHeader response = RDLBackendHandlerFactory.newInstance(mock(AlterReadwriteSplittingRuleStatement.class), connectionSession).execute();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandlerTest.java
index 3158d2691fd..f8929fe6794 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterResourceBackendHandlerTest.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesVali
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.resource.DuplicateResourceException;
import org.apache.shardingsphere.infra.distsql.exception.resource.InvalidResourcesException;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -109,7 +109,7 @@ public final class AlterResourceBackendHandlerTest extends ProxyContextRestorer
alterResourceBackendHandler.execute("test_db", createAlterResourceStatementWithDuplicateResourceNames());
}
- @Test(expected = RequiredResourceMissedException.class)
+ @Test(expected = MissingRequiredResourcesException.class)
public void assertExecuteWithNotExistedResourceNames() throws DistSQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
@@ -121,7 +121,7 @@ public final class AlterResourceBackendHandlerTest extends ProxyContextRestorer
}
@Test(expected = InvalidResourcesException.class)
- public void assertExecuteWithAlterDatabase() throws Exception {
+ public void assertExecuteWithAlterDatabase() {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
ProxyContext.init(contextManager);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleUpdaterTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleUpdaterTest.java
index 491a85398da..c709b0aedf9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleUpdaterTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/AlterDefaultSingleTableRuleUpdaterTest.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule;
import org.apache.shardingsphere.distsql.parser.statement.rdl.alter.AlterDefaultSingleTableRuleStatement;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration;
import org.apache.shardingsphere.test.mock.MockedDataSource;
@@ -55,18 +55,18 @@ public final class AlterDefaultSingleTableRuleUpdaterTest {
when(database.getResource().getDataSources()).thenReturn(Collections.singletonMap("ds_0", new MockedDataSource()));
}
- @Test(expected = RequiredRuleMissedException.class)
- public void assertCheckWithNotExistConfiguration() throws Exception {
+ @Test(expected = MissingRequiredRuleException.class)
+ public void assertCheckWithNotExistConfiguration() {
updater.checkSQLStatement(database, new AlterDefaultSingleTableRuleStatement("ds_1"), null);
}
- @Test(expected = RequiredResourceMissedException.class)
- public void assertCheckWithInvalidResource() throws Exception {
+ @Test(expected = MissingRequiredResourcesException.class)
+ public void assertCheckWithInvalidResource() {
updater.checkSQLStatement(database, new AlterDefaultSingleTableRuleStatement("ds_1"), currentConfig);
}
- @Test(expected = RequiredRuleMissedException.class)
- public void assertCheckWithNotExistResource() throws Exception {
+ @Test(expected = MissingRequiredRuleException.class)
+ public void assertCheckWithNotExistResource() {
when(currentConfig.getDefaultDataSource()).thenReturn(Optional.empty());
updater.checkSQLStatement(database, new AlterDefaultSingleTableRuleStatement("ds_0"), currentConfig);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleUpdaterTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleUpdaterTest.java
index deadb365a14..9ab4f18d8ff 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleUpdaterTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/CreateDefaultSingleTableRuleUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule;
import org.apache.shardingsphere.distsql.parser.statement.rdl.create.CreateDefaultSingleTableRuleStatement;
-import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.MissingRequiredResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration;
@@ -55,13 +55,13 @@ public final class CreateDefaultSingleTableRuleUpdaterTest {
when(database.getResource().getDataSources()).thenReturn(Collections.singletonMap("ds_0", new MockedDataSource()));
}
- @Test(expected = RequiredResourceMissedException.class)
- public void assertCheckWithInvalidResource() throws Exception {
+ @Test(expected = MissingRequiredResourcesException.class)
+ public void assertCheckWithInvalidResource() {
updater.checkSQLStatement(database, new CreateDefaultSingleTableRuleStatement("ds_1"), currentConfig);
}
@Test(expected = DuplicateRuleException.class)
- public void assertCheckWithDuplicateResource() throws Exception {
+ public void assertCheckWithDuplicateResource() {
when(currentConfig.getDefaultDataSource()).thenReturn(Optional.of("single_table"));
updater.checkSQLStatement(database, new CreateDefaultSingleTableRuleStatement("ds_0"), currentConfig);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/DropDefaultSingleTableRuleUpdaterTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/DropDefaultSingleTableRuleUpdaterTest.java
index 41315dbd649..e535c8fd139 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/DropDefaultSingleTableRuleUpdaterTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/DropDefaultSingleTableRuleUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule;
import org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropDefaultSingleTableRuleStatement;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration;
import org.apache.shardingsphere.test.mock.MockedDataSource;
@@ -48,18 +48,18 @@ public final class DropDefaultSingleTableRuleUpdaterTest {
when(database.getResource().getDataSources()).thenReturn(Collections.singletonMap("ds_0", new MockedDataSource()));
}
- @Test(expected = RequiredRuleMissedException.class)
- public void assertCheckWithoutConfig() throws Exception {
+ @Test(expected = MissingRequiredRuleException.class)
+ public void assertCheckWithoutConfig() {
updater.checkSQLStatement(database, new DropDefaultSingleTableRuleStatement(), null);
}
- @Test(expected = RequiredRuleMissedException.class)
- public void assertCheckWithoutResource() throws Exception {
+ @Test(expected = MissingRequiredRuleException.class)
+ public void assertCheckWithoutResource() {
updater.checkSQLStatement(database, new DropDefaultSingleTableRuleStatement(), new SingleTableRuleConfiguration());
}
@Test
- public void assertCheckWithIfExists() throws Exception {
+ public void assertCheckWithIfExists() {
DropDefaultSingleTableRuleStatement statement = new DropDefaultSingleTableRuleStatement(true);
SingleTableRuleConfiguration currentConfig = new SingleTableRuleConfiguration();
updater.checkSQLStatement(database, statement, currentConfig);