You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2021/07/04 07:03:29 UTC
[shardingsphere] branch master updated: Add
ResourceDefinitionViolationException (#11136)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 83216cb Add ResourceDefinitionViolationException (#11136)
83216cb is described below
commit 83216cb8e0d277c40d499d8c6ad41413990dc1b5
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Jul 4 15:02:59 2021 +0800
Add ResourceDefinitionViolationException (#11136)
* Add ResourceDefinitionViolationException
* Add ResourceDefinitionViolationException
* Rename DuplicateRuleException
* Rename RequiredRuleMissedException
* Rename RequiredResourceMissedException
---
...AlterDatabaseDiscoveryRuleStatementUpdater.java | 20 ++++++++---------
...reateDatabaseDiscoveryRuleStatementUpdater.java | 16 ++++++-------
.../DropDatabaseDiscoveryRuleStatementUpdater.java | 10 ++++-----
...rDatabaseDiscoveryRuleStatementUpdaterTest.java | 20 ++++++++---------
...eDatabaseDiscoveryRuleStatementUpdaterTest.java | 16 ++++++-------
...pDatabaseDiscoveryRuleStatementUpdaterTest.java | 6 ++---
.../update/AlterEncryptRuleStatementUpdater.java | 10 ++++-----
.../update/CreateEncryptRuleStatementUpdater.java | 6 ++---
.../update/DropEncryptRuleStatementUpdater.java | 10 ++++-----
.../AlterEncryptRuleStatementUpdaterTest.java | 6 ++---
.../CreateEncryptRuleStatementUpdaterTest.java | 4 ++--
.../DropEncryptRuleStatementUpdaterTest.java | 6 ++---
...lterReadwriteSplittingRuleStatementUpdater.java | 20 ++++++++---------
...eateReadwriteSplittingRuleStatementUpdater.java | 16 ++++++-------
...DropReadwriteSplittingRuleStatementUpdater.java | 10 ++++-----
...ReadwriteSplittingRuleStatementUpdaterTest.java | 20 ++++++++---------
...ReadwriteSplittingRuleStatementUpdaterTest.java | 16 ++++++-------
...ReadwriteSplittingRuleStatementUpdaterTest.java | 6 ++---
...erShardingBindingTableRuleStatementUpdater.java | 12 +++++-----
.../AlterShardingTableRuleStatementUpdater.java | 26 +++++++++++-----------
...teShardingBindingTableRuleStatementUpdater.java | 6 ++---
.../CreateShardingTableRuleStatementUpdater.java | 16 ++++++-------
.../DropShardingTableRuleStatementUpdater.java | 6 ++---
...ardingBindingTableRuleStatementUpdaterTest.java | 8 +++----
...AlterShardingTableRuleStatementUpdaterTest.java | 20 ++++++++---------
...ardingBindingTableRuleStatementUpdaterTest.java | 4 ++--
...reateShardingTableRuleStatementUpdaterTest.java | 10 ++++-----
.../DropShardingTableRuleStatementUpdaterTest.java | 4 ++--
.../infra/distsql/update/RDLUpdater.java | 6 ++---
...tion.java => DefinitionViolationException.java} | 10 ++++-----
.../DuplicateResourceException.java | 4 ++--
.../InvalidResourceException.java | 4 ++--
.../RequiredResourceMissedException.java} | 8 +++----
.../ResourceDefinitionViolationException.java} | 14 ++++++------
.../ResourceInUsedException.java | 4 ++--
...dException.java => DuplicateRuleException.java} | 6 ++---
...ption.java => RequiredRuleMissedException.java} | 8 +++----
.../rule/RuleDefinitionViolationException.java | 6 ++---
.../text/distsql/rdl/RDLBackendHandler.java | 3 ++-
.../rdl/impl/AddResourceBackendHandler.java | 8 +++----
.../rdl/impl/DropResourceBackendHandler.java | 14 ++++++------
.../distsql/DistSQLBackendHandlerFactoryTest.java | 6 ++---
.../rdl/impl/AddResourceBackendHandlerTest.java | 8 +++----
43 files changed, 220 insertions(+), 219 deletions(-)
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 826ec16..33292bd 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
@@ -25,10 +25,10 @@ import org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDisc
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.AlterDatabaseDiscoveryRuleStatement;
import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryType;
import org.apache.shardingsphere.infra.distsql.update.RDLAlterUpdater;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.ResourceNotExistedException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
@@ -51,25 +51,25 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdater implements RDLAlte
@Override
public void checkSQLStatement(final String schemaName, final AlterDatabaseDiscoveryRuleStatement sqlStatement,
- final DatabaseDiscoveryRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+ final DatabaseDiscoveryRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws DefinitionViolationException {
checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
checkToBeAlteredRules(schemaName, sqlStatement, currentRuleConfig);
checkToBeAlteredResources(schemaName, sqlStatement, resource);
checkToBeAlteredDiscoveryType(sqlStatement);
}
- private void checkCurrentRuleConfiguration(final String schemaName, final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ private void checkCurrentRuleConfiguration(final String schemaName, final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
if (null == currentRuleConfig) {
- throw new CurrentRuleNotExistedException("Database discovery", schemaName);
+ throw new RequiredRuleMissedException("Database discovery", schemaName);
}
}
private void checkToBeAlteredRules(final String schemaName, final AlterDatabaseDiscoveryRuleStatement sqlStatement,
- final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
Collection<String> currentRuleNames = currentRuleConfig.getDataSources().stream().map(DatabaseDiscoveryDataSourceRuleConfiguration::getName).collect(Collectors.toSet());
Collection<String> notExistedRuleNames = getToBeAlteredRuleNames(sqlStatement).stream().filter(each -> !currentRuleNames.contains(each)).collect(Collectors.toList());
if (!notExistedRuleNames.isEmpty()) {
- throw new CurrentRuleNotExistedException("Database discovery", schemaName, notExistedRuleNames);
+ throw new RequiredRuleMissedException("Database discovery", schemaName, notExistedRuleNames);
}
}
@@ -77,10 +77,10 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdater implements RDLAlte
return sqlStatement.getRules().stream().map(DatabaseDiscoveryRuleSegment::getName).collect(Collectors.toList());
}
- private void checkToBeAlteredResources(final String schemaName, final AlterDatabaseDiscoveryRuleStatement sqlStatement, final ShardingSphereResource resource) throws ResourceNotExistedException {
+ private void checkToBeAlteredResources(final String schemaName, final AlterDatabaseDiscoveryRuleStatement sqlStatement, final ShardingSphereResource resource) throws RequiredResourceMissedException {
Collection<String> notExistedResources = resource.getNotExistedResources(getToBeAlteredResourceNames(sqlStatement));
if (!notExistedResources.isEmpty()) {
- throw new ResourceNotExistedException(schemaName, notExistedResources);
+ throw new RequiredResourceMissedException(schemaName, notExistedResources);
}
}
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 8d26fc6..2284bc1 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
@@ -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.dbdiscovery.spi.DatabaseDiscoveryType;
import org.apache.shardingsphere.infra.distsql.update.RDLCreateUpdater;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.RequiredResourceMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.ResourceNotExistedException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
@@ -50,20 +50,20 @@ public final class CreateDatabaseDiscoveryRuleStatementUpdater implements RDLCre
@Override
public void checkSQLStatement(final String schemaName, final CreateDatabaseDiscoveryRuleStatement sqlStatement,
- final DatabaseDiscoveryRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+ final DatabaseDiscoveryRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws DefinitionViolationException {
checkDuplicateRuleNames(schemaName, sqlStatement, currentRuleConfig);
checkToBeCreatedResources(schemaName, sqlStatement, resource);
checkToBeCreatedDiscoverTypes(sqlStatement);
}
private void checkDuplicateRuleNames(final String schemaName, final CreateDatabaseDiscoveryRuleStatement sqlStatement,
- final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws RuleDuplicatedException {
+ final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws DuplicateRuleException {
if (null != currentRuleConfig) {
Collection<String> existRuleNames = currentRuleConfig.getDataSources().stream().map(DatabaseDiscoveryDataSourceRuleConfiguration::getName).collect(Collectors.toList());
Collection<String> duplicateRuleNames = sqlStatement.getRules().stream().map(DatabaseDiscoveryRuleSegment::getName).filter(existRuleNames::contains).collect(Collectors.toSet());
duplicateRuleNames.addAll(getToBeCreatedDuplicateRuleNames(sqlStatement));
if (!duplicateRuleNames.isEmpty()) {
- throw new RuleDuplicatedException("database discovery", schemaName, duplicateRuleNames);
+ throw new DuplicateRuleException("database discovery", schemaName, duplicateRuleNames);
}
}
}
@@ -77,12 +77,12 @@ public final class CreateDatabaseDiscoveryRuleStatementUpdater implements RDLCre
.collect(Collectors.toSet());
}
- private void checkToBeCreatedResources(final String schemaName, final CreateDatabaseDiscoveryRuleStatement sqlStatement, final ShardingSphereResource resource) throws ResourceNotExistedException {
+ private void checkToBeCreatedResources(final String schemaName, final CreateDatabaseDiscoveryRuleStatement sqlStatement, final ShardingSphereResource resource) throws RequiredResourceMissedException {
Collection<String> resources = new LinkedHashSet<>();
sqlStatement.getRules().forEach(each -> resources.addAll(each.getDataSources()));
Collection<String> notExistResources = resource.getNotExistedResources(resources);
if (!notExistResources.isEmpty()) {
- throw new ResourceNotExistedException(schemaName, notExistResources);
+ throw new RequiredResourceMissedException(schemaName, notExistResources);
}
}
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 c78ee2a..9b44631 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
@@ -22,7 +22,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.DropDatabaseDiscoveryRuleStatement;
import org.apache.shardingsphere.infra.distsql.update.RDLDropUpdater;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
@@ -42,18 +42,18 @@ public final class DropDatabaseDiscoveryRuleStatementUpdater implements RDLDropU
checkToBeDroppedRuleNames(schemaName, sqlStatement, currentRuleConfig);
}
- private void checkCurrentRuleConfiguration(final String schemaName, final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ private void checkCurrentRuleConfiguration(final String schemaName, final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
if (null == currentRuleConfig) {
- throw new CurrentRuleNotExistedException("Database discovery", schemaName);
+ throw new RequiredRuleMissedException("Database discovery", schemaName);
}
}
private void checkToBeDroppedRuleNames(final String schemaName, final DropDatabaseDiscoveryRuleStatement sqlStatement,
- final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ final DatabaseDiscoveryRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
Collection<String> currentRuleNames = currentRuleConfig.getDataSources().stream().map(DatabaseDiscoveryDataSourceRuleConfiguration::getName).collect(Collectors.toList());
Collection<String> notExistedRuleNames = sqlStatement.getRuleNames().stream().filter(each -> !currentRuleNames.contains(each)).collect(Collectors.toList());
if (!notExistedRuleNames.isEmpty()) {
- throw new CurrentRuleNotExistedException("Database discovery", schemaName, notExistedRuleNames);
+ throw new RequiredRuleMissedException("Database discovery", schemaName, notExistedRuleNames);
}
}
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 ccc865f..d244b9c 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
@@ -21,10 +21,10 @@ import org.apache.shardingsphere.dbdiscovery.api.config.DatabaseDiscoveryRuleCon
import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
import org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDiscoveryRuleSegment;
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.AlterDatabaseDiscoveryRuleStatement;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.ResourceNotExistedException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.junit.Test;
@@ -42,26 +42,26 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdaterTest {
private final AlterDatabaseDiscoveryRuleStatementUpdater updater = new AlterDatabaseDiscoveryRuleStatementUpdater();
- @Test(expected = CurrentRuleNotExistedException.class)
- public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
+ @Test(expected = RequiredRuleMissedException.class)
+ public void assertCheckSQLStatementWithoutCurrentRule() throws DefinitionViolationException {
updater.checkSQLStatement("foo", new AlterDatabaseDiscoveryRuleStatement(Collections.emptyList()), null, mock(ShardingSphereResource.class));
}
- @Test(expected = CurrentRuleNotExistedException.class)
- public void assertCheckSQLStatementWithoutToBeAlteredDatabaseDiscoveryRule() throws RuleDefinitionViolationException {
+ @Test(expected = RequiredRuleMissedException.class)
+ public void assertCheckSQLStatementWithoutToBeAlteredDatabaseDiscoveryRule() throws DefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("TEST"),
new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap()), mock(ShardingSphereResource.class));
}
- @Test(expected = ResourceNotExistedException.class)
- public void assertCheckSQLStatementWithoutExistedResources() throws RuleDefinitionViolationException {
+ @Test(expected = RequiredResourceMissedException.class)
+ public void assertCheckSQLStatementWithoutExistedResources() throws DefinitionViolationException {
ShardingSphereResource resource = mock(ShardingSphereResource.class);
when(resource.getNotExistedResources(any())).thenReturn(Collections.singleton("ds0"));
updater.checkSQLStatement("foo", createSQLStatement("TEST"), createCurrentRuleConfiguration(), resource);
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
- public void assertCheckSQLStatementWithoutToBeAlteredDiscoveryTypes() throws RuleDefinitionViolationException {
+ public void assertCheckSQLStatementWithoutToBeAlteredDiscoveryTypes() throws DefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("INVALID_TYPE"), createCurrentRuleConfiguration(), mock(ShardingSphereResource.class));
}
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 f07b4c2..8fc3240 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
@@ -21,10 +21,10 @@ import org.apache.shardingsphere.dbdiscovery.api.config.DatabaseDiscoveryRuleCon
import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
import org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDiscoveryRuleSegment;
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.CreateDatabaseDiscoveryRuleStatement;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.RequiredResourceMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.ResourceNotExistedException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.junit.Test;
@@ -40,22 +40,22 @@ public final class CreateDatabaseDiscoveryRuleStatementUpdaterTest {
private final CreateDatabaseDiscoveryRuleStatementUpdater updater = new CreateDatabaseDiscoveryRuleStatementUpdater();
- @Test(expected = RuleDuplicatedException.class)
- public void assertCheckSQLStatementWithDuplicateRuleNames() throws RuleDefinitionViolationException {
+ @Test(expected = DuplicateRuleException.class)
+ public void assertCheckSQLStatementWithDuplicateRuleNames() throws DefinitionViolationException {
DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("pr_ds", Collections.emptyList(), "test");
updater.checkSQLStatement(
"foo", createSQLStatement("TEST"), new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceRuleConfig), Collections.emptyMap()), mock(ShardingSphereResource.class));
}
- @Test(expected = ResourceNotExistedException.class)
- public void assertCheckSQLStatementWithoutExistedResources() throws RuleDefinitionViolationException {
+ @Test(expected = RequiredResourceMissedException.class)
+ public void assertCheckSQLStatementWithoutExistedResources() throws DefinitionViolationException {
ShardingSphereResource resource = mock(ShardingSphereResource.class);
when(resource.getNotExistedResources(any())).thenReturn(Collections.singleton("ds_read_0"));
updater.checkSQLStatement("foo", createSQLStatement("TEST"), null, resource);
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
- public void assertCheckSQLStatementWithDatabaseDiscoveryType() throws RuleDefinitionViolationException {
+ public void assertCheckSQLStatementWithDatabaseDiscoveryType() throws DefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("INVALID_TYPE"), null, mock(ShardingSphereResource.class));
}
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 f37cba6..7bcf66a 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
@@ -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.DropDatabaseDiscoveryRuleStatement;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.junit.Test;
@@ -38,12 +38,12 @@ public final class DropDatabaseDiscoveryRuleStatementUpdaterTest {
private final DropDatabaseDiscoveryRuleStatementUpdater updater = new DropDatabaseDiscoveryRuleStatementUpdater();
- @Test(expected = CurrentRuleNotExistedException.class)
+ @Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement(), null, mock(ShardingSphereResource.class));
}
- @Test(expected = CurrentRuleNotExistedException.class)
+ @Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithoutToBeDroppedRules() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement(), new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap()), mock(ShardingSphereResource.class));
}
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 03f29a9..bb23db0 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
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegme
import org.apache.shardingsphere.encrypt.distsql.parser.statement.AlterEncryptRuleStatement;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.infra.distsql.update.RDLAlterUpdater;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
@@ -56,17 +56,17 @@ public final class AlterEncryptRuleStatementUpdater implements RDLAlterUpdater<A
checkToBeAlteredEncryptors(sqlStatement);
}
- private void checkCurrentRuleConfiguration(final String schemaName, final EncryptRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ private void checkCurrentRuleConfiguration(final String schemaName, final EncryptRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
if (null == currentRuleConfig) {
- throw new CurrentRuleNotExistedException("Encrypt", schemaName);
+ throw new RequiredRuleMissedException("Encrypt", schemaName);
}
}
- private void checkToBeAlteredRules(final String schemaName, final AlterEncryptRuleStatement sqlStatement, final EncryptRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ private void checkToBeAlteredRules(final String schemaName, final AlterEncryptRuleStatement sqlStatement, final EncryptRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
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 CurrentRuleNotExistedException("Encrypt", schemaName, notExistEncryptTableNames);
+ throw new RequiredRuleMissedException("Encrypt", schemaName, notExistEncryptTableNames);
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdater.java
index b08cbc0..dd24c79 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdater.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegme
import org.apache.shardingsphere.encrypt.distsql.parser.statement.CreateEncryptRuleStatement;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.infra.distsql.update.RDLCreateUpdater;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
@@ -54,12 +54,12 @@ public final class CreateEncryptRuleStatementUpdater implements RDLCreateUpdater
// TODO check resource
}
- private void checkDuplicateRuleNames(final String schemaName, final CreateEncryptRuleStatement sqlStatement, final EncryptRuleConfiguration currentRuleConfig) throws RuleDuplicatedException {
+ private void checkDuplicateRuleNames(final String schemaName, final CreateEncryptRuleStatement sqlStatement, final EncryptRuleConfiguration currentRuleConfig) throws DuplicateRuleException {
if (null != currentRuleConfig) {
Collection<String> currentRuleNames = currentRuleConfig.getTables().stream().map(EncryptTableRuleConfiguration::getName).collect(Collectors.toList());
Collection<String> toBeCreatedDuplicateRuleNames = sqlStatement.getRules().stream().map(EncryptRuleSegment::getTableName).filter(currentRuleNames::contains).collect(Collectors.toList());
if (!toBeCreatedDuplicateRuleNames.isEmpty()) {
- throw new RuleDuplicatedException("encrypt", schemaName, toBeCreatedDuplicateRuleNames);
+ throw new DuplicateRuleException("encrypt", schemaName, toBeCreatedDuplicateRuleNames);
}
}
}
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 3e4b43f..0c54004 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
@@ -22,7 +22,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.update.RDLDropUpdater;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
@@ -42,18 +42,18 @@ public final class DropEncryptRuleStatementUpdater implements RDLDropUpdater<Dro
checkToBeDroppedEncryptTableNames(schemaName, sqlStatement, currentRuleConfig);
}
- private void checkCurrentRuleConfiguration(final String schemaName, final EncryptRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ private void checkCurrentRuleConfiguration(final String schemaName, final EncryptRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
if (null == currentRuleConfig) {
- throw new CurrentRuleNotExistedException("Encrypt", schemaName);
+ throw new RequiredRuleMissedException("Encrypt", schemaName);
}
}
private void checkToBeDroppedEncryptTableNames(final String schemaName, final DropEncryptRuleStatement sqlStatement,
- final EncryptRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ final EncryptRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
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());
if (!notExistedTableNames.isEmpty()) {
- throw new CurrentRuleNotExistedException("Encrypt", schemaName, notExistedTableNames);
+ throw new RequiredRuleMissedException("Encrypt", schemaName, notExistedTableNames);
}
}
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 cfb8711..d955c60 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
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfigu
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptColumnSegment;
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegment;
import org.apache.shardingsphere.encrypt.distsql.parser.statement.AlterEncryptRuleStatement;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
@@ -40,12 +40,12 @@ public final class AlterEncryptRuleStatementUpdaterTest {
private final AlterEncryptRuleStatementUpdater updater = new AlterEncryptRuleStatementUpdater();
- @Test(expected = CurrentRuleNotExistedException.class)
+ @Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("MD5"), null, mock(ShardingSphereResource.class));
}
- @Test(expected = CurrentRuleNotExistedException.class)
+ @Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithoutToBeAlteredRules() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("MD5"), new EncryptRuleConfiguration(Collections.emptyList(), new HashMap<>()), mock(ShardingSphereResource.class));
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdaterTest.java
index a0c30e0..605c367 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdaterTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfigu
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptColumnSegment;
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegment;
import org.apache.shardingsphere.encrypt.distsql.parser.statement.CreateEncryptRuleStatement;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
@@ -38,7 +38,7 @@ public final class CreateEncryptRuleStatementUpdaterTest {
private final CreateEncryptRuleStatementUpdater updater = new CreateEncryptRuleStatementUpdater();
- @Test(expected = RuleDuplicatedException.class)
+ @Test(expected = DuplicateRuleException.class)
public void assertCheckSQLStatementWithDuplicateEncryptRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("MD5"), getCurrentRuleConfig(), mock(ShardingSphereResource.class));
}
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 27e7b46..a942982 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
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfig
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.distsql.parser.statement.DropEncryptRuleStatement;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.junit.Test;
@@ -39,12 +39,12 @@ public final class DropEncryptRuleStatementUpdaterTest {
private final DropEncryptRuleStatementUpdater updater = new DropEncryptRuleStatementUpdater();
- @Test(expected = CurrentRuleNotExistedException.class)
+ @Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement(), null, mock(ShardingSphereResource.class));
}
- @Test(expected = CurrentRuleNotExistedException.class)
+ @Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithoutToBeDroppedRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement(), new EncryptRuleConfiguration(Collections.emptyList(), Collections.emptyMap()), mock(ShardingSphereResource.class));
}
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 0fe9f8c..2d1c7f9 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
@@ -20,10 +20,10 @@ package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.distsql.update.RDLAlterUpdater;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.ResourceNotExistedException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
@@ -52,25 +52,25 @@ public final class AlterReadwriteSplittingRuleStatementUpdater implements RDLAlt
@Override
public void checkSQLStatement(final String schemaName, final AlterReadwriteSplittingRuleStatement sqlStatement,
- final ReadwriteSplittingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+ final ReadwriteSplittingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws DefinitionViolationException {
checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
checkToBeAlteredRules(schemaName, sqlStatement, currentRuleConfig);
checkToBeAlteredResources(schemaName, sqlStatement, resource);
checkToBeAlteredLoadBalancer(sqlStatement);
}
- private void checkCurrentRuleConfiguration(final String schemaName, final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ private void checkCurrentRuleConfiguration(final String schemaName, final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
if (null == currentRuleConfig) {
- throw new CurrentRuleNotExistedException("Readwrite splitting", schemaName);
+ throw new RequiredRuleMissedException("Readwrite splitting", schemaName);
}
}
private void checkToBeAlteredRules(final String schemaName, final AlterReadwriteSplittingRuleStatement sqlStatement,
- final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
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 CurrentRuleNotExistedException("Readwrite splitting", schemaName, notExistedRuleNames);
+ throw new RequiredRuleMissedException("Readwrite splitting", schemaName, notExistedRuleNames);
}
}
@@ -86,7 +86,7 @@ public final class AlterReadwriteSplittingRuleStatementUpdater implements RDLAlt
}
}
- private void checkToBeAlteredResources(final String schemaName, final AlterReadwriteSplittingRuleStatement sqlStatement, final ShardingSphereResource resource) throws ResourceNotExistedException {
+ private void checkToBeAlteredResources(final String schemaName, final AlterReadwriteSplittingRuleStatement sqlStatement, final ShardingSphereResource resource) throws RequiredResourceMissedException {
Collection<String> resources = new LinkedHashSet<>();
sqlStatement.getRules().stream().filter(each -> Strings.isNullOrEmpty(each.getAutoAwareResource())).forEach(each -> {
resources.add(each.getWriteDataSource());
@@ -94,7 +94,7 @@ public final class AlterReadwriteSplittingRuleStatementUpdater implements RDLAlt
});
Collection<String> notExistedResources = resource.getNotExistedResources(resources);
if (!notExistedResources.isEmpty()) {
- throw new ResourceNotExistedException(schemaName, notExistedResources);
+ throw new RequiredResourceMissedException(schemaName, notExistedResources);
}
}
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 ad2f86d..a689892 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
@@ -19,10 +19,10 @@ package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.distsql.update.RDLCreateUpdater;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.RequiredResourceMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.ResourceNotExistedException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
@@ -50,28 +50,28 @@ public final class CreateReadwriteSplittingRuleStatementUpdater implements RDLCr
@Override
public void checkSQLStatement(final String schemaName, final CreateReadwriteSplittingRuleStatement sqlStatement,
- final ReadwriteSplittingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+ final ReadwriteSplittingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws DefinitionViolationException {
checkDuplicateRuleNames(schemaName, sqlStatement, currentRuleConfig);
checkToBeCreatedResources(schemaName, sqlStatement, resource);
checkToBeCreatedLoadBalancers(sqlStatement);
}
private void checkDuplicateRuleNames(final String schemaName, final CreateReadwriteSplittingRuleStatement sqlStatement,
- final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws RuleDuplicatedException {
+ final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws DuplicateRuleException {
if (null != currentRuleConfig) {
Collection<String> currentRuleNames = currentRuleConfig.getDataSources().stream().map(ReadwriteSplittingDataSourceRuleConfiguration::getName).collect(Collectors.toList());
Collection<String> duplicateRuleNames = sqlStatement.getRules().stream().map(ReadwriteSplittingRuleSegment::getName).filter(currentRuleNames::contains).collect(Collectors.toList());
if (!duplicateRuleNames.isEmpty()) {
- throw new RuleDuplicatedException("readwrite splitting", schemaName, duplicateRuleNames);
+ throw new DuplicateRuleException("readwrite splitting", schemaName, duplicateRuleNames);
}
}
}
private void checkToBeCreatedResources(final String schemaName, final CreateReadwriteSplittingRuleStatement sqlStatement,
- final ShardingSphereResource resource) throws ResourceNotExistedException {
+ final ShardingSphereResource resource) throws RequiredResourceMissedException {
Collection<String> notExistResources = resource.getNotExistedResources(getToBeCreatedResources(sqlStatement));
if (!notExistResources.isEmpty()) {
- throw new ResourceNotExistedException(schemaName, notExistResources);
+ throw new RequiredResourceMissedException(schemaName, notExistResources);
}
}
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 74c3982..cc85c64 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
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import com.google.common.base.Preconditions;
import org.apache.shardingsphere.infra.distsql.update.RDLDropUpdater;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
@@ -42,18 +42,18 @@ public final class DropReadwriteSplittingRuleStatementUpdater implements RDLDrop
checkToBeDroppedRuleNames(schemaName, sqlStatement, currentRuleConfig);
}
- private void checkCurrentRuleConfiguration(final String schemaName, final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ private void checkCurrentRuleConfiguration(final String schemaName, final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
if (null == currentRuleConfig) {
- throw new CurrentRuleNotExistedException("Readwrite splitting", schemaName);
+ throw new RequiredRuleMissedException("Readwrite splitting", schemaName);
}
}
private void checkToBeDroppedRuleNames(final String schemaName, final DropReadwriteSplittingRuleStatement sqlStatement,
- final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ final ReadwriteSplittingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
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 CurrentRuleNotExistedException("Readwrite splitting", schemaName, sqlStatement.getRuleNames());
+ throw new RequiredRuleMissedException("Readwrite splitting", schemaName, 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 32df413..bfb93ac 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
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.ResourceNotExistedException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
@@ -42,25 +42,25 @@ public final class AlterReadwriteSplittingRuleStatementUpdaterTest {
private final AlterReadwriteSplittingRuleStatementUpdater updater = new AlterReadwriteSplittingRuleStatementUpdater();
- @Test(expected = CurrentRuleNotExistedException.class)
- public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
+ @Test(expected = RequiredRuleMissedException.class)
+ public void assertCheckSQLStatementWithoutCurrentRule() throws DefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("TEST"), null, mock(ShardingSphereResource.class));
}
- @Test(expected = CurrentRuleNotExistedException.class)
- public void assertCheckSQLStatementWithoutToBeAlteredRules() throws RuleDefinitionViolationException {
+ @Test(expected = RequiredRuleMissedException.class)
+ public void assertCheckSQLStatementWithoutToBeAlteredRules() throws DefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("TEST"), new ReadwriteSplittingRuleConfiguration(Collections.emptyList(), Collections.emptyMap()), mock(ShardingSphereResource.class));
}
- @Test(expected = ResourceNotExistedException.class)
- public void assertCheckSQLStatementWithoutExistedResources() throws RuleDefinitionViolationException {
+ @Test(expected = RequiredResourceMissedException.class)
+ public void assertCheckSQLStatementWithoutExistedResources() throws DefinitionViolationException {
ShardingSphereResource resource = mock(ShardingSphereResource.class);
when(resource.getNotExistedResources(any())).thenReturn(Collections.singleton("read_ds_0"));
updater.checkSQLStatement("foo", createSQLStatement("TEST"), createCurrentRuleConfiguration(), resource);
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
- public void assertCheckSQLStatementWithoutToBeAlteredLoadBalancers() throws RuleDefinitionViolationException {
+ public void assertCheckSQLStatementWithoutToBeAlteredLoadBalancers() throws DefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("INVALID_TYPE"), createCurrentRuleConfiguration(), mock(ShardingSphereResource.class));
}
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 77450c6..3f468d4 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
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.RequiredResourceMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.ResourceNotExistedException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
@@ -42,20 +42,20 @@ public final class CreateReadwriteSplittingRuleStatementUpdaterTest {
private final CreateReadwriteSplittingRuleStatementUpdater updater = new CreateReadwriteSplittingRuleStatementUpdater();
- @Test(expected = RuleDuplicatedException.class)
- public void assertCheckSQLStatementWithDuplicateRuleNames() throws RuleDefinitionViolationException {
+ @Test(expected = DuplicateRuleException.class)
+ public void assertCheckSQLStatementWithDuplicateRuleNames() throws DefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("TEST"), getCurrentRuleConfig(), mock(ShardingSphereResource.class));
}
- @Test(expected = ResourceNotExistedException.class)
- public void assertCheckSQLStatementWithoutExistedResources() throws RuleDefinitionViolationException {
+ @Test(expected = RequiredResourceMissedException.class)
+ public void assertCheckSQLStatementWithoutExistedResources() throws DefinitionViolationException {
ShardingSphereResource resource = mock(ShardingSphereResource.class);
when(resource.getNotExistedResources(any())).thenReturn(Arrays.asList("read_ds_0", "read_ds_1"));
updater.checkSQLStatement("foo", createSQLStatement("TEST"), null, resource);
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
- public void assertCheckSQLStatementWithoutToBeCreatedLoadBalancers() throws RuleDefinitionViolationException {
+ public void assertCheckSQLStatementWithoutToBeCreatedLoadBalancers() throws DefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("INVALID_TYPE"), null, mock(ShardingSphereResource.class));
}
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 5336504..a778659 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
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
@@ -38,12 +38,12 @@ public final class DropReadwriteSplittingRuleStatementUpdaterTest {
private final DropReadwriteSplittingRuleStatementUpdater updater = new DropReadwriteSplittingRuleStatementUpdater();
- @Test(expected = CurrentRuleNotExistedException.class)
+ @Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement(), null, mock(ShardingSphereResource.class));
}
- @Test(expected = CurrentRuleNotExistedException.class)
+ @Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithoutToBeDroppedRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement(), new ReadwriteSplittingRuleConfiguration(Collections.emptyList(), Collections.emptyMap()), mock(ShardingSphereResource.class));
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingBindingTableRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingBindingTableRuleStatementUpdater.java
index 82af751..8efca49 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingBindingTableRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingBindingTableRuleStatementUpdater.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.infra.distsql.update.RDLAlterUpdater;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -46,9 +46,9 @@ public final class AlterShardingBindingTableRuleStatementUpdater implements RDLA
checkToBeAlteredDuplicateBindingTables(schemaName, sqlStatement);
}
- private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
if (null == currentRuleConfig) {
- throw new CurrentRuleNotExistedException("Sharding", schemaName);
+ throw new RequiredRuleMissedException("Sharding", schemaName);
}
}
@@ -68,11 +68,11 @@ public final class AlterShardingBindingTableRuleStatementUpdater implements RDLA
return result;
}
- private void checkToBeAlteredDuplicateBindingTables(final String schemaName, final AlterShardingBindingTableRulesStatement sqlStatement) throws RuleDuplicatedException {
+ private void checkToBeAlteredDuplicateBindingTables(final String schemaName, final AlterShardingBindingTableRulesStatement sqlStatement) throws DuplicateRuleException {
Collection<String> toBeAlteredBindingTables = new HashSet<>();
Collection<String> duplicateBindingTables = sqlStatement.getBindingTables().stream().filter(each -> !toBeAlteredBindingTables.add(each)).collect(Collectors.toSet());
if (!duplicateBindingTables.isEmpty()) {
- throw new RuleDuplicatedException("binding", schemaName, duplicateBindingTables);
+ throw new DuplicateRuleException("binding", schemaName, duplicateBindingTables);
}
}
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 14e3a42..0f6feb5 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
@@ -19,11 +19,11 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import com.google.common.base.Preconditions;
import org.apache.shardingsphere.infra.distsql.update.RDLAlterUpdater;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.ResourceNotExistedException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
@@ -57,7 +57,7 @@ public final class AlterShardingTableRuleStatementUpdater implements RDLAlterUpd
@Override
public void checkSQLStatement(final String schemaName, final AlterShardingTableRuleStatement sqlStatement,
- final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+ final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws DefinitionViolationException {
checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
checkToBeAlteredResources(schemaName, sqlStatement, resource);
checkToBeAlteredShardingTables(schemaName, sqlStatement, currentRuleConfig);
@@ -66,9 +66,9 @@ public final class AlterShardingTableRuleStatementUpdater implements RDLAlterUpd
checkToBeAlteredDuplicateShardingTables(schemaName, sqlStatement);
}
- private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
if (null == currentRuleConfig) {
- throw new CurrentRuleNotExistedException("Sharding", schemaName);
+ throw new RequiredRuleMissedException("Sharding", schemaName);
}
}
@@ -76,10 +76,10 @@ public final class AlterShardingTableRuleStatementUpdater implements RDLAlterUpd
return sqlStatement.getRules().stream().map(TableRuleSegment::getLogicTable).collect(Collectors.toList());
}
- private void checkToBeAlteredResources(final String schemaName, final AlterShardingTableRuleStatement sqlStatement, final ShardingSphereResource resource) throws ResourceNotExistedException {
+ private void checkToBeAlteredResources(final String schemaName, final AlterShardingTableRuleStatement sqlStatement, final ShardingSphereResource resource) throws RequiredResourceMissedException {
Collection<String> notExistResources = resource.getNotExistedResources(getToBeAlteredResources(sqlStatement));
if (!notExistResources.isEmpty()) {
- throw new ResourceNotExistedException(schemaName, notExistResources);
+ throw new RequiredResourceMissedException(schemaName, notExistResources);
}
}
@@ -90,11 +90,11 @@ public final class AlterShardingTableRuleStatementUpdater implements RDLAlterUpd
}
private void checkToBeAlteredShardingTables(final String schemaName, final AlterShardingTableRuleStatement sqlStatement,
- final ShardingRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ final ShardingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
Collection<String> currentShardingTables = getCurrentShardingTables(currentRuleConfig);
Collection<String> notExistedShardingTables = getToBeAlteredTableNames(sqlStatement).stream().filter(each -> !currentShardingTables.contains(each)).collect(Collectors.toList());
if (!notExistedShardingTables.isEmpty()) {
- throw new CurrentRuleNotExistedException("Sharding", schemaName, notExistedShardingTables);
+ throw new RequiredRuleMissedException("Sharding", schemaName, notExistedShardingTables);
}
}
@@ -125,10 +125,10 @@ public final class AlterShardingTableRuleStatementUpdater implements RDLAlterUpd
return sqlStatement.getRules().stream().filter(each -> null != each.getKeyGenerateStrategy()).map(each -> each.getKeyGenerateStrategy().getName()).collect(Collectors.toSet());
}
- private void checkToBeAlteredDuplicateShardingTables(final String schemaName, final AlterShardingTableRuleStatement sqlStatement) throws RuleDuplicatedException {
+ private void checkToBeAlteredDuplicateShardingTables(final String schemaName, final AlterShardingTableRuleStatement sqlStatement) throws DuplicateRuleException {
Collection<String> duplicateTables = getDuplicateTables(sqlStatement);
if (!duplicateTables.isEmpty()) {
- throw new RuleDuplicatedException("sharding", schemaName, duplicateTables);
+ throw new DuplicateRuleException("sharding", schemaName, duplicateTables);
}
}
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 dc47a53..3aef073 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.update.RDLCreateUpdater;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -75,12 +75,12 @@ public final class CreateShardingBindingTableRuleStatementUpdater implements RDL
}
private void checkToBeCreatedDuplicateBindingTables(final String schemaName,
- final CreateShardingBindingTableRulesStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) throws RuleDuplicatedException {
+ final CreateShardingBindingTableRulesStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) throws DuplicateRuleException {
Collection<String> toBeCreatedBindingTables = new HashSet<>();
Collection<String> duplicateBindingTables = sqlStatement.getBindingTables().stream().filter(each -> !toBeCreatedBindingTables.add(each)).collect(Collectors.toSet());
duplicateBindingTables.addAll(getCurrentBindingTables(currentRuleConfig).stream().filter(each -> !toBeCreatedBindingTables.add(each)).collect(Collectors.toSet()));
if (!duplicateBindingTables.isEmpty()) {
- throw new RuleDuplicatedException("binding", schemaName, duplicateBindingTables);
+ throw new DuplicateRuleException("binding", schemaName, duplicateBindingTables);
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableRuleStatementUpdater.java
index e8b2943..5c6804c 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableRuleStatementUpdater.java
@@ -18,10 +18,10 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.infra.distsql.update.RDLCreateUpdater;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.RequiredResourceMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.ResourceNotExistedException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
@@ -57,17 +57,17 @@ public final class CreateShardingTableRuleStatementUpdater implements RDLCreateU
@Override
public void checkSQLStatement(final String schemaName, final CreateShardingTableRuleStatement sqlStatement,
- final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+ final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws DefinitionViolationException {
checkToBeCreatedResource(schemaName, sqlStatement, resource);
checkDuplicateTables(schemaName, sqlStatement, currentRuleConfig);
checkToBeCreatedShardingAlgorithms(sqlStatement);
checkToBeCreatedKeyGenerators(sqlStatement);
}
- private void checkToBeCreatedResource(final String schemaName, final CreateShardingTableRuleStatement sqlStatement, final ShardingSphereResource resource) throws ResourceNotExistedException {
+ private void checkToBeCreatedResource(final String schemaName, final CreateShardingTableRuleStatement sqlStatement, final ShardingSphereResource resource) throws RequiredResourceMissedException {
Collection<String> notExistedResources = resource.getNotExistedResources(getToBeCreatedResources(sqlStatement));
if (!notExistedResources.isEmpty()) {
- throw new ResourceNotExistedException(schemaName, notExistedResources);
+ throw new RequiredResourceMissedException(schemaName, notExistedResources);
}
}
@@ -77,13 +77,13 @@ public final class CreateShardingTableRuleStatementUpdater implements RDLCreateU
return result;
}
- private void checkDuplicateTables(final String schemaName, final CreateShardingTableRuleStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) throws RuleDuplicatedException {
+ private void checkDuplicateTables(final String schemaName, final CreateShardingTableRuleStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) throws DuplicateRuleException {
Collection<String> shardingTableNames = null == currentRuleConfig ? Collections.emptyList() : getShardingTables(currentRuleConfig);
Set<String> duplicateTableNames = sqlStatement.getRules().stream().collect(Collectors.toMap(TableRuleSegment::getLogicTable, each -> 1, Integer::sum))
.entrySet().stream().filter(entry -> entry.getValue() > 1).map(Entry::getKey).collect(Collectors.toSet());
duplicateTableNames.addAll(sqlStatement.getRules().stream().map(TableRuleSegment::getLogicTable).filter(shardingTableNames::contains).collect(Collectors.toSet()));
if (!duplicateTableNames.isEmpty()) {
- throw new RuleDuplicatedException("sharding", schemaName, duplicateTableNames);
+ throw new DuplicateRuleException("sharding", schemaName, duplicateTableNames);
}
}
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 99e781f..a5f8603 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
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import com.google.common.base.Splitter;
import org.apache.shardingsphere.infra.distsql.update.RDLDropUpdater;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -47,9 +47,9 @@ public final class DropShardingTableRuleStatementUpdater implements RDLDropUpdat
checkBindingTables(sqlStatement, currentRuleConfig);
}
- private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws CurrentRuleNotExistedException {
+ private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
if (null == currentRuleConfig) {
- throw new CurrentRuleNotExistedException("Sharding", schemaName);
+ throw new RequiredRuleMissedException("Sharding", schemaName);
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingBindingTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingBindingTableRuleStatementUpdaterTest.java
index 6921886..0ef51f5 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingBindingTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingBindingTableRuleStatementUpdaterTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.sharding.distsql.update;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
@@ -37,12 +37,12 @@ public final class AlterShardingBindingTableRuleStatementUpdaterTest {
private final AlterShardingBindingTableRuleStatementUpdater updater = new AlterShardingBindingTableRuleStatementUpdater();
- @Test(expected = CurrentRuleNotExistedException.class)
+ @Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement(), null, mock(ShardingSphereResource.class));
}
- @Test(expected = RuleDuplicatedException.class)
+ @Test(expected = DuplicateRuleException.class)
public void assertCheckSQLStatementWithDuplicateTables() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", createDuplicatedSQLStatement(), createCurrentRuleConfiguration(), mock(ShardingSphereResource.class));
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
index a9b6433..8972329 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
@@ -18,10 +18,10 @@
package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -42,23 +42,23 @@ public final class AlterShardingTableRuleStatementUpdaterTest {
private final AlterShardingTableRuleStatementUpdater updater = new AlterShardingTableRuleStatementUpdater();
- @Test(expected = CurrentRuleNotExistedException.class)
- public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
+ @Test(expected = RequiredRuleMissedException.class)
+ public void assertCheckSQLStatementWithoutCurrentRule() throws DefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("t_order", "STANDARD_TEST"), null, mock(ShardingSphereResource.class));
}
- @Test(expected = RuleDuplicatedException.class)
- public void assertCheckSQLStatementWithDuplicateTables() throws RuleDefinitionViolationException {
+ @Test(expected = DuplicateRuleException.class)
+ public void assertCheckSQLStatementWithDuplicateTables() throws DefinitionViolationException {
updater.checkSQLStatement("foo", createDuplicatedSQLStatement(), createCurrentRuleConfiguration(), mock(ShardingSphereResource.class));
}
- @Test(expected = CurrentRuleNotExistedException.class)
- public void assertCheckSQLStatementWithoutExistTable() throws RuleDefinitionViolationException {
+ @Test(expected = RequiredRuleMissedException.class)
+ public void assertCheckSQLStatementWithoutExistTable() throws DefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("invalid_table", "STANDARD_TEST"), createCurrentRuleConfiguration(), mock(ShardingSphereResource.class));
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
- public void assertCheckSQLStatementWithoutToBeAlteredShardingAlgorithms() throws RuleDefinitionViolationException {
+ public void assertCheckSQLStatementWithoutToBeAlteredShardingAlgorithms() throws DefinitionViolationException {
updater.checkSQLStatement("foo", createSQLStatement("t_order", "INVALID_TYPE"), createCurrentRuleConfiguration(), mock(ShardingSphereResource.class));
}
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 46a766e..930c267 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
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
@@ -41,7 +41,7 @@ public final class CreateShardingBindingTableRuleStatementUpdaterTest {
updater.checkSQLStatement("foo", createSQLStatement(), new ShardingRuleConfiguration(), mock(ShardingSphereResource.class));
}
- @Test(expected = RuleDuplicatedException.class)
+ @Test(expected = DuplicateRuleException.class)
public void assertCheckSQLStatementWithDuplicateTables() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", createDuplicatedSQLStatement(), getCurrentRuleConfig(), mock(ShardingSphereResource.class));
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
index f18c5f6..eae1ee4 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.sharding.distsql.update;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
import org.apache.shardingsphere.infra.exception.rule.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDuplicatedException;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.sharding.distsql.handler.update.CreateShardingTableRuleStatementUpdater;
import org.apache.shardingsphere.sharding.distsql.parser.segment.TableRuleSegment;
@@ -37,14 +37,14 @@ public final class CreateShardingTableRuleStatementUpdaterTest {
private final CreateShardingTableRuleStatementUpdater updater = new CreateShardingTableRuleStatementUpdater();
- @Test(expected = RuleDuplicatedException.class)
- public void assertExecuteWithDuplicateTables() throws RuleDefinitionViolationException {
+ @Test(expected = DuplicateRuleException.class)
+ public void assertExecuteWithDuplicateTables() throws DefinitionViolationException {
TableRuleSegment ruleSegment = new TableRuleSegment("t_order", Collections.emptyList(), null, null, null, null);
updater.checkSQLStatement("foo", createSQLStatement(ruleSegment, ruleSegment), null, mock(ShardingSphereResource.class));
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
- public void assertCheckSQLStatementWithoutToBeCreatedShardingAlgorithms() throws RuleDefinitionViolationException {
+ public void assertCheckSQLStatementWithoutToBeCreatedShardingAlgorithms() throws DefinitionViolationException {
TableRuleSegment ruleSegment = new TableRuleSegment("t_order", Collections.emptyList(), null, new AlgorithmSegment("INVALID_TYPE", new Properties()), null, null);
updater.checkSQLStatement("foo", createSQLStatement(ruleSegment), null, mock(ShardingSphereResource.class));
}
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 4d9b82c..44e7d18 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.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -46,7 +46,7 @@ public final class DropShardingTableRuleStatementUpdaterTest {
private final DropShardingTableRuleStatementUpdater updater = new DropShardingTableRuleStatementUpdater();
- @Test(expected = CurrentRuleNotExistedException.class)
+ @Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
updater.checkSQLStatement("foo", new DropShardingTableRuleStatement(Collections.emptyList()), null, mock(ShardingSphereResource.class));
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RDLUpdater.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RDLUpdater.java
index fc9a64c..8861f8a 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RDLUpdater.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RDLUpdater.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.infra.distsql.update;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.spi.typed.TypedSPI;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -38,9 +38,9 @@ public interface RDLUpdater<T extends SQLStatement, R extends RuleConfiguration>
* @param sqlStatement SQL statement
* @param currentRuleConfig current rule configuration
* @param resource ShardingSphere resource
- * @throws RuleDefinitionViolationException rule definition violation exception
+ * @throws DefinitionViolationException definition violation exception
*/
- void checkSQLStatement(String schemaName, T sqlStatement, R currentRuleConfig, ShardingSphereResource resource) throws RuleDefinitionViolationException;
+ void checkSQLStatement(String schemaName, T sqlStatement, R currentRuleConfig, ShardingSphereResource resource) throws DefinitionViolationException;
/**
* Get rule configuration class.
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RuleDefinitionViolationException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/DefinitionViolationException.java
similarity index 73%
copy from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RuleDefinitionViolationException.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/DefinitionViolationException.java
index 8276dfd..8256ae0 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RuleDefinitionViolationException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/DefinitionViolationException.java
@@ -15,18 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.exception.rule;
+package org.apache.shardingsphere.infra.exception;
import java.sql.SQLException;
/**
- * Rule definition violation exception.
+ * Definition violation exception.
*/
-public abstract class RuleDefinitionViolationException extends SQLException {
+public abstract class DefinitionViolationException extends SQLException {
- private static final long serialVersionUID = 1090914641996552474L;
+ private static final long serialVersionUID = -6464411607608071400L;
- public RuleDefinitionViolationException(final int errorCode, final String reason) {
+ public DefinitionViolationException(final int errorCode, final String reason) {
super(reason, "C" + errorCode, errorCode);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/DuplicateResourceException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/DuplicateResourceException.java
similarity index 88%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/DuplicateResourceException.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/DuplicateResourceException.java
index a19ece8..8f6902b 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/DuplicateResourceException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/DuplicateResourceException.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.exception.rule;
+package org.apache.shardingsphere.infra.exception.resource;
import java.util.Collection;
/**
* Duplicate resource exception.
*/
-public final class DuplicateResourceException extends RuleDefinitionViolationException {
+public final class DuplicateResourceException extends ResourceDefinitionViolationException {
private static final long serialVersionUID = 2103793827572264148L;
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/InvalidResourceException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/InvalidResourceException.java
similarity index 88%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/InvalidResourceException.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/InvalidResourceException.java
index dc4912f..90347a3 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/InvalidResourceException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/InvalidResourceException.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.exception.rule;
+package org.apache.shardingsphere.infra.exception.resource;
import java.util.Collection;
/**
* Invalid resource exception.
*/
-public final class InvalidResourceException extends RuleDefinitionViolationException {
+public final class InvalidResourceException extends ResourceDefinitionViolationException {
private static final long serialVersionUID = 7029641448948791509L;
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/ResourceNotExistedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/RequiredResourceMissedException.java
similarity index 77%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/ResourceNotExistedException.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/RequiredResourceMissedException.java
index 72ba342..1a33d4d 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/ResourceNotExistedException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/RequiredResourceMissedException.java
@@ -15,18 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.exception.rule;
+package org.apache.shardingsphere.infra.exception.resource;
import java.util.Collection;
/**
- * Resource not existed exception.
+ * Required resource missed exception.
*/
-public final class ResourceNotExistedException extends RuleDefinitionViolationException {
+public final class RequiredResourceMissedException extends ResourceDefinitionViolationException {
private static final long serialVersionUID = 1704331180489268L;
- public ResourceNotExistedException(final String schemaName, final Collection<String> resourceNames) {
+ public RequiredResourceMissedException(final String schemaName, final Collection<String> resourceNames) {
super(1102, String.format("Resources %s do not exist in schema %s.", resourceNames, schemaName));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/ResourceInUsedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/ResourceDefinitionViolationException.java
similarity index 63%
copy from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/ResourceInUsedException.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/ResourceDefinitionViolationException.java
index 150b1c7..8a68977 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/ResourceInUsedException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/ResourceDefinitionViolationException.java
@@ -15,18 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.exception.rule;
+package org.apache.shardingsphere.infra.exception.resource;
-import java.util.Collection;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
/**
- * Resource in used exception.
+ * Resource definition violation exception.
*/
-public final class ResourceInUsedException extends RuleDefinitionViolationException {
+public abstract class ResourceDefinitionViolationException extends DefinitionViolationException {
- private static final long serialVersionUID = -3427324685070457375L;
+ private static final long serialVersionUID = -2686784350802985974L;
- public ResourceInUsedException(final Collection<String> resourceNames) {
- super(1101, String.format("Resources %s in the rule are still in used.", resourceNames));
+ public ResourceDefinitionViolationException(final int errorCode, final String reason) {
+ super(errorCode, reason);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/ResourceInUsedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/ResourceInUsedException.java
similarity index 88%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/ResourceInUsedException.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/ResourceInUsedException.java
index 150b1c7..b67f5e1 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/ResourceInUsedException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/resource/ResourceInUsedException.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.exception.rule;
+package org.apache.shardingsphere.infra.exception.resource;
import java.util.Collection;
/**
* Resource in used exception.
*/
-public final class ResourceInUsedException extends RuleDefinitionViolationException {
+public final class ResourceInUsedException extends ResourceDefinitionViolationException {
private static final long serialVersionUID = -3427324685070457375L;
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RuleDuplicatedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/DuplicateRuleException.java
similarity index 82%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RuleDuplicatedException.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/DuplicateRuleException.java
index bfde662..f320bb4 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RuleDuplicatedException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/DuplicateRuleException.java
@@ -20,13 +20,13 @@ package org.apache.shardingsphere.infra.exception.rule;
import java.util.Collection;
/**
- * Rule duplicated exception.
+ * Duplicate rule exception.
*/
-public final class RuleDuplicatedException extends RuleDefinitionViolationException {
+public final class DuplicateRuleException extends RuleDefinitionViolationException {
private static final long serialVersionUID = -1738699538105858939L;
- public RuleDuplicatedException(final String ruleType, final String schemaName, final Collection<String> ruleNames) {
+ public DuplicateRuleException(final String ruleType, final String schemaName, final Collection<String> ruleNames) {
super(1105, String.format("Duplicate %s rule names `%s` in schema `%s`", ruleType, ruleNames, schemaName));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/CurrentRuleNotExistedException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RequiredRuleMissedException.java
similarity index 77%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/CurrentRuleNotExistedException.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RequiredRuleMissedException.java
index 68cf49c..91c80e3 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/CurrentRuleNotExistedException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RequiredRuleMissedException.java
@@ -20,17 +20,17 @@ package org.apache.shardingsphere.infra.exception.rule;
import java.util.Collection;
/**
- * Current rule not existed exception.
+ * Required rule missed exception.
*/
-public final class CurrentRuleNotExistedException extends RuleDefinitionViolationException {
+public final class RequiredRuleMissedException extends RuleDefinitionViolationException {
private static final long serialVersionUID = -8464574460917965546L;
- public CurrentRuleNotExistedException(final String ruleType, final String schemaName) {
+ public RequiredRuleMissedException(final String ruleType, final String schemaName) {
super(1106, String.format("%s rule does not exist in schema `%s`.", ruleType, schemaName));
}
- public CurrentRuleNotExistedException(final String ruleType, final String schemaName, final Collection<String> ruleNames) {
+ public RequiredRuleMissedException(final String ruleType, final String schemaName, final Collection<String> ruleNames) {
super(1106, String.format("%s rules `%s` do not exist in schema `%s`.", ruleType, ruleNames, schemaName));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RuleDefinitionViolationException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RuleDefinitionViolationException.java
index 8276dfd..58c45bd 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RuleDefinitionViolationException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/rule/RuleDefinitionViolationException.java
@@ -17,16 +17,16 @@
package org.apache.shardingsphere.infra.exception.rule;
-import java.sql.SQLException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
/**
* Rule definition violation exception.
*/
-public abstract class RuleDefinitionViolationException extends SQLException {
+public abstract class RuleDefinitionViolationException extends DefinitionViolationException {
private static final long serialVersionUID = 1090914641996552474L;
public RuleDefinitionViolationException(final int errorCode, final String reason) {
- super(reason, "C" + errorCode, errorCode);
+ super(errorCode, reason);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandler.java
index 6053324..1ede5c6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandler.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.infra.distsql.update.RDLCreateUpdater;
import org.apache.shardingsphere.infra.distsql.update.RDLDropUpdater;
import org.apache.shardingsphere.infra.distsql.update.RDLUpdater;
import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
@@ -54,7 +55,7 @@ public final class RDLBackendHandler<T extends SQLStatement> extends SchemaRequi
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
- protected ResponseHeader execute(final String schemaName, final T sqlStatement) throws RuleDefinitionViolationException {
+ protected ResponseHeader execute(final String schemaName, final T sqlStatement) throws DefinitionViolationException {
RDLUpdater rdlUpdater = TypedSPIRegistry.getRegisteredService(RDLUpdater.class, sqlStatement.getClass().getCanonicalName(), new Properties());
Class<? extends RuleConfiguration> ruleConfigClass = rdlUpdater.getRuleConfigurationClass();
RuleConfiguration currentRuleConfig = findCurrentRuleConfiguration(schemaName, ruleConfigClass).orElse(null);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AddResourceBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AddResourceBackendHandler.java
index 5500d7c..363fea5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AddResourceBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AddResourceBackendHandler.java
@@ -24,9 +24,9 @@ import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration
import org.apache.shardingsphere.infra.config.datasource.DataSourceValidator;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
-import org.apache.shardingsphere.infra.exception.rule.DuplicateResourceException;
-import org.apache.shardingsphere.infra.exception.rule.InvalidResourceException;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.DuplicateResourceException;
+import org.apache.shardingsphere.infra.exception.resource.InvalidResourceException;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -60,7 +60,7 @@ public final class AddResourceBackendHandler extends SchemaRequiredBackendHandle
}
@Override
- public ResponseHeader execute(final String schemaName, final AddResourceStatement sqlStatement) throws RuleDefinitionViolationException {
+ public ResponseHeader execute(final String schemaName, final AddResourceStatement sqlStatement) throws DefinitionViolationException {
check(schemaName, sqlStatement);
Map<String, DataSourceConfiguration> dataSourceConfigMap = DataSourceParameterConverter.getDataSourceConfigurationMap(
DataSourceParameterConverter.getDataSourceParameterMapFromYamlConfiguration(AddResourcesStatementConverter.convert(databaseType, sqlStatement)));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropResourceBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropResourceBackendHandler.java
index 93c3c56..46fa3ca 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropResourceBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropResourceBackendHandler.java
@@ -21,14 +21,14 @@ import org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropResourceS
import org.apache.shardingsphere.governance.core.registry.config.event.datasource.DataSourceDroppedSQLNotificationEvent;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.ResourceDefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.resource.ResourceInUsedException;
+import org.apache.shardingsphere.infra.exception.resource.RequiredResourceMissedException;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.type.DataNodeContainedRule;
import org.apache.shardingsphere.infra.rule.type.DataSourceContainedRule;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.infra.exception.rule.ResourceInUsedException;
-import org.apache.shardingsphere.infra.exception.rule.ResourceNotExistedException;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.text.SchemaRequiredBackendHandler;
@@ -51,7 +51,7 @@ public final class DropResourceBackendHandler extends SchemaRequiredBackendHandl
}
@Override
- public ResponseHeader execute(final String schemaName, final DropResourceStatement sqlStatement) throws RuleDefinitionViolationException {
+ public ResponseHeader execute(final String schemaName, final DropResourceStatement sqlStatement) throws ResourceDefinitionViolationException {
Collection<String> toBeDroppedResourceNames = sqlStatement.getNames();
check(schemaName, toBeDroppedResourceNames);
drop(schemaName, toBeDroppedResourceNames);
@@ -59,16 +59,16 @@ public final class DropResourceBackendHandler extends SchemaRequiredBackendHandl
return new UpdateResponseHeader(sqlStatement);
}
- private void check(final String schemaName, final Collection<String> toBeDroppedResourceNames) throws ResourceNotExistedException, ResourceInUsedException {
+ private void check(final String schemaName, final Collection<String> toBeDroppedResourceNames) throws RequiredResourceMissedException, ResourceInUsedException {
checkResourceNameExisted(schemaName, toBeDroppedResourceNames);
checkResourceNameNotInUse(schemaName, toBeDroppedResourceNames);
}
- private void checkResourceNameExisted(final String schemaName, final Collection<String> resourceNames) throws ResourceNotExistedException {
+ private void checkResourceNameExisted(final String schemaName, final Collection<String> resourceNames) throws RequiredResourceMissedException {
Map<String, DataSource> resources = ProxyContext.getInstance().getMetaData(schemaName).getResource().getDataSources();
Collection<String> notExistedResourceNames = resourceNames.stream().filter(each -> !resources.containsKey(each)).collect(Collectors.toList());
if (!notExistedResourceNames.isEmpty()) {
- throw new ResourceNotExistedException(schemaName, notExistedResourceNames);
+ throw new RequiredResourceMissedException(schemaName, notExistedResourceNames);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java
index fb60a73..f18ae11 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import org.apache.shardingsphere.infra.exception.rule.CurrentRuleNotExistedException;
+import org.apache.shardingsphere.infra.exception.rule.RequiredRuleMissedException;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
@@ -200,7 +200,7 @@ public final class DistSQLBackendHandlerFactoryTest {
assertThat(response, instanceOf(UpdateResponseHeader.class));
}
- @Test(expected = CurrentRuleNotExistedException.class)
+ @Test(expected = RequiredRuleMissedException.class)
public void assertExecuteDropReadwriteSplittingRuleContext() throws SQLException {
BackendConnection connection = mock(BackendConnection.class);
when(connection.getSchemaName()).thenReturn("schema");
@@ -228,7 +228,7 @@ public final class DistSQLBackendHandlerFactoryTest {
assertThat(response, instanceOf(UpdateResponseHeader.class));
}
- @Test(expected = CurrentRuleNotExistedException.class)
+ @Test(expected = RequiredRuleMissedException.class)
public void assertExecuteAlterReadwriteSplittingRuleContext() throws SQLException {
BackendConnection connection = mock(BackendConnection.class);
when(connection.getSchemaName()).thenReturn("schema");
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AddResourceBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AddResourceBackendHandlerTest.java
index 17d53e1..eece1a9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AddResourceBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AddResourceBackendHandlerTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration
import org.apache.shardingsphere.infra.config.datasource.DataSourceValidator;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import org.apache.shardingsphere.infra.exception.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.exception.DefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
@@ -82,18 +82,18 @@ public final class AddResourceBackendHandlerTest {
}
@Test
- public void assertExecute() throws RuleDefinitionViolationException {
+ public void assertExecute() throws DefinitionViolationException {
ProxyContext.getInstance().init(metaDataContexts, transactionContexts);
when(metaDataContexts.getAllSchemaNames()).thenReturn(Collections.singleton("test"));
when(metaDataContexts.getMetaData(eq("test"))).thenReturn(shardingSphereMetaData);
when(shardingSphereMetaData.getResource()).thenReturn(shardingSphereResource);
when(shardingSphereResource.getDataSources()).thenReturn(new HashMap<>());
when(dataSourceValidator.validate(any(DataSourceConfiguration.class))).thenReturn(true);
- ResponseHeader responseHeader = addResourceBackendHandler.execute("test", buildAddResourceStatement());
+ ResponseHeader responseHeader = addResourceBackendHandler.execute("test", createAddResourceStatement());
assertTrue(responseHeader instanceof UpdateResponseHeader);
}
- private AddResourceStatement buildAddResourceStatement() {
+ private AddResourceStatement createAddResourceStatement() {
return new AddResourceStatement(Collections.singleton(new DataSourceSegment("ds_0", "127.0.0.1", "test0", "3306", "root", "", new Properties())));
}
}