This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 a1a547ddac3 Rename resource to storage unit (#23125)
a1a547ddac3 is described below
commit a1a547ddac3f8b749295e807de594928a1f574f0
Author: Chen Jiahao <[email protected]>
AuthorDate: Wed Dec 28 13:53:30 2022 +0800
Rename resource to storage unit (#23125)
---
.../DuplicateStorageUnitException.java} | 10 +++++-----
.../EmptyStorageUnitException.java} | 8 ++++----
.../InvalidStorageUnitsException.java} | 8 ++++----
.../MissingRequiredStorageUnitsException.java} | 10 +++++-----
.../StorageUnitDefinitionViolationException.java} | 8 ++++----
.../StorageUnitInUsedException.java} | 10 +++++-----
.../validate/DataSourcePropertiesValidateHandler.java | 4 ++--
.../update/AlterDatabaseDiscoveryRuleStatementUpdater.java | 4 ++--
.../CreateDatabaseDiscoveryRuleStatementUpdater.java | 4 ++--
.../AlterDatabaseDiscoveryRuleStatementUpdaterTest.java | 4 ++--
.../CreateDatabaseDiscoveryRuleStatementUpdaterTest.java | 4 ++--
.../handler/update/CreateEncryptRuleStatementUpdater.java | 4 ++--
.../checker/ReadwriteSplittingRuleStatementChecker.java | 6 +++---
.../AlterReadwriteSplittingRuleStatementUpdaterTest.java | 6 +++---
.../CreateReadwriteSplittingRuleStatementUpdaterTest.java | 6 +++---
.../handler/checker/ShadowRuleStatementChecker.java | 4 ++--
.../update/AlterShadowRuleStatementUpdaterTest.java | 4 ++--
.../update/CreateShadowRuleStatementUpdaterTest.java | 4 ++--
.../handler/checker/ShardingTableRuleStatementChecker.java | 4 ++--
.../distsql/checker/ShardingRuleStatementCheckerTest.java | 4 ++--
.../infra/instance/mode/ModeContextManager.java | 1 -
.../infra/context/refresher/MetaDataRefresher.java | 2 +-
.../type/table/AlterTableStatementSchemaRefresher.java | 4 ++--
.../type/table/RenameTableStatementSchemaRefresher.java | 4 ++--
.../DatabaseDiscoveryRuleConfigurationImportChecker.java | 4 ++--
.../ReadwriteSplittingRuleConfigurationImportChecker.java | 6 +++---
.../checker/ShardingRuleConfigurationImportChecker.java | 4 ++--
...eadwriteSplittingStorageUnitStatusStatementHandler.java | 4 ++--
.../ral/updatable/ImportDatabaseConfigurationHandler.java | 4 ++--
.../distsql/ral/updatable/RefreshTableMetaDataHandler.java | 8 ++++----
.../rdl/resource/AlterStorageUnitBackendHandler.java | 14 +++++++-------
.../rdl/resource/RegisterStorageUnitBackendHandler.java | 10 +++++-----
.../rdl/resource/UnregisterStorageUnitBackendHandler.java | 14 +++++++-------
.../SetDefaultSingleTableStorageUnitStatementUpdater.java | 4 ++--
.../ral/updatable/RefreshTableMetaDataHandlerTest.java | 8 ++++----
.../rdl/resource/AlterStorageUnitBackendHandlerTest.java | 12 ++++++------
.../resource/RegisterStorageUnitBackendHandlerTest.java | 10 +++++-----
.../resource/UnregisterStorageUnitBackendHandlerTest.java | 10 +++++-----
.../rule/SetDefaultSingleTableStorageUnitUpdaterTest.java | 4 ++--
39 files changed, 121 insertions(+), 122 deletions(-)
diff --git
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/DuplicateResourceException.java
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/DuplicateStorageUnitException.java
similarity index 76%
rename from
distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/DuplicateResourceException.java
rename to
distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/DuplicateStorageUnitException.java
index 6f22ec27907..2a2766f7102 100644
---
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/DuplicateResourceException.java
+++
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/DuplicateStorageUnitException.java
@@ -15,20 +15,20 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.handler.exception.resource;
+package org.apache.shardingsphere.distsql.handler.exception.storageunit;
import
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
import java.util.Collection;
/**
- * Duplicate resource exception.
+ * Duplicate storage unit exception.
*/
-public final class DuplicateResourceException extends
ResourceDefinitionViolationException {
+public final class DuplicateStorageUnitException extends
StorageUnitDefinitionViolationException {
private static final long serialVersionUID = 2103793827572264148L;
- public DuplicateResourceException(final Collection<String> resourceNames) {
- super(XOpenSQLState.CHECK_OPTION_VIOLATION, 4, "Duplicate storage unit
names `%s`.", resourceNames);
+ public DuplicateStorageUnitException(final Collection<String>
storageUnitNames) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 4, "Duplicate storage unit
names `%s`.", storageUnitNames);
}
}
diff --git
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/EmptyResourceException.java
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/EmptyStorageUnitException.java
similarity index 80%
rename from
distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/EmptyResourceException.java
rename to
distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/EmptyStorageUnitException.java
index c13695fe0ca..f63607fe890 100644
---
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/EmptyResourceException.java
+++
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/EmptyStorageUnitException.java
@@ -15,18 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.handler.exception.resource;
+package org.apache.shardingsphere.distsql.handler.exception.storageunit;
import
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
/**
- * Empty resource exception.
+ * Empty storage unit exception.
*/
-public final class EmptyResourceException extends
ResourceDefinitionViolationException {
+public final class EmptyStorageUnitException extends
StorageUnitDefinitionViolationException {
private static final long serialVersionUID = 1704331180489268L;
- public EmptyResourceException(final String databaseName) {
+ public EmptyStorageUnitException(final String databaseName) {
super(XOpenSQLState.CHECK_OPTION_VIOLATION, 2, "There is no storage
unit in the database `%s`.", databaseName);
}
}
diff --git
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/InvalidResourcesException.java
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/InvalidStorageUnitsException.java
similarity index 80%
rename from
distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/InvalidResourcesException.java
rename to
distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/InvalidStorageUnitsException.java
index 45332a9935f..6f3edb90098 100644
---
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/InvalidResourcesException.java
+++
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/InvalidStorageUnitsException.java
@@ -15,20 +15,20 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.handler.exception.resource;
+package org.apache.shardingsphere.distsql.handler.exception.storageunit;
import
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
import java.util.Collection;
/**
- * Invalid resources exception.
+ * Invalid storage units exception.
*/
-public final class InvalidResourcesException extends
ResourceDefinitionViolationException {
+public final class InvalidStorageUnitsException extends
StorageUnitDefinitionViolationException {
private static final long serialVersionUID = 7029641448948791509L;
- public InvalidResourcesException(final Collection<String> errorMessages) {
+ public InvalidStorageUnitsException(final Collection<String>
errorMessages) {
super(XOpenSQLState.CHECK_OPTION_VIOLATION, 0, "Can not process
invalid storage units, error message is: %s", errorMessages);
}
}
diff --git
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/MissingRequiredResourcesException.java
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/MissingRequiredStorageUnitsException.java
similarity index 72%
rename from
distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/MissingRequiredResourcesException.java
rename to
distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/MissingRequiredStorageUnitsException.java
index 1eee11a37f1..a0e1cbe55de 100644
---
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/MissingRequiredResourcesException.java
+++
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/MissingRequiredStorageUnitsException.java
@@ -15,20 +15,20 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.handler.exception.resource;
+package org.apache.shardingsphere.distsql.handler.exception.storageunit;
import
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
import java.util.Collection;
/**
- * Missing required resources exception.
+ * Missing required storage units exception.
*/
-public final class MissingRequiredResourcesException extends
ResourceDefinitionViolationException {
+public final class MissingRequiredStorageUnitsException extends
StorageUnitDefinitionViolationException {
private static final long serialVersionUID = 1704331180489268L;
- public MissingRequiredResourcesException(final String databaseName, final
Collection<String> resourceNames) {
- super(XOpenSQLState.CHECK_OPTION_VIOLATION, 1, "Storage units `%s` do
not exist in database `%s`.", resourceNames, databaseName);
+ public MissingRequiredStorageUnitsException(final String databaseName,
final Collection<String> storageUnitNames) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 1, "Storage units `%s` do
not exist in database `%s`.", storageUnitNames, databaseName);
}
}
diff --git
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/ResourceDefinitionViolationException.java
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/StorageUnitDefinitionViolationException.java
similarity index 75%
rename from
distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/ResourceDefinitionViolationException.java
rename to
distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/StorageUnitDefinitionViolationException.java
index d008efe2361..c273cd3f122 100644
---
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/ResourceDefinitionViolationException.java
+++
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/StorageUnitDefinitionViolationException.java
@@ -15,19 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.handler.exception.resource;
+package org.apache.shardingsphere.distsql.handler.exception.storageunit;
import org.apache.shardingsphere.distsql.handler.exception.DistSQLException;
import
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.SQLState;
/**
- * Resource definition violation exception.
+ * Storage unit definition violation exception.
*/
-public abstract class ResourceDefinitionViolationException extends
DistSQLException {
+public abstract class StorageUnitDefinitionViolationException extends
DistSQLException {
private static final long serialVersionUID = -2686784350802985974L;
- public ResourceDefinitionViolationException(final SQLState sqlState, final
int errorCode, final String reason, final Object... messageArgs) {
+ public StorageUnitDefinitionViolationException(final SQLState sqlState,
final int errorCode, final String reason, final Object... messageArgs) {
super(sqlState, errorCode, reason, messageArgs);
}
}
diff --git
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/ResourceInUsedException.java
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/StorageUnitInUsedException.java
similarity index 70%
rename from
distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/ResourceInUsedException.java
rename to
distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/StorageUnitInUsedException.java
index f9d75d08529..17b39ea8e03 100644
---
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/resource/ResourceInUsedException.java
+++
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/storageunit/StorageUnitInUsedException.java
@@ -15,20 +15,20 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.handler.exception.resource;
+package org.apache.shardingsphere.distsql.handler.exception.storageunit;
import
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
import java.util.Collection;
/**
- * Resource in used exception.
+ * Storage unit in used exception.
*/
-public final class ResourceInUsedException extends
ResourceDefinitionViolationException {
+public final class StorageUnitInUsedException extends
StorageUnitDefinitionViolationException {
private static final long serialVersionUID = -3427324685070457375L;
- public ResourceInUsedException(final String resourceName, final
Collection<String> ruleTypes) {
- super(XOpenSQLState.CHECK_OPTION_VIOLATION, 3, "Resource `%s` is still
used by `%s`.", resourceName, ruleTypes);
+ public StorageUnitInUsedException(final String storageUnitName, final
Collection<String> ruleTypes) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 3, "Storage unit `%s` is
still used by `%s`.", storageUnitName, ruleTypes);
}
}
diff --git
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/validate/DataSourcePropertiesValidateHandler.java
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/validate/DataSourcePropertiesValidateHandler.java
index e9a678bc12d..1e6101c2783 100644
---
a/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/validate/DataSourcePropertiesValidateHandler.java
+++
b/distsql/handler/src/main/java/org/apache/shardingsphere/distsql/handler/validate/DataSourcePropertiesValidateHandler.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.distsql.handler.validate;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.InvalidResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException;
import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
import
org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesValidator;
@@ -37,7 +37,7 @@ public final class DataSourcePropertiesValidateHandler {
public void validate(final Map<String, DataSourceProperties>
dataSourcePropertiesMap) {
Collection<String> errorMessages = new
DataSourcePropertiesValidator().validate(dataSourcePropertiesMap);
if (!errorMessages.isEmpty()) {
- throw new InvalidResourcesException(errorMessages);
+ throw new InvalidStorageUnitsException(errorMessages);
}
}
}
diff --git
a/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdater.java
b/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdater.java
index 3289cb03687..1cb497ae2b3 100644
---
a/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdater.java
+++
b/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdater.java
@@ -26,7 +26,7 @@ import
org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDisc
import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.AlterDatabaseDiscoveryRuleStatement;
import
org.apache.shardingsphere.dbdiscovery.factory.DatabaseDiscoveryProviderAlgorithmFactory;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
@@ -75,7 +75,7 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdater
implements RuleDef
private void checkToBeAlteredResources(final String databaseName, final
AlterDatabaseDiscoveryRuleStatement sqlStatement, final
ShardingSphereResourceMetaData resourceMetaData) {
Collection<String> notExistedResources =
resourceMetaData.getNotExistedResources(getToBeAlteredResourceNames(sqlStatement));
- ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(),
() -> new MissingRequiredResourcesException(databaseName, notExistedResources));
+ ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(),
() -> new MissingRequiredStorageUnitsException(databaseName,
notExistedResources));
}
private Collection<String> getToBeAlteredResourceNames(final
AlterDatabaseDiscoveryRuleStatement sqlStatement) {
diff --git
a/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdater.java
b/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdater.java
index 3473c944deb..dcc0bcb169c 100644
---
a/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdater.java
+++
b/features/db-discovery/distsql/handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdater.java
@@ -24,7 +24,7 @@ import
org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.AbstractData
import
org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDiscoveryDefinitionSegment;
import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.CreateDatabaseDiscoveryRuleStatement;
import
org.apache.shardingsphere.dbdiscovery.factory.DatabaseDiscoveryProviderAlgorithmFactory;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
@@ -75,7 +75,7 @@ public final class
CreateDatabaseDiscoveryRuleStatementUpdater implements RuleDe
Collection<String> resources = new LinkedHashSet<>();
sqlStatement.getRules().forEach(each ->
resources.addAll(each.getDataSources()));
Collection<String> notExistResources =
resourceMetaData.getNotExistedResources(resources);
- ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), ()
-> new MissingRequiredResourcesException(databaseName, notExistResources));
+ ShardingSpherePreconditions.checkState(notExistResources.isEmpty(), ()
-> new MissingRequiredStorageUnitsException(databaseName, notExistResources));
}
private void checkDiscoverTypeAndHeartbeat(final String databaseName,
final CreateDatabaseDiscoveryRuleStatement sqlStatement, final
DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
diff --git
a/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
b/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
index d029ab88881..c6ff5cd9807 100644
---
a/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
+++
b/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
@@ -22,7 +22,7 @@ import
org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDa
import
org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDiscoveryDefinitionSegment;
import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.AlterDatabaseDiscoveryRuleStatement;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -77,7 +77,7 @@ public final class
AlterDatabaseDiscoveryRuleStatementUpdaterTest {
new
DatabaseDiscoveryRuleConfiguration(Collections.emptyList(),
Collections.emptyMap(), Collections.emptyMap()));
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertCheckSQLStatementWithoutExistedResources() {
when(resourceMetaData.getNotExistedResources(any())).thenReturn(Collections.singleton("ds0"));
Properties props = new Properties();
diff --git
a/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java
b/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java
index 6cc08955866..aaaaa6c2c2e 100644
---
a/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java
+++
b/features/db-discovery/distsql/handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java
@@ -22,7 +22,7 @@ import
org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDa
import
org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDiscoveryDefinitionSegment;
import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.CreateDatabaseDiscoveryRuleStatement;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -73,7 +73,7 @@ public final class
CreateDatabaseDiscoveryRuleStatementUpdaterTest {
new
DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceRuleConfig),
Collections.emptyMap(), Collections.emptyMap()));
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertCheckSQLStatementWithoutExistedResources() {
when(resourceMetaData.getNotExistedResources(any())).thenReturn(Collections.singleton("ds_read_0"));
Properties props = new Properties();
diff --git
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdater.java
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdater.java
index c3524239be2..bfd5809db67 100644
---
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdater.java
+++
b/features/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.EncryptColumnSeg
import
org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegment;
import
org.apache.shardingsphere.encrypt.distsql.parser.statement.CreateEncryptRuleStatement;
import org.apache.shardingsphere.encrypt.factory.EncryptAlgorithmFactory;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.EmptyResourceException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.EmptyStorageUnitException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
@@ -76,7 +76,7 @@ public final class CreateEncryptRuleStatementUpdater
implements RuleDefinitionCr
}
private void checkDataSources(final ShardingSphereDatabase database) {
-
ShardingSpherePreconditions.checkState(!database.getResourceMetaData().getDataSources().isEmpty(),
() -> new EmptyResourceException(database.getName()));
+
ShardingSpherePreconditions.checkState(!database.getResourceMetaData().getDataSources().isEmpty(),
() -> new EmptyStorageUnitException(database.getName()));
}
@Override
diff --git
a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/checker/ReadwriteSplittingRuleStatementChecker.java
b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/checker/ReadwriteSplittingRuleStatementChecker.java
index 6b57e3dac9f..83ef736316c 100644
---
a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/checker/ReadwriteSplittingRuleStatementChecker.java
+++
b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/checker/ReadwriteSplittingRuleStatementChecker.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.readwritesplitting.distsql.handler.checker;
import com.google.common.base.Strings;
import
org.apache.shardingsphere.infra.rule.identifier.type.exportable.constant.ExportableConstants;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
@@ -148,10 +148,10 @@ public final class ReadwriteSplittingRuleStatementChecker
{
}
});
Collection<String> notExistedDataSources =
database.getResourceMetaData().getNotExistedResources(requiredDataSources);
-
ShardingSpherePreconditions.checkState(notExistedDataSources.isEmpty(), () ->
new MissingRequiredResourcesException(databaseName, notExistedDataSources));
+
ShardingSpherePreconditions.checkState(notExistedDataSources.isEmpty(), () ->
new MissingRequiredStorageUnitsException(databaseName, notExistedDataSources));
Collection<String> logicalDataSources = getLogicDataSources(database);
Collection<String> notExistedLogicalDataSources =
requiredLogicalDataSources.stream().filter(each ->
!logicalDataSources.contains(each)).collect(Collectors.toSet());
-
ShardingSpherePreconditions.checkState(notExistedLogicalDataSources.isEmpty(),
() -> new MissingRequiredResourcesException(databaseName,
notExistedLogicalDataSources));
+
ShardingSpherePreconditions.checkState(notExistedLogicalDataSources.isEmpty(),
() -> new MissingRequiredStorageUnitsException(databaseName,
notExistedLogicalDataSources));
}
@SuppressWarnings("unchecked")
diff --git
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
index 94def6172b1..580f206317a 100644
---
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
+++
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import
org.apache.shardingsphere.infra.rule.identifier.type.exportable.constant.ExportableConstants;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
@@ -74,13 +74,13 @@ public final class
AlterReadwriteSplittingRuleStatementUpdaterTest {
updater.checkSQLStatement(database, createSQLStatement("TEST"), new
ReadwriteSplittingRuleConfiguration(Collections.emptyList(),
Collections.emptyMap()));
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertCheckSQLStatementWithoutExistedResources() {
when(resourceMetaData.getNotExistedResources(any())).thenReturn(Collections.singleton("read_ds_0"));
updater.checkSQLStatement(database, createSQLStatement("TEST"),
createCurrentRuleConfiguration());
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertCheckSQLStatementWithoutExistedAutoAwareResources() {
ExportableRule exportableRule = mock(ExportableRule.class);
when(exportableRule.getExportData()).thenReturn(Collections.singletonMap(ExportableConstants.EXPORT_DB_DISCOVERY_PRIMARY_DATA_SOURCES,
Collections.singletonMap("ms_group", "ds_0")));
diff --git
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
index 13dfa283f27..4952ee460dd 100644
---
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
+++
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import
org.apache.shardingsphere.infra.rule.identifier.type.exportable.constant.ExportableConstants;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
@@ -88,13 +88,13 @@ public final class
CreateReadwriteSplittingRuleStatementUpdaterTest {
updater.checkSQLStatement(database, createSQLStatement("write_ds",
"TEST"), createCurrentRuleConfiguration());
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertCheckSQLStatementWithoutExistedResources() {
when(resourceMetaData.getNotExistedResources(any())).thenReturn(Arrays.asList("read_ds_0",
"read_ds_1"));
updater.checkSQLStatement(database, createSQLStatement("TEST"), null);
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertCheckSQLStatementWithoutExistedAutoAwareResources() {
ExportableRule exportableRule = mock(ExportableRule.class);
when(exportableRule.getExportData()).thenReturn(Collections.singletonMap(ExportableConstants.EXPORT_DB_DISCOVERY_PRIMARY_DATA_SOURCES,
Collections.singletonMap("ms_group", "ds_0")));
diff --git
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
index ebb6806139e..8eccf2d717a 100644
---
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
+++
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.shadow.distsql.handler.checker;
import org.apache.shardingsphere.distsql.handler.exception.DistSQLException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -55,7 +55,7 @@ public class ShadowRuleStatementChecker {
*/
public static void checkStorageUnitsExist(final Collection<String>
requiredStorageUnits, final ShardingSphereDatabase database) {
Collection<String> notExistedStorageUnits =
database.getResourceMetaData().getNotExistedResources(requiredStorageUnits);
-
ShardingSpherePreconditions.checkState(notExistedStorageUnits.isEmpty(), () ->
new MissingRequiredResourcesException(database.getName(),
notExistedStorageUnits));
+
ShardingSpherePreconditions.checkState(notExistedStorageUnits.isEmpty(), () ->
new MissingRequiredStorageUnitsException(database.getName(),
notExistedStorageUnits));
}
/**
diff --git
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
index 69bd4775a44..8da4ab304bb 100644
---
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
+++
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.distsql.update;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
@@ -88,7 +88,7 @@ public final class AlterShadowRuleStatementUpdaterTest {
updater.checkSQLStatement(database, createSQLStatement(ruleSegment),
currentConfig);
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertExecuteWithNotExistResource() {
List<String> dataSources = Arrays.asList("ds", "ds0");
when(resourceMetaData.getNotExistedResources(any())).thenReturn(dataSources);
diff --git
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
index 2efdf8d0f89..d163662381c 100644
---
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
+++
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.distsql.update;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -77,7 +77,7 @@ public final class CreateShadowRuleStatementUpdaterTest {
updater.checkSQLStatement(database, createSQLStatement(false,
ruleSegment), currentConfig);
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertExecuteWithNotExistResource() {
when(resourceMetaData.getNotExistedResources(any())).thenReturn(Arrays.asList("ds0",
"ds1"));
CreateShadowRuleStatement sqlStatement = createSQLStatement(false, new
ShadowRuleSegment("ruleName", "ds1", null, null));
diff --git
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
index 412f8eb3265..ab387d3b6dd 100644
---
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
+++
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
@@ -21,7 +21,7 @@ import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
@@ -161,7 +161,7 @@ public final class ShardingTableRuleStatementChecker {
Collection<String> notExistedResources =
database.getResourceMetaData().getNotExistedResources(requiredResource);
Collection<String> logicResources = getLogicResources(database);
notExistedResources.removeIf(logicResources::contains);
- ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(),
() -> new MissingRequiredResourcesException(databaseName, notExistedResources));
+ ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(),
() -> new MissingRequiredStorageUnitsException(databaseName,
notExistedResources));
}
private static Collection<String> getLogicResources(final
ShardingSphereDatabase database) {
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
index d773ab7f385..7e1068b99ce 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.checker;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
@@ -125,7 +125,7 @@ public final class ShardingRuleStatementCheckerTest {
ShardingTableRuleStatementChecker.checkAlteration(database, rules,
shardingRuleConfig);
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertCheckCreationWithResourceRequiredMissed() {
List<AbstractTableRuleSegment> rules = Collections.singletonList(new
AutoTableRuleSegment("t_product", Arrays.asList("ds_required_missed", "ds_1")));
ShardingTableRuleStatementChecker.checkCreation(database, rules,
false, shardingRuleConfig);
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/mode/ModeContextManager.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/mode/ModeContextManager.java
index 6593f7c4535..5ed7d90bf52 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/mode/ModeContextManager.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/mode/ModeContextManager.java
@@ -54,7 +54,6 @@ public interface ModeContextManager {
*/
void createSchema(String databaseName, String schemaName);
-
/**
* Alter schema.
*
diff --git
a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefresher.java
b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefresher.java
index 4014889f4ad..01ffd8653ee 100644
---
a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefresher.java
+++
b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefresher.java
@@ -47,5 +47,5 @@ public interface MetaDataRefresher<T extends SQLStatement>
extends TypedSPI {
* @throws SQLException SQL exception
*/
void refresh(ModeContextManager modeContextManager, ShardingSphereDatabase
database, Collection<String> logicDataSourceNames, String schemaName,
- T sqlStatement,
ConfigurationProperties props) throws SQLException;
+ T sqlStatement, ConfigurationProperties props) throws
SQLException;
}
diff --git
a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/table/AlterTableStatementSchemaRefresher.java
b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/table/AlterTableStatementSchemaRefresher.java
index 72d30bbbc32..954453ce31a 100644
---
a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/table/AlterTableStatementSchemaRefresher.java
+++
b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/table/AlterTableStatementSchemaRefresher.java
@@ -67,8 +67,8 @@ public final class AlterTableStatementSchemaRefresher
implements MetaDataRefresh
GenericSchemaBuilderMaterial material = new
GenericSchemaBuilderMaterial(database.getProtocolType(),
database.getResourceMetaData().getStorageTypes(),
database.getResourceMetaData().getDataSources(), ruleMetaData.getRules(),
props, schemaName);
Map<String, ShardingSphereSchema> schemaMap =
GenericSchemaBuilder.build(Collections.singletonList(tableName), material);
- return Optional.ofNullable(schemaMap.get(schemaName)).map(optional ->
optional.getTable(tableName)).orElseGet(() ->
- new ShardingSphereTable(tableName, Collections.emptyList(),
Collections.emptyList(), Collections.emptyList()));
+ return Optional.ofNullable(schemaMap.get(schemaName)).map(optional ->
optional.getTable(tableName))
+ .orElseGet(() -> new ShardingSphereTable(tableName,
Collections.emptyList(), Collections.emptyList(), Collections.emptyList()));
}
private boolean containsInImmutableDataNodeContainedRule(final String
tableName, final ShardingSphereDatabase database) {
diff --git
a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/table/RenameTableStatementSchemaRefresher.java
b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/table/RenameTableStatementSchemaRefresher.java
index 1b8ebddd57d..d399628a813 100644
---
a/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/table/RenameTableStatementSchemaRefresher.java
+++
b/infra/context/src/main/java/org/apache/shardingsphere/infra/context/refresher/type/table/RenameTableStatementSchemaRefresher.java
@@ -64,8 +64,8 @@ public final class RenameTableStatementSchemaRefresher
implements MetaDataRefres
GenericSchemaBuilderMaterial material = new
GenericSchemaBuilderMaterial(database.getProtocolType(),
database.getResourceMetaData().getStorageTypes(),
database.getResourceMetaData().getDataSources(), ruleMetaData.getRules(),
props, schemaName);
Map<String, ShardingSphereSchema> schemaMap =
GenericSchemaBuilder.build(Collections.singletonList(tableName), material);
- return Optional.ofNullable(schemaMap.get(schemaName)).map(optional ->
optional.getTable(tableName)).orElseGet(() ->
- new ShardingSphereTable(tableName, Collections.emptyList(),
Collections.emptyList(), Collections.emptyList()));
+ return Optional.ofNullable(schemaMap.get(schemaName)).map(optional ->
optional.getTable(tableName))
+ .orElseGet(() -> new ShardingSphereTable(tableName,
Collections.emptyList(), Collections.emptyList(), Collections.emptyList()));
}
private boolean containsInImmutableDataNodeContainedRule(final String
tableName, final ShardingSphereDatabase database) {
diff --git
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
index ff2bc88eaaa..082927a402e 100644
---
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
+++
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.check
import
org.apache.shardingsphere.dbdiscovery.api.config.DatabaseDiscoveryRuleConfiguration;
import
org.apache.shardingsphere.dbdiscovery.factory.DatabaseDiscoveryProviderAlgorithmFactory;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -56,7 +56,7 @@ public final class
DatabaseDiscoveryRuleConfigurationImportChecker {
Collection<String> requiredDataSources = new LinkedHashSet<>();
currentRuleConfig.getDataSources().forEach(each ->
requiredDataSources.addAll(each.getDataSourceNames()));
Collection<String> notExistedDataSources =
database.getResourceMetaData().getNotExistedResources(requiredDataSources);
-
ShardingSpherePreconditions.checkState(notExistedDataSources.isEmpty(), () ->
new MissingRequiredResourcesException(databaseName, notExistedDataSources));
+
ShardingSpherePreconditions.checkState(notExistedDataSources.isEmpty(), () ->
new MissingRequiredStorageUnitsException(databaseName, notExistedDataSources));
}
private void checkDiscoverTypeAndHeartbeat(final String databaseName,
final DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
diff --git
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportChecker.java
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportChecker.java
index 1733a98a1b4..1c0a8f40193 100644
---
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportChecker.java
+++
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportChecker.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.checker;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
@@ -67,10 +67,10 @@ public final class
ReadwriteSplittingRuleConfigurationImportChecker {
}
});
Collection<String> notExistedDataSources =
database.getResourceMetaData().getNotExistedResources(requiredDataSources);
-
ShardingSpherePreconditions.checkState(notExistedDataSources.isEmpty(), () ->
new MissingRequiredResourcesException(databaseName, notExistedDataSources));
+
ShardingSpherePreconditions.checkState(notExistedDataSources.isEmpty(), () ->
new MissingRequiredStorageUnitsException(databaseName, notExistedDataSources));
Collection<String> logicalDataSources = getLogicDataSources(database);
Collection<String> notExistedLogicalDataSources =
requiredLogicalDataSources.stream().filter(each ->
!logicalDataSources.contains(each)).collect(Collectors.toSet());
-
ShardingSpherePreconditions.checkState(notExistedLogicalDataSources.isEmpty(),
() -> new MissingRequiredResourcesException(databaseName,
notExistedLogicalDataSources));
+
ShardingSpherePreconditions.checkState(notExistedLogicalDataSources.isEmpty(),
() -> new MissingRequiredStorageUnitsException(databaseName,
notExistedLogicalDataSources));
}
private Collection<String> getLogicDataSources(final
ShardingSphereDatabase database) {
diff --git
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
index 330d5409c9b..d78f1785029 100644
---
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
+++
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.check
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.ShardingSphereAlgorithm;
import org.apache.shardingsphere.infra.datanode.DataNode;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import
org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -124,7 +124,7 @@ public final class ShardingRuleConfigurationImportChecker {
Collection<String> notExistedResources =
database.getResourceMetaData().getNotExistedResources(requiredResource);
Collection<String> logicResources = getLogicResources(database);
notExistedResources.removeIf(logicResources::contains);
- ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(),
() -> new MissingRequiredResourcesException(databaseName, notExistedResources));
+ ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(),
() -> new MissingRequiredStorageUnitsException(databaseName,
notExistedResources));
}
private Collection<String> getLogicResources(final ShardingSphereDatabase
database) {
diff --git
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/AlterReadwriteSplittingStorageUnitStatusStatementHandler.java
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/AlterReadwriteSplittingStorageUnitStatusStatementHandler.java
index 7428d906528..863a6bdea46 100644
---
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/AlterReadwriteSplittingStorageUnitStatusStatementHandler.java
+++
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/AlterReadwriteSplittingStorageUnitStatusStatementHandler.java
@@ -23,7 +23,7 @@ import
org.apache.shardingsphere.dialect.exception.syntax.database.NoDatabaseSel
import
org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException;
import
org.apache.shardingsphere.infra.rule.identifier.type.exportable.constant.ExportableConstants;
import
org.apache.shardingsphere.infra.rule.identifier.type.exportable.constant.ExportableItemConstants;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.infra.metadata.database.schema.QualifiedDatabase;
import
org.apache.shardingsphere.infra.rule.identifier.type.exportable.RuleExportEngine;
import
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -135,7 +135,7 @@ public final class
AlterReadwriteSplittingStorageUnitStatusStatementHandler exte
private void checkResourceExists(final ContextManager contextManager,
final String databaseName, final String toBeDisabledResource) {
Collection<String> notExistedResources = contextManager
.getMetaDataContexts().getMetaData().getDatabase(databaseName).getResourceMetaData().getNotExistedResources(Collections.singleton(toBeDisabledResource));
- ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(),
() -> new MissingRequiredResourcesException(databaseName,
Collections.singleton(toBeDisabledResource)));
+ ShardingSpherePreconditions.checkState(notExistedResources.isEmpty(),
() -> new MissingRequiredStorageUnitsException(databaseName,
Collections.singleton(toBeDisabledResource)));
}
private void checkIsNotDisabled(final Collection<String>
disabledResources, final String toBeEnabledResource) {
diff --git
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationHandler.java
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationHandler.java
index f99800d0cb5..5f0d0d8ebe7 100644
---
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationHandler.java
+++
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationHandler.java
@@ -31,7 +31,7 @@ import
org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
import
org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesCreator;
import org.apache.shardingsphere.distsql.handler.exception.DistSQLException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.InvalidResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
@@ -127,7 +127,7 @@ public final class ImportDatabaseConfigurationHandler
extends UpdatableRALBacken
try {
ProxyContext.getInstance().getContextManager().getInstanceContext().getModeContextManager().registerStorageUnits(databaseName,
dataSourcePropsMap);
} catch (final SQLException ex) {
- throw new
InvalidResourcesException(Collections.singleton(ex.getMessage()));
+ throw new
InvalidStorageUnitsException(Collections.singleton(ex.getMessage()));
}
}
diff --git
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataHandler.java
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataHandler.java
index fef3ea83889..14653079110 100644
---
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataHandler.java
+++
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataHandler.java
@@ -22,8 +22,8 @@ import
org.apache.shardingsphere.dialect.exception.syntax.database.NoDatabaseSel
import
org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException;
import
org.apache.shardingsphere.distsql.parser.statement.ral.updatable.RefreshTableMetaDataStatement;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.EmptyResourceException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.EmptyStorageUnitException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -59,10 +59,10 @@ public final class RefreshTableMetaDataHandler extends
UpdatableRALBackendHandle
}
private void checkDataSources(final String databaseName, final Map<String,
DataSource> dataSources) {
- ShardingSpherePreconditions.checkState(!dataSources.isEmpty(), () ->
new EmptyResourceException(databaseName));
+ ShardingSpherePreconditions.checkState(!dataSources.isEmpty(), () ->
new EmptyStorageUnitException(databaseName));
if (getSqlStatement().getStorageUnitName().isPresent()) {
String storageUnitName =
getSqlStatement().getStorageUnitName().get();
-
ShardingSpherePreconditions.checkState(dataSources.containsKey(storageUnitName),
() -> new MissingRequiredResourcesException(databaseName,
Collections.singletonList(storageUnitName)));
+
ShardingSpherePreconditions.checkState(dataSources.containsKey(storageUnitName),
() -> new MissingRequiredStorageUnitsException(databaseName,
Collections.singletonList(storageUnitName)));
}
}
diff --git
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterStorageUnitBackendHandler.java
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterStorageUnitBackendHandler.java
index f3853601b7d..188d7bc1e72 100644
---
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterStorageUnitBackendHandler.java
+++
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterStorageUnitBackendHandler.java
@@ -29,9 +29,9 @@ import
org.apache.shardingsphere.infra.database.metadata.url.StandardJdbcUrlPars
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
import
org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesCreator;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.DuplicateResourceException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.InvalidResourcesException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.DuplicateStorageUnitException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import
org.apache.shardingsphere.infra.util.exception.external.server.ShardingSphereServerException;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -74,7 +74,7 @@ public final class AlterStorageUnitBackendHandler extends
DatabaseRequiredBacken
ProxyContext.getInstance().getContextManager().getInstanceContext().getModeContextManager().alterStorageUnits(databaseName,
dataSourcePropsMap);
} catch (final SQLException | ShardingSphereServerException ex) {
log.error("Alter storage unit failed", ex);
- throw new
InvalidResourcesException(Collections.singleton(ex.getMessage()));
+ throw new
InvalidStorageUnitsException(Collections.singleton(ex.getMessage()));
}
return new UpdateResponseHeader(sqlStatement);
}
@@ -93,7 +93,7 @@ public final class AlterStorageUnitBackendHandler extends
DatabaseRequiredBacken
private void checkDuplicatedStorageUnitNames(final Collection<String>
storageUnitNames) {
Collection<String> duplicatedStorageUnitNames =
getDuplicatedStorageUnitNames(storageUnitNames);
-
ShardingSpherePreconditions.checkState(duplicatedStorageUnitNames.isEmpty(), ()
-> new DuplicateResourceException(duplicatedStorageUnitNames));
+
ShardingSpherePreconditions.checkState(duplicatedStorageUnitNames.isEmpty(), ()
-> new DuplicateStorageUnitException(duplicatedStorageUnitNames));
}
private Collection<String> getDuplicatedStorageUnitNames(final
Collection<String> storageUnitNames) {
@@ -103,7 +103,7 @@ public final class AlterStorageUnitBackendHandler extends
DatabaseRequiredBacken
private void checkStorageUnitNameExisted(final String databaseName, final
Collection<String> storageUnitNames) {
Map<String, DataSource> storageUnits =
ProxyContext.getInstance().getDatabase(databaseName).getResourceMetaData().getDataSources();
Collection<String> notExistedStorageUnitNames =
storageUnitNames.stream().filter(each ->
!storageUnits.containsKey(each)).collect(Collectors.toList());
-
ShardingSpherePreconditions.checkState(notExistedStorageUnitNames.isEmpty(), ()
-> new MissingRequiredResourcesException(databaseName,
notExistedStorageUnitNames));
+
ShardingSpherePreconditions.checkState(notExistedStorageUnitNames.isEmpty(), ()
-> new MissingRequiredStorageUnitsException(databaseName,
notExistedStorageUnitNames));
}
private void checkDatabase(final String databaseName, final
AlterStorageUnitStatement sqlStatement) {
@@ -111,7 +111,7 @@ public final class AlterStorageUnitBackendHandler extends
DatabaseRequiredBacken
Collection<String> invalidStorageUnitNames =
sqlStatement.getStorageUnits().stream().collect(Collectors.toMap(DataSourceSegment::getName,
each -> each)).entrySet().stream()
.filter(each -> !isIdenticalDatabase(each.getValue(),
storageUnits.get(each.getKey()))).map(Entry::getKey).collect(Collectors.toSet());
ShardingSpherePreconditions.checkState(invalidStorageUnitNames.isEmpty(),
- () -> new
InvalidResourcesException(Collections.singleton(String.format("Cannot alter the
database of %s", invalidStorageUnitNames))));
+ () -> new
InvalidStorageUnitsException(Collections.singleton(String.format("Cannot alter
the database of %s", invalidStorageUnitNames))));
}
private boolean isIdenticalDatabase(final DataSourceSegment segment, final
DataSource dataSource) {
diff --git
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/RegisterStorageUnitBackendHandler.java
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/RegisterStorageUnitBackendHandler.java
index 332f41f2b13..c9fe7bb7a81 100644
---
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/RegisterStorageUnitBackendHandler.java
+++
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/RegisterStorageUnitBackendHandler.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.resource;
import lombok.extern.slf4j.Slf4j;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.DuplicateResourceException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.InvalidResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.DuplicateStorageUnitException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.validate.DataSourcePropertiesValidateHandler;
import org.apache.shardingsphere.distsql.parser.segment.DataSourceSegment;
import
org.apache.shardingsphere.distsql.parser.segment.converter.DataSourceSegmentsConverter;
@@ -77,7 +77,7 @@ public final class RegisterStorageUnitBackendHandler extends
DatabaseRequiredBac
ProxyContext.getInstance().getContextManager().getInstanceContext().getModeContextManager().registerStorageUnits(databaseName,
dataSourcePropsMap);
} catch (final SQLException | ShardingSphereServerException ex) {
log.error("Register storage unit failed", ex);
- throw new
InvalidResourcesException(Collections.singleton(ex.getMessage()));
+ throw new
InvalidStorageUnitsException(Collections.singleton(ex.getMessage()));
}
return new UpdateResponseHeader(sqlStatement);
}
@@ -99,7 +99,7 @@ public final class RegisterStorageUnitBackendHandler extends
DatabaseRequiredBac
}
dataSourceNames.add(each.getName());
}
-
ShardingSpherePreconditions.checkState(duplicatedDataSourceNames.isEmpty(), ()
-> new DuplicateResourceException(duplicatedDataSourceNames));
+
ShardingSpherePreconditions.checkState(duplicatedDataSourceNames.isEmpty(), ()
-> new DuplicateStorageUnitException(duplicatedDataSourceNames));
}
private void checkDuplicatedLogicalDataSourceNames(final String
databaseName, final Collection<String> requiredDataSourceNames) {
@@ -109,7 +109,7 @@ public final class RegisterStorageUnitBackendHandler
extends DatabaseRequiredBac
}
Collection<String> duplicatedDataSourceNames =
requiredDataSourceNames.stream().filter(logicalDataSourceNames::contains).collect(Collectors.toSet());
ShardingSpherePreconditions.checkState(duplicatedDataSourceNames.isEmpty(),
- () -> new
InvalidResourcesException(Collections.singleton(String.format("%s already
existed in rule", duplicatedDataSourceNames))));
+ () -> new
InvalidStorageUnitsException(Collections.singleton(String.format("%s already
existed in rule", duplicatedDataSourceNames))));
}
private Collection<String> getCurrentStorageUnitNames(final String
databaseName) {
diff --git
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/UnregisterStorageUnitBackendHandler.java
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/UnregisterStorageUnitBackendHandler.java
index 7931b29755f..201b93309fc 100644
---
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/UnregisterStorageUnitBackendHandler.java
+++
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/UnregisterStorageUnitBackendHandler.java
@@ -22,9 +22,9 @@ import com.google.common.collect.Multimap;
import lombok.extern.slf4j.Slf4j;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.UnregisterStorageUnitStatement;
import org.apache.shardingsphere.infra.datanode.DataNode;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.InvalidResourcesException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.ResourceInUsedException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.StorageUnitInUsedException;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
@@ -62,7 +62,7 @@ public final class UnregisterStorageUnitBackendHandler
extends DatabaseRequiredB
ProxyContext.getInstance().getContextManager().getInstanceContext().getModeContextManager().unregisterStorageUnits(databaseName,
sqlStatement.getStorageUnitNames());
} catch (final SQLException | ShardingSphereServerException ex) {
log.error("Unregister storage unit failed", ex);
- throw new
InvalidResourcesException(Collections.singleton(ex.getMessage()));
+ throw new
InvalidStorageUnitsException(Collections.singleton(ex.getMessage()));
}
return new UpdateResponseHeader(sqlStatement);
}
@@ -78,7 +78,7 @@ public final class UnregisterStorageUnitBackendHandler
extends DatabaseRequiredB
private void checkExisted(final String databaseName, final
Collection<String> storageUnitNames) {
Map<String, DataSource> dataSources =
ProxyContext.getInstance().getDatabase(databaseName).getResourceMetaData().getDataSources();
Collection<String> notExistedStorageUnits =
storageUnitNames.stream().filter(each ->
!dataSources.containsKey(each)).collect(Collectors.toList());
-
ShardingSpherePreconditions.checkState(notExistedStorageUnits.isEmpty(), () ->
new MissingRequiredResourcesException(databaseName, notExistedStorageUnits));
+
ShardingSpherePreconditions.checkState(notExistedStorageUnits.isEmpty(), () ->
new MissingRequiredStorageUnitsException(databaseName, notExistedStorageUnits));
}
private void checkInUsed(final String databaseName, final
UnregisterStorageUnitStatement sqlStatement) {
@@ -90,7 +90,7 @@ public final class UnregisterStorageUnitBackendHandler
extends DatabaseRequiredB
checkInUsedIgnoreSingleTables(new
HashSet<>(inUsedStorageUnitNames), inUsedStorageUnits);
} else {
String firstResource =
inUsedStorageUnitNames.iterator().next();
- throw new ResourceInUsedException(firstResource,
inUsedStorageUnits.get(firstResource));
+ throw new StorageUnitInUsedException(firstResource,
inUsedStorageUnits.get(firstResource));
}
}
}
@@ -128,7 +128,7 @@ public final class UnregisterStorageUnitBackendHandler
extends DatabaseRequiredB
for (String each : inUsedResourceNames) {
Collection<String> inUsedRules = inUsedStorageUnits.get(each);
inUsedRules.remove(SingleRule.class.getSimpleName());
- ShardingSpherePreconditions.checkState(inUsedRules.isEmpty(), ()
-> new ResourceInUsedException(each, inUsedRules));
+ ShardingSpherePreconditions.checkState(inUsedRules.isEmpty(), ()
-> new StorageUnitInUsedException(each, inUsedRules));
}
}
}
diff --git
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/SetDefaultSingleTableStorageUnitStatementUpdater.java
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/SetDefaultSingleTableStorageUnitStatementUpdater.java
index 15074ec2516..060f1485167 100644
---
a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/SetDefaultSingleTableStorageUnitStatementUpdater.java
+++
b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/SetDefaultSingleTableStorageUnitStatementUpdater.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule;
import org.apache.commons.lang3.StringUtils;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.SetDefaultSingleTableStorageUnitStatement;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.update.RuleDefinitionCreateUpdater;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -42,7 +42,7 @@ public final class
SetDefaultSingleTableStorageUnitStatementUpdater implements R
if (StringUtils.isNotBlank(sqlStatement.getDefaultStorageUnit())) {
Collection<String> storageUnitNames =
database.getResourceMetaData().getDataSources().keySet();
ShardingSpherePreconditions.checkState(storageUnitNames.contains(sqlStatement.getDefaultStorageUnit()),
- () -> new
MissingRequiredResourcesException(database.getName(),
Collections.singleton(sqlStatement.getDefaultStorageUnit())));
+ () -> new
MissingRequiredStorageUnitsException(database.getName(),
Collections.singleton(sqlStatement.getDefaultStorageUnit())));
}
}
diff --git
a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataHandlerTest.java
b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataHandlerTest.java
index 2f0eb5ea15e..0b16f39a52b 100644
---
a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataHandlerTest.java
+++
b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataHandlerTest.java
@@ -22,8 +22,8 @@ import
org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDataba
import
org.apache.shardingsphere.distsql.parser.statement.ral.updatable.RefreshTableMetaDataStatement;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.EmptyResourceException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.EmptyStorageUnitException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -80,7 +80,7 @@ public final class RefreshTableMetaDataHandlerTest extends
ProxyContextRestorer
backendHandler.execute();
}
- @Test(expected = EmptyResourceException.class)
+ @Test(expected = EmptyStorageUnitException.class)
public void assertEmptyResource() throws SQLException {
when(connectionSession.getDatabaseName()).thenReturn("sharding_db");
when(shardingSphereMetaData.containsDatabase("sharding_db")).thenReturn(true);
@@ -90,7 +90,7 @@ public final class RefreshTableMetaDataHandlerTest extends
ProxyContextRestorer
backendHandler.execute();
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertMissingRequiredResources() throws SQLException {
when(connectionSession.getDatabaseName()).thenReturn("sharding_db");
when(shardingSphereMetaData.containsDatabase("sharding_db")).thenReturn(true);
diff --git
a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterStorageUnitBackendHandlerTest.java
b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterStorageUnitBackendHandlerTest.java
index 89ce020467e..f95623cbd1e 100644
---
a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterStorageUnitBackendHandlerTest.java
+++
b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/AlterStorageUnitBackendHandlerTest.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.resource;
import com.zaxxer.hikari.HikariDataSource;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.DuplicateResourceException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.InvalidResourcesException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.DuplicateStorageUnitException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.validate.DataSourcePropertiesValidateHandler;
import org.apache.shardingsphere.distsql.parser.segment.DataSourceSegment;
import
org.apache.shardingsphere.distsql.parser.segment.HostnameAndPortBasedDataSourceSegment;
@@ -101,12 +101,12 @@ public final class AlterStorageUnitBackendHandlerTest
extends ProxyContextRestor
assertThat(alterStorageUnitBackendHandler.execute("test_db",
createAlterStorageUnitStatement("ds_0")),
instanceOf(UpdateResponseHeader.class));
}
- @Test(expected = DuplicateResourceException.class)
+ @Test(expected = DuplicateStorageUnitException.class)
public void assertExecuteWithDuplicateStorageUnitNames() {
alterStorageUnitBackendHandler.execute("test_db",
createAlterStorageUnitStatementWithDuplicateStorageUnitNames());
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertExecuteWithNotExistedStorageUnitNames() {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
@@ -117,7 +117,7 @@ public final class AlterStorageUnitBackendHandlerTest
extends ProxyContextRestor
alterStorageUnitBackendHandler.execute("test_db",
createAlterStorageUnitStatement("not_existed"));
}
- @Test(expected = InvalidResourcesException.class)
+ @Test(expected = InvalidStorageUnitsException.class)
public void assertExecuteWithAlterDatabase() {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
diff --git
a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/RegisterStorageUnitBackendHandlerTest.java
b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/RegisterStorageUnitBackendHandlerTest.java
index b098d92f9bd..364acd3b9c6 100644
---
a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/RegisterStorageUnitBackendHandlerTest.java
+++
b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/RegisterStorageUnitBackendHandlerTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.resource;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.DuplicateResourceException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.InvalidResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.DuplicateStorageUnitException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.InvalidStorageUnitsException;
import
org.apache.shardingsphere.distsql.handler.validate.DataSourcePropertiesValidateHandler;
import org.apache.shardingsphere.distsql.parser.segment.DataSourceSegment;
import
org.apache.shardingsphere.distsql.parser.segment.HostnameAndPortBasedDataSourceSegment;
@@ -96,7 +96,7 @@ public final class RegisterStorageUnitBackendHandlerTest
extends ProxyContextRes
assertThat(responseHeader, instanceOf(UpdateResponseHeader.class));
}
- @Test(expected = DuplicateResourceException.class)
+ @Test(expected = DuplicateStorageUnitException.class)
public void assertExecuteWithDuplicateStorageUnitNamesInStatement() {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
@@ -104,7 +104,7 @@ public final class RegisterStorageUnitBackendHandlerTest
extends ProxyContextRes
registerStorageUnitBackendHandler.execute("test_db",
createRegisterStorageUnitStatementWithDuplicateStorageUnitNames());
}
- @Test(expected = DuplicateResourceException.class)
+ @Test(expected = DuplicateStorageUnitException.class)
public void
assertExecuteWithDuplicateStorageUnitNamesWithResourceMetaData() {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
ProxyContext.init(contextManager);
@@ -112,7 +112,7 @@ public final class RegisterStorageUnitBackendHandlerTest
extends ProxyContextRes
registerStorageUnitBackendHandler.execute("test_db",
createRegisterStorageUnitStatement());
}
- @Test(expected = InvalidResourcesException.class)
+ @Test(expected = InvalidStorageUnitsException.class)
public void
assertExecuteWithDuplicateStorageUnitNamesWithDataSourceContainedRule() {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
diff --git
a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/UnregisterStorageUnitBackendHandlerTest.java
b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/UnregisterStorageUnitBackendHandlerTest.java
index 8192c5e8511..493b5e18567 100644
---
a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/UnregisterStorageUnitBackendHandlerTest.java
+++
b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/UnregisterStorageUnitBackendHandlerTest.java
@@ -20,8 +20,8 @@ package
org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.resource;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.UnregisterStorageUnitStatement;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.distsql.handler.exception.DistSQLException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.ResourceInUsedException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.StorageUnitInUsedException;
import org.apache.shardingsphere.infra.instance.mode.ModeContextManager;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
@@ -112,12 +112,12 @@ public final class
UnregisterStorageUnitBackendHandlerTest extends ProxyContextR
verify(modeContextManager).unregisterStorageUnits("test",
unregisterStorageUnitStatement.getStorageUnitNames());
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertStorageUnitNameNotExistedExecute() {
unregisterStorageUnitBackendHandler.execute("test", new
UnregisterStorageUnitStatement(Collections.singleton("foo_ds"), false));
}
- @Test(expected = ResourceInUsedException.class)
+ @Test(expected = StorageUnitInUsedException.class)
public void assertStorageUnitNameInUseExecute() {
when(ruleMetaData.getRules()).thenReturn(Collections.singleton(shadowRule));
when(shadowRule.getType()).thenReturn("ShadowRule");
@@ -128,7 +128,7 @@ public final class UnregisterStorageUnitBackendHandlerTest
extends ProxyContextR
unregisterStorageUnitBackendHandler.execute("test", new
UnregisterStorageUnitStatement(Collections.singleton("foo_ds"), false));
}
- @Test(expected = ResourceInUsedException.class)
+ @Test(expected = StorageUnitInUsedException.class)
public void assertStorageUnitNameInUseWithoutIgnoreSingleTables() {
when(ruleMetaData.getRules()).thenReturn(Collections.singleton(singleTableRule));
when(singleTableRule.getType()).thenReturn("SingleTableRule");
diff --git
a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/SetDefaultSingleTableStorageUnitUpdaterTest.java
b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/SetDefaultSingleTableStorageUnitUpdaterTest.java
index 0f23398adcd..c639418cd3d 100644
---
a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/SetDefaultSingleTableStorageUnitUpdaterTest.java
+++
b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/SetDefaultSingleTableStorageUnitUpdaterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.SetDefaultSingleTableStorageUnitStatement;
-import
org.apache.shardingsphere.distsql.handler.exception.resource.MissingRequiredResourcesException;
+import
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource;
@@ -54,7 +54,7 @@ public final class
SetDefaultSingleTableStorageUnitUpdaterTest {
when(database.getResourceMetaData().getDataSources()).thenReturn(Collections.singletonMap("ds_0",
new MockedDataSource()));
}
- @Test(expected = MissingRequiredResourcesException.class)
+ @Test(expected = MissingRequiredStorageUnitsException.class)
public void assertCheckWithInvalidResource() {
updater.checkSQLStatement(database, new
SetDefaultSingleTableStorageUnitStatement("ds_1"), currentConfig);
}