You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2024/03/15 14:43:51 UTC
(shardingsphere) branch master updated: Merge feature algorithm initialization exceptions exception to AlgorithmInitializationException (#30506)
This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng 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 dbc7c2879cb Merge feature algorithm initialization exceptions exception to AlgorithmInitializationException (#30506)
dbc7c2879cb is described below
commit dbc7c2879cba745c487a027e550ff72da33938de
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Mar 15 22:43:45 2024 +0800
Merge feature algorithm initialization exceptions exception to AlgorithmInitializationException (#30506)
* Merge feature algorithm initialization exceptions exception to AlgorithmInitializationException
* Merge feature algorithm initialization exceptions exception to AlgorithmInitializationException
* Merge feature algorithm initialization exceptions exception to AlgorithmInitializationException
* Merge feature algorithm initialization exceptions exception to AlgorithmInitializationException
* Merge feature algorithm initialization exceptions exception to AlgorithmInitializationException
* Merge feature algorithm initialization exceptions exception to AlgorithmInitializationException
* Merge feature algorithm initialization exceptions exception to AlgorithmInitializationException
* Merge feature algorithm initialization exceptions exception to AlgorithmInitializationException
* Merge feature algorithm initialization exceptions exception to AlgorithmInitializationException
---
.../user-manual/error-code/sql-error-code.cn.md | 100 ++++++++--------
.../user-manual/error-code/sql-error-code.en.md | 128 ++++++++++-----------
.../algorithm/standard/AESEncryptAlgorithm.java | 4 +-
.../EncryptAlgorithmInitializationException.java | 33 ------
.../standard/AESEncryptAlgorithmTest.java | 6 +-
.../update/CreateEncryptRuleExecutorTest.java | 4 +-
.../mask/algorithm/MaskAlgorithmPropsChecker.java | 39 +++----
.../cover/KeepFirstNLastMMaskAlgorithm.java | 6 +-
.../algorithm/cover/KeepFromXToYMaskAlgorithm.java | 10 +-
.../cover/MaskAfterSpecialCharsAlgorithm.java | 4 +-
.../cover/MaskBeforeSpecialCharsAlgorithm.java | 4 +-
.../cover/MaskFirstNLastMMaskAlgorithm.java | 6 +-
.../algorithm/cover/MaskFromXToYMaskAlgorithm.java | 10 +-
.../GenericTableRandomReplaceAlgorithm.java | 8 +-
.../MaskAlgorithmInitializationException.java | 33 ------
.../algorithm/MaskAlgorithmPropsCheckerTest.java | 53 +++++----
.../cover/KeepFirstNLastMMaskAlgorithmTest.java | 8 +-
.../cover/KeepFromXToYMaskAlgorithmTest.java | 14 +--
.../cover/MaskAfterSpecialCharsAlgorithmTest.java | 10 +-
.../cover/MaskBeforeSpecialCharsAlgorithmTest.java | 6 +-
.../cover/MaskFirstNLastMMaskAlgorithmTest.java | 8 +-
.../cover/MaskFromXToYMaskAlgorithmTest.java | 14 +--
...writeSplittingRuleConfigurationCheckerTest.java | 4 +-
.../AbstractColumnMatchedShadowAlgorithm.java | 8 +-
.../column/ColumnRegexMatchedShadowAlgorithm.java | 4 +-
.../column/ColumnValueMatchedShadowAlgorithm.java | 4 +-
.../ShadowAlgorithmInitializationException.java | 33 ------
.../ColumnRegexMatchShadowAlgorithmTest.java | 8 +-
.../ColumnValueMatchShadowAlgorithmTest.java | 8 +-
.../classbased/ClassBasedShardingAlgorithm.java | 8 +-
.../datetime/AutoIntervalShardingAlgorithm.java | 7 +-
.../datetime/IntervalShardingAlgorithm.java | 8 +-
.../sharding/hint/HintInlineShardingAlgorithm.java | 4 +-
.../inline/ComplexInlineShardingAlgorithm.java | 5 +-
.../sharding/inline/InlineShardingAlgorithm.java | 5 +-
.../sharding/mod/HashModShardingAlgorithm.java | 6 +-
.../sharding/mod/ModShardingAlgorithm.java | 10 +-
.../range/BoundaryBasedRangeShardingAlgorithm.java | 6 +-
.../range/VolumeBasedRangeShardingAlgorithm.java | 10 +-
.../ShardingAlgorithmInitializationException.java | 33 ------
.../shardingsphere/sharding/rule/ShardingRule.java | 8 +-
.../ClassBasedShardingAlgorithmTest.java | 10 +-
.../inline/ComplexInlineShardingAlgorithmTest.java | 6 +-
.../inline/InlineShardingAlgorithmTest.java | 6 +-
.../sharding/mod/HashModShardingAlgorithmTest.java | 4 +-
.../sharding/mod/ModShardingAlgorithmTest.java | 10 +-
.../sharding/rule/ShardingRuleTest.java | 12 +-
.../sharding/CoreAutoShardingAlgorithmFixture.java | 8 +-
.../AlgorithmInitializationException.java} | 20 ++--
...eyGenerateAlgorithmInitializationException.java | 32 ------
.../snowflake/SnowflakeKeyGenerateAlgorithm.java | 12 +-
.../SnowflakeKeyGenerateAlgorithmTest.java | 8 +-
...oadBalanceAlgorithmInitializationException.java | 32 ------
.../weight/WeightLoadBalanceAlgorithm.java | 10 +-
...bRateLimitAlgorithmInitializationException.java | 30 -----
.../ratelimit/type/QPSJobRateLimitAlgorithm.java | 4 +-
.../ratelimit/type/TPSJobRateLimitAlgorithm.java | 4 +-
.../ratelimit/QPSJobRateLimitAlgorithmTest.java | 4 +-
.../ratelimit/TPSJobRateLimitAlgorithmTest.java | 4 +-
.../traffic/segment/SQLMatchTrafficAlgorithm.java | 8 +-
.../traffic/segment/SQLRegexTrafficAlgorithm.java | 8 +-
...entTrafficAlgorithmInitializationException.java | 33 ------
.../e2e/fixture/ITEncryptLikeAlgorithmFixture.java | 8 +-
.../RewriteEncryptLikeAlgorithmFixture.java | 8 +-
64 files changed, 344 insertions(+), 624 deletions(-)
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index 15ee67950c5..5f6d4c79c03 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -22,6 +22,7 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| 42S02 | 10006 | Unknown column '%s' in '%s'. |
| 42S02 | 10007 | Table or view \`%s\` does not exist. |
| 42000 | 10010 | Rule does not exist. |
+| 44000 | 10011 | '%s.'%s' initialization failed, reason is: %s. |
| 42S02 | 10020 | Schema \`%s\` does not exist. |
| 42S02 | 10021 | Single table \`%s\` does not exist. |
| HY000 | 10022 | Can not load table with database name \`%s\` and data source name \`%s\`. |
@@ -38,16 +39,16 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
### 语法
-| SQL State | Vendor Code | 错误信息 |
-|-----------|-------------|---------------------------------------------|
-| 42000 | 12000 | You have an error in your SQL syntax: %s |
-| 42000 | 12001 | Can not accept SQL type \`%s\`. |
-| 42000 | 12002 | SQL String can not be NULL or empty. |
-| 42000 | 12010 | Can not support variable \`%s\`. |
-| 42S02 | 12011 | Can not find column label \`%s\`. |
-| 42S02 | 12012 | Can not find url provider for \`%s`\. |
-| HV008 | 12020 | Column index \`%d\` is out of range. |
-| 0A000 | 12100 | DROP TABLE ... CASCADE is not supported. |
+| SQL State | Vendor Code | 错误信息 |
+|-----------|-------------|------------------------------------------|
+| 42000 | 12000 | You have an error in your SQL syntax: %s |
+| 42000 | 12001 | Can not accept SQL type \`%s\`. |
+| 42000 | 12002 | SQL String can not be NULL or empty. |
+| 42000 | 12010 | Can not support variable \`%s\`. |
+| 42S02 | 12011 | Can not find column label \`%s\`. |
+| 42S02 | 12012 | Can not find url provider for \`%s`\. |
+| HV008 | 12020 | Column index \`%d\` is out of range. |
+| 0A000 | 12100 | DROP TABLE ... CASCADE is not supported. |
### 连接
@@ -109,37 +110,37 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
### 迁移
-| SQL State | Vendor Code | 错误信息 |
-|-----------|-------------|------------------------------------------------------------------------------------|
-| 42S02 | 18002 | There is no rule in database \`%s\`. |
-| 44000 | 18003 | Mode configuration does not exist. |
-| 44000 | 18004 | Target database \`%s\` isn't exist. |
-| 22023 | 18005 | There is invalid parameter value: `%s`. |
-| HY000 | 18020 | Failed to get DDL for table \`%s\`. |
-| 42S01 | 18030 | Duplicate storage unit names \`%s\`. |
-| 42S02 | 18031 | Storage units names \`%s\` do not exist. |
-| HY000 | 18050 | Before data record is \`%s\`, after data record is \`%s\`. |
-| 08000 | 18051 | Data check table \`%s\` failed. |
-| 0A000 | 18052 | Unsupported pipeline database type \`%s\`. |
-| 0A000 | 18053 | Unsupported CRC32 data consistency calculate algorithm with database type \`%s\`. |
-| 0A000 | 18054 | Unsupported mode type \`%s\`. |
-| HY000 | 18080 | Can not find pipeline job \`%s\`. |
-| HY000 | 18082 | Sharding count of job \`%s\` is 0. |
-| HY000 | 18083 | Can not split by range for table \`%s\`, reason is: %s |
-| HY000 | 18084 | Can not split by unique key \`%s\` for table \`%s\`, reason is: %s |
-| HY000 | 18085 | Target table \`%s\` is not empty. |
-| 01007 | 18086 | Source data source lacks %s privilege(s). |
-| HY000 | 18087 | Source data source required \`%s = %s\`, now is \`%s\`. |
-| HY000 | 18088 | User \`%s\` does exist. |
-| 08000 | 18089 | Check privileges failed on source data source, reason is: %s |
-| 08000 | 18090 | Data sources can not connect, reason is: %s |
-| HY000 | 18091 | Importer job write data failed. |
-| 08000 | 18092 | Get binlog position failed by job \`%s\`, reason is: %s |
-| HY000 | 18095 | Can not find consistency check job of \`%s\`. |
-| HY000 | 18096 | Uncompleted consistency check job \`%s\` exists. |
-| HY000 | 18200 | Not find stream data source table. |
-| HY000 | 18201 | CDC server exception, reason is: %s. |
-| HY000 | 18202 | CDC login failed, reason is: %s |
+| SQL State | Vendor Code | 错误信息 |
+|-----------|-------------|-----------------------------------------------------------------------------------|
+| 42S02 | 18002 | There is no rule in database \`%s\`. |
+| 44000 | 18003 | Mode configuration does not exist. |
+| 44000 | 18004 | Target database \`%s\` isn't exist. |
+| 22023 | 18005 | There is invalid parameter value: \`%s\`. |
+| HY000 | 18020 | Failed to get DDL for table \`%s\`. |
+| 42S01 | 18030 | Duplicate storage unit names \`%s\`. |
+| 42S02 | 18031 | Storage units names \`%s\` do not exist. |
+| HY000 | 18050 | Before data record is \`%s\`, after data record is \`%s\`. |
+| 08000 | 18051 | Data check table \`%s\` failed. |
+| 0A000 | 18052 | Unsupported pipeline database type \`%s\`. |
+| 0A000 | 18053 | Unsupported CRC32 data consistency calculate algorithm with database type \`%s\`. |
+| 0A000 | 18054 | Unsupported mode type \`%s\`. |
+| HY000 | 18080 | Can not find pipeline job \`%s\`. |
+| HY000 | 18082 | Sharding count of job \`%s\` is 0. |
+| HY000 | 18083 | Can not split by range for table \`%s\`, reason is: %s |
+| HY000 | 18084 | Can not split by unique key \`%s\` for table \`%s\`, reason is: %s |
+| HY000 | 18085 | Target table \`%s\` is not empty. |
+| 01007 | 18086 | Source data source lacks %s privilege(s). |
+| HY000 | 18087 | Source data source required \`%s = %s\`, now is \`%s\`. |
+| HY000 | 18088 | User \`%s\` does exist. |
+| 08000 | 18089 | Check privileges failed on source data source, reason is: %s |
+| 08000 | 18090 | Data sources can not connect, reason is: %s |
+| HY000 | 18091 | Importer job write data failed. |
+| 08000 | 18092 | Get binlog position failed by job \`%s\`, reason is: %s |
+| HY000 | 18095 | Can not find consistency check job of \`%s\`. |
+| HY000 | 18096 | Uncompleted consistency check job \`%s\` exists. |
+| HY000 | 18200 | Not find stream data source table. |
+| HY000 | 18201 | CDC server exception, reason is: %s. |
+| HY000 | 18202 | CDC login failed, reason is: %s |
### DistSQL
@@ -205,7 +206,6 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| HY000 | 20080 | Sharding algorithm class \`%s\` should be implement \`%s\`. |
| HY000 | 20081 | Routed target \`%s\` does not exist, available targets are \`%s\`. |
| 44000 | 20082 | Inline sharding algorithms expression \`%s\` and sharding column \`%s\` do not match. |
-| HY000 | 20083 | Sharding algorithm \`%s\` initialization failed, reason is: %s. |
| 44000 | 20084 | Complex inline algorithm need %d sharing columns, but only found %d. |
| 44000 | 20085 | No sharding database route info. |
| 44000 | 20086 | Some routed data sources do not belong to configured data sources. routed data sources: \`%s\`, configured data sources: \`%s\`. |
@@ -250,7 +250,6 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| 44000 | 20702 | Altered column \`%s\` must use same encrypt algorithm with previous column \`%s\` in table \`%s\`. |
| 42000 | 20740 | Insert value of index \`%s\` can not support for encrypt. |
| 0A000 | 20741 | The SQL clause \`%s\` is unsupported in encrypt rule. |
-| HY004 | 20780 | Encrypt algorithm \`%s\` initialization failed, reason is: %s. |
| HY004 | 20781 | \`%s\` column's encryptor name \`%s\` does not match encrypt algorithm type \`%s\`. |
| 44000 | 20703 | Cipher column of \`%s\` can not be null in database \`%s\`. |
| 44000 | 20704 | Can not find (STANDARD\|ASSIST_QUERY\|LIKE_QUERY) encryptor in table \`%s\` and column \`%s\`. |
@@ -269,28 +268,19 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| 44000 | 20803 | Column shadow algorithm \`%s\` operation only supports one column mapping in shadow table \`%s\`. |
| HY004 | 20820 | Shadow column \`%s\` of table \`%s\` does not support \`%s\` type. |
| 42000 | 20840 | Insert value of index \`%s\` can not support for shadow. |
-| HY000 | 20880 | Shadow algorithm \`%s\` initialization failed, reason is: %s. |
| 44000 | 20881 | Default shadow algorithm class should be implement HintShadowAlgorithm. |
### 数据脱敏
| SQL State | Vendor Code | 错误信息 |
|-----------|-------------|-------------------------------------------------------------|
-| HY000 | 20980 | Mask algorithm \`%s\` initialization failed, reason is: %s. |
| 42S02 | 20990 | Invalid mask algorithm \`%s\` in database \`%s\`. |
### 基础算法 - 分布式序列
-| SQL State | Vendor Code | 错误信息 |
-|-----------|-------------|-------------------------------------------------------------|
-| 44000 | 21180 | Can not find strategy for generate keys with table \`%s\`. |
-| HY000 | 21181 | Key generate algorithm \`%s\` initialization failed, reason is: %s. |
-
-### 基础算法 - 负载均衡
-
-| SQL State | Vendor Code | 错误信息 |
-|-----------|-------------|-------------------------------------------------------------------|
-| 44000 | 21280 | '%s' load balance algorithm initialization failed, reason is: %s. |
+| SQL State | Vendor Code | 错误信息 |
+|-----------|-------------|---------------------------------------------------------------------|
+| 44000 | 21180 | Can not find strategy for generate keys with table \`%s\`. |
### 联邦查询
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index 4ff155273f9..094491b2120 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -22,6 +22,7 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
| 42S02 | 10006 | Unknown column '%s' in '%s'. |
| 42S02 | 10007 | Table or view \`%s\` does not exist. |
| 42000 | 10010 | Rule does not exist. |
+| 44000 | 10011 | '%s.'%s' initialization failed, reason is: %s. |
| 42S02 | 10020 | Schema \`%s\` does not exist. |
| 42S02 | 10021 | Single table \`%s\` does not exist. |
| HY000 | 10022 | Can not load table with database name \`%s\` and data source name \`%s\`. |
@@ -38,16 +39,16 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
### Syntax
-| SQL State | Vendor Code | Reason |
-|-----------|-------------|---------------------------------------------|
-| 42000 | 12000 | You have an error in your SQL syntax: %s |
-| 42000 | 12001 | Can not accept SQL type \`%s\`. |
-| 42000 | 12002 | SQL String can not be NULL or empty. |
-| 42000 | 12010 | Can not support variable \`%s\`. |
-| 42S02 | 12011 | Can not find column label \`%s\`. |
-| 42S02 | 12012 | Can not find url provider for \`%s`\. |
-| HV008 | 12020 | Column index \`%d\` is out of range. |
-| 0A000 | 12100 | DROP TABLE ... CASCADE is not supported. |
+| SQL State | Vendor Code | Reason |
+|-----------|-------------|------------------------------------------|
+| 42000 | 12000 | You have an error in your SQL syntax: %s |
+| 42000 | 12001 | Can not accept SQL type \`%s\`. |
+| 42000 | 12002 | SQL String can not be NULL or empty. |
+| 42000 | 12010 | Can not support variable \`%s\`. |
+| 42S02 | 12011 | Can not find column label \`%s\`. |
+| 42S02 | 12012 | Can not find url provider for \`%s`\. |
+| HV008 | 12020 | Column index \`%d\` is out of range. |
+| 0A000 | 12100 | DROP TABLE ... CASCADE is not supported. |
### Connection
@@ -109,37 +110,37 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
### Migration
-| SQL State | Vendor Code | Reason |
-|-----------|-------------|------------------------------------------------------------------------------------|
-| 42S02 | 18002 | There is no rule in database \`%s\`. |
-| 44000 | 18003 | Mode configuration does not exist. |
-| 44000 | 18004 | Target database \`%s\` isn't exist. |
-| 22023 | 18005 | There is invalid parameter value: `%s`. |
-| HY000 | 18020 | Failed to get DDL for table \`%s\`. |
-| 42S01 | 18030 | Duplicate storage unit names \`%s\`. |
-| 42S02 | 18031 | Storage units names \`%s\` do not exist. |
-| HY000 | 18050 | Before data record is \`%s\`, after data record is \`%s\`. |
-| 08000 | 18051 | Data check table \`%s\` failed. |
-| 0A000 | 18052 | Unsupported pipeline database type \`%s\`. |
-| 0A000 | 18053 | Unsupported CRC32 data consistency calculate algorithm with database type \`%s\`. |
-| 0A000 | 18054 | Unsupported mode type \`%s\`. |
-| HY000 | 18080 | Can not find pipeline job \`%s\`. |
-| HY000 | 18082 | Sharding count of job \`%s\` is 0. |
-| HY000 | 18083 | Can not split by range for table \`%s\`, reason is: %s |
-| HY000 | 18084 | Can not split by unique key \`%s\` for table \`%s\`, reason is: %s |
-| HY000 | 18085 | Target table \`%s\` is not empty. |
-| 01007 | 18086 | Source data source lacks %s privilege(s). |
-| HY000 | 18087 | Source data source required \`%s = %s\`, now is \`%s\`. |
-| HY000 | 18088 | User \`%s\` does exist. |
-| 08000 | 18089 | Check privileges failed on source data source, reason is: %s |
-| 08000 | 18090 | Data sources can not connect, reason is: %s |
-| HY000 | 18091 | Importer job write data failed. |
-| 08000 | 18092 | Get binlog position failed by job \`%s\`, reason is: %s |
-| HY000 | 18095 | Can not find consistency check job of \`%s\`. |
-| HY000 | 18096 | Uncompleted consistency check job \`%s\` exists. |
-| HY000 | 18200 | Not find stream data source table. |
-| HY000 | 18201 | CDC server exception, reason is: %s. |
-| HY000 | 18202 | CDC login failed, reason is: %s |
+| SQL State | Vendor Code | Reason |
+|-----------|-------------|-----------------------------------------------------------------------------------|
+| 42S02 | 18002 | There is no rule in database \`%s\`. |
+| 44000 | 18003 | Mode configuration does not exist. |
+| 44000 | 18004 | Target database \`%s\` isn't exist. |
+| 22023 | 18005 | There is invalid parameter value: \`%s\`. |
+| HY000 | 18020 | Failed to get DDL for table \`%s\`. |
+| 42S01 | 18030 | Duplicate storage unit names \`%s\`. |
+| 42S02 | 18031 | Storage units names \`%s\` do not exist. |
+| HY000 | 18050 | Before data record is \`%s\`, after data record is \`%s\`. |
+| 08000 | 18051 | Data check table \`%s\` failed. |
+| 0A000 | 18052 | Unsupported pipeline database type \`%s\`. |
+| 0A000 | 18053 | Unsupported CRC32 data consistency calculate algorithm with database type \`%s\`. |
+| 0A000 | 18054 | Unsupported mode type \`%s\`. |
+| HY000 | 18080 | Can not find pipeline job \`%s\`. |
+| HY000 | 18082 | Sharding count of job \`%s\` is 0. |
+| HY000 | 18083 | Can not split by range for table \`%s\`, reason is: %s |
+| HY000 | 18084 | Can not split by unique key \`%s\` for table \`%s\`, reason is: %s |
+| HY000 | 18085 | Target table \`%s\` is not empty. |
+| 01007 | 18086 | Source data source lacks %s privilege(s). |
+| HY000 | 18087 | Source data source required \`%s = %s\`, now is \`%s\`. |
+| HY000 | 18088 | User \`%s\` does exist. |
+| 08000 | 18089 | Check privileges failed on source data source, reason is: %s |
+| 08000 | 18090 | Data sources can not connect, reason is: %s |
+| HY000 | 18091 | Importer job write data failed. |
+| 08000 | 18092 | Get binlog position failed by job \`%s\`, reason is: %s |
+| HY000 | 18095 | Can not find consistency check job of \`%s\`. |
+| HY000 | 18096 | Uncompleted consistency check job \`%s\` exists. |
+| HY000 | 18200 | Not find stream data source table. |
+| HY000 | 18201 | CDC server exception, reason is: %s. |
+| HY000 | 18202 | CDC login failed, reason is: %s |
### DistSQL
@@ -205,7 +206,6 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
| HY000 | 20080 | Sharding algorithm class \`%s\` should be implement \`%s\`. |
| HY000 | 20081 | Routed target \`%s\` does not exist, available targets are \`%s\`. |
| 44000 | 20082 | Inline sharding algorithms expression \`%s\` and sharding column \`%s\` do not match. |
-| HY000 | 20083 | Sharding algorithm \`%s\` initialization failed, reason is: %s. |
| 44000 | 20084 | Complex inline algorithm need %d sharing columns, but only found %d. |
| 44000 | 20085 | No sharding database route info. |
| 44000 | 20086 | Some routed data sources do not belong to configured data sources. routed data sources: \`%s\`, configured data sources: \`%s\`. |
@@ -258,21 +258,20 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
### Data Encrypt
-| SQL State | Vendor Code | Reason |
-|-----------|-------------|----------------------------------------------------------------------------------------------------|
-| 44000 | 20700 | Can not find logic encrypt column by \`%s\`. |
-| 44000 | 20701 | Fail to find encrypt column \`%s\` from table \`%s\`. |
-| 44000 | 20702 | Altered column \`%s\` must use same encrypt algorithm with previous column \`%s\` in table \`%s\`. |
-| 42000 | 20740 | Insert value of index \`%s\` can not support for encrypt. |
-| 0A000 | 20741 | The SQL clause \`%s\` is unsupported in encrypt rule. |
-| HY004 | 20780 | Encrypt algorithm \`%s\` initialization failed, reason is: %s. |
-| HY004 | 20781 | \`%s\` column's encryptor name \`%s\` does not match encrypt algorithm type \`%s\ in database \`%s\`.|
-| 44000 | 20703 | Cipher column of \`%s\` can not be null in database \`%s\`. |
-| 44000 | 20704 | Can not find (STANDARD\|ASSIST_QUERY\|LIKE_QUERY) encryptor in table \`%s\` and column \`%s\`. |
-| 44000 | 20705 | Assisted query column of \`%s\` can not be null in database \`%s\`. |
-| 44000 | 20707 | Like query column of \`%s\` can not be null in database \`%s\`. |
-| 44000 | 20709 | Can not find encrypt table: \`%s\`. |
-| 44000 | 20710 | Can not found registered encryptor \`%s\` in database \`%s\`. |
+| SQL State | Vendor Code | Reason |
+|-----------|-------------|-------------------------------------------------------------------------------------------------------|
+| 44000 | 20700 | Can not find logic encrypt column by \`%s\`. |
+| 44000 | 20701 | Fail to find encrypt column \`%s\` from table \`%s\`. |
+| 44000 | 20702 | Altered column \`%s\` must use same encrypt algorithm with previous column \`%s\` in table \`%s\`. |
+| 42000 | 20740 | Insert value of index \`%s\` can not support for encrypt. |
+| 0A000 | 20741 | The SQL clause \`%s\` is unsupported in encrypt rule. |
+| HY004 | 20781 | \`%s\` column's encryptor name \`%s\` does not match encrypt algorithm type \`%s\ in database \`%s\`. |
+| 44000 | 20703 | Cipher column of \`%s\` can not be null in database \`%s\`. |
+| 44000 | 20704 | Can not find (STANDARD\|ASSIST_QUERY\|LIKE_QUERY) encryptor in table \`%s\` and column \`%s\`. |
+| 44000 | 20705 | Assisted query column of \`%s\` can not be null in database \`%s\`. |
+| 44000 | 20707 | Like query column of \`%s\` can not be null in database \`%s\`. |
+| 44000 | 20709 | Can not find encrypt table: \`%s\`. |
+| 44000 | 20710 | Can not found registered encryptor \`%s\` in database \`%s\`. |
### Shadow Database
@@ -284,28 +283,19 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
| 44000 | 20803 | Column shadow algorithm \`%s\` operation only supports one column mapping in shadow table \`%s\`. |
| HY004 | 20820 | Shadow column \`%s\` of table \`%s\` does not support \`%s\` type. |
| 42000 | 20840 | Insert value of index \`%s\` can not support for shadow. |
-| HY000 | 20880 | Shadow algorithm \`%s\` initialization failed, reason is: %s. |
| 44000 | 20881 | Default shadow algorithm class should be implement HintShadowAlgorithm. |
### Data Masking
| SQL State | Vendor Code | Reason |
|-----------|-------------|-------------------------------------------------------------|
-| HY000 | 20980 | Mask algorithm \`%s\` initialization failed, reason is: %s. |
| 42S02 | 20990 | Invalid mask algorithm \`%s\` in database \`%s\`. |
### Infra algorithm - key generate
-| SQL State | Vendor Code | Reason |
-|-----------|-------------|-------------------------------------------------------------|
-| 44000 | 21180 | Can not find strategy for generate keys with table \`%s\`. |
-| HY000 | 21181 | Key generate algorithm \`%s\` initialization failed, reason is: %s. |
-
-### Infra algorithm - load balance
-
-| SQL State | Vendor Code | Reason |
-|-----------|-------------|-------------------------------------------------------------------|
-| 44000 | 21280 | '%s' load balance algorithm initialization failed, reason is: %s. |
+| SQL State | Vendor Code | Reason |
+|-----------|-------------|---------------------------------------------------------------------|
+| 44000 | 21180 | Can not find strategy for generate keys with table \`%s\`. |
### SQL Federation
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/AESEncryptAlgorithm.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/AESEncryptAlgorithm.java
index fa902c58c8b..d9bd78ff263 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/AESEncryptAlgorithm.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/AESEncryptAlgorithm.java
@@ -23,10 +23,10 @@ import lombok.Getter;
import lombok.SneakyThrows;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.codec.digest.MessageDigestAlgorithms;
-import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithmMetaData;
import org.apache.shardingsphere.infra.algorithm.core.context.AlgorithmSQLContext;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import javax.crypto.Cipher;
@@ -59,7 +59,7 @@ public final class AESEncryptAlgorithm implements EncryptAlgorithm {
private byte[] getSecretKey(final Properties props) {
String aesKey = props.getProperty(AES_KEY);
- ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(aesKey), () -> new EncryptAlgorithmInitializationException(getType(), String.format("%s can not be null or empty", AES_KEY)));
+ ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(aesKey), () -> new AlgorithmInitializationException(this, "%s can not be null or empty", AES_KEY));
String digestAlgorithm = props.getProperty(DIGEST_ALGORITHM_NAME, MessageDigestAlgorithms.SHA_1);
return Arrays.copyOf(DigestUtils.getDigest(digestAlgorithm.toUpperCase()).digest(aesKey.getBytes(StandardCharsets.UTF_8)), 16);
}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/algorithm/EncryptAlgorithmInitializationException.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/algorithm/EncryptAlgorithmInitializationException.java
deleted file mode 100644
index 578ae86a52b..00000000000
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/algorithm/EncryptAlgorithmInitializationException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.encrypt.exception.algorithm;
-
-import org.apache.shardingsphere.encrypt.exception.EncryptSQLException;
-import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-
-/**
- * Encrypt algorithm initialization exception.
- */
-public final class EncryptAlgorithmInitializationException extends EncryptSQLException {
-
- private static final long serialVersionUID = -2004166948563207100L;
-
- public EncryptAlgorithmInitializationException(final String encryptorType, final String reason) {
- super(XOpenSQLState.GENERAL_ERROR, 80, "Encrypt algorithm `%s` initialization failed, reason is: %s.", encryptorType, reason);
- }
-}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/standard/AESEncryptAlgorithmTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/standard/AESEncryptAlgorithmTest.java
index 4ee3699da9d..f8d8cc9bb4c 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/standard/AESEncryptAlgorithmTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/standard/AESEncryptAlgorithmTest.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.encrypt.algorithm.standard;
import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.infra.algorithm.core.context.AlgorithmSQLContext;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
@@ -68,12 +68,12 @@ class AESEncryptAlgorithmTest {
@Test
void assertCreateNewInstanceWithoutAESKey() {
- assertThrows(EncryptAlgorithmInitializationException.class, () -> TypedSPILoader.getService(EncryptAlgorithm.class, "AES"));
+ assertThrows(AlgorithmInitializationException.class, () -> TypedSPILoader.getService(EncryptAlgorithm.class, "AES"));
}
@Test
void assertCreateNewInstanceWithEmptyAESKey() {
- assertThrows(EncryptAlgorithmInitializationException.class, () -> encryptAlgorithm.init(PropertiesBuilder.build(new Property("aes-key-value", ""))));
+ assertThrows(AlgorithmInitializationException.class, () -> encryptAlgorithm.init(PropertiesBuilder.build(new Property("aes-key-value", ""))));
}
@Test
diff --git a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutorTest.java b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutorTest.java
index 9018b8b7b90..061b6489e77 100644
--- a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutorTest.java
+++ b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutorTest.java
@@ -26,8 +26,8 @@ import org.apache.shardingsphere.encrypt.distsql.segment.EncryptColumnItemSegmen
import org.apache.shardingsphere.encrypt.distsql.segment.EncryptColumnSegment;
import org.apache.shardingsphere.encrypt.distsql.segment.EncryptRuleSegment;
import org.apache.shardingsphere.encrypt.distsql.statement.CreateEncryptRuleStatement;
-import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
@@ -142,7 +142,7 @@ class CreateEncryptRuleExecutorTest {
EncryptRule rule = mock(EncryptRule.class);
when(rule.getConfiguration()).thenReturn(getCurrentRuleConfig());
executor.setRule(rule);
- assertThrows(EncryptAlgorithmInitializationException.class, () -> executor.checkBeforeUpdate(sqlStatement));
+ assertThrows(AlgorithmInitializationException.class, () -> executor.checkBeforeUpdate(sqlStatement));
}
private CreateEncryptRuleStatement createWrongAESEncryptorSQLStatement() {
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsChecker.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsChecker.java
index 54d740899e5..9d089514c9c 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsChecker.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsChecker.java
@@ -19,8 +19,9 @@ package org.apache.shardingsphere.mask.algorithm;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.mask.exception.algorithm.MaskAlgorithmInitializationException;
+import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import java.util.Properties;
@@ -35,12 +36,12 @@ public final class MaskAlgorithmPropsChecker {
*
* @param props props
* @param singleCharConfigKey single char config key
- * @param maskType mask type
+ * @param algorithm mask algorithm
*/
- public static void checkSingleCharConfig(final Properties props, final String singleCharConfigKey, final String maskType) {
- checkRequiredPropertyConfig(props, singleCharConfigKey, maskType);
+ public static void checkSingleCharConfiguration(final Properties props, final String singleCharConfigKey, final MaskAlgorithm<?, ?> algorithm) {
+ checkRequiredPropertyConfiguration(props, singleCharConfigKey, algorithm);
ShardingSpherePreconditions.checkState(1 == props.getProperty(singleCharConfigKey).length(),
- () -> new MaskAlgorithmInitializationException(maskType, String.format("%s's length must be one", singleCharConfigKey)));
+ () -> new AlgorithmInitializationException(algorithm, "%s's length must be one", singleCharConfigKey));
}
/**
@@ -48,35 +49,33 @@ public final class MaskAlgorithmPropsChecker {
*
* @param props props
* @param atLeastOneCharConfigKey at least one char config key
- * @param maskType mask type
+ * @param algorithm mask algorithm
*/
- public static void checkAtLeastOneCharConfig(final Properties props, final String atLeastOneCharConfigKey, final String maskType) {
- checkRequiredPropertyConfig(props, atLeastOneCharConfigKey, maskType);
+ public static void checkAtLeastOneCharConfiguration(final Properties props, final String atLeastOneCharConfigKey, final MaskAlgorithm<?, ?> algorithm) {
+ checkRequiredPropertyConfiguration(props, atLeastOneCharConfigKey, algorithm);
ShardingSpherePreconditions.checkState(props.getProperty(atLeastOneCharConfigKey).length() > 0,
- () -> new MaskAlgorithmInitializationException(maskType, String.format("%s's length must be at least one", atLeastOneCharConfigKey)));
+ () -> new AlgorithmInitializationException(algorithm, "%s's length must be at least one", atLeastOneCharConfigKey));
}
/**
- * Check required property config.
+ * Check required property configuration.
*
* @param props props
* @param positiveIntegerTypeConfigKey positive integer type config key
- * @param maskType mask type
- * @throws MaskAlgorithmInitializationException mask algorithm initialization exception
+ * @param algorithm mask algorithm
+ * @throws AlgorithmInitializationException algorithm initialization exception
*/
- public static void checkPositiveIntegerConfig(final Properties props, final String positiveIntegerTypeConfigKey, final String maskType) {
- checkRequiredPropertyConfig(props, positiveIntegerTypeConfigKey, maskType);
+ public static void checkPositiveIntegerConfiguration(final Properties props, final String positiveIntegerTypeConfigKey, final MaskAlgorithm<?, ?> algorithm) {
+ checkRequiredPropertyConfiguration(props, positiveIntegerTypeConfigKey, algorithm);
try {
int integerValue = Integer.parseInt(props.getProperty(positiveIntegerTypeConfigKey));
- ShardingSpherePreconditions.checkState(integerValue > 0,
- () -> new MaskAlgorithmInitializationException(maskType, String.format("%s must be a positive integer.", positiveIntegerTypeConfigKey)));
+ ShardingSpherePreconditions.checkState(integerValue > 0, () -> new AlgorithmInitializationException(algorithm, "%s must be a positive integer.", positiveIntegerTypeConfigKey));
} catch (final NumberFormatException ex) {
- throw new MaskAlgorithmInitializationException(maskType, String.format("%s must be a valid integer number", positiveIntegerTypeConfigKey));
+ throw new AlgorithmInitializationException(algorithm, "%s must be a valid integer number", positiveIntegerTypeConfigKey);
}
}
- private static void checkRequiredPropertyConfig(final Properties props, final String requiredPropertyConfigKey, final String maskType) {
- ShardingSpherePreconditions.checkState(props.containsKey(requiredPropertyConfigKey),
- () -> new MaskAlgorithmInitializationException(maskType, String.format("%s is required", requiredPropertyConfigKey)));
+ private static void checkRequiredPropertyConfiguration(final Properties props, final String requiredPropertyConfigKey, final MaskAlgorithm<?, ?> algorithm) {
+ ShardingSpherePreconditions.checkState(props.containsKey(requiredPropertyConfigKey), () -> new AlgorithmInitializationException(algorithm, "%s is required", requiredPropertyConfigKey));
}
}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java
index 2d6c23cb33a..0295c2f9c2a 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java
@@ -48,17 +48,17 @@ public final class KeepFirstNLastMMaskAlgorithm implements MaskAlgorithm<Object,
}
private Integer createFirstN(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfig(props, FIRST_N, getType());
+ MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props, FIRST_N, this);
return Integer.parseInt(props.getProperty(FIRST_N));
}
private Integer createLastM(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfig(props, LAST_M, getType());
+ MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props, LAST_M, this);
return Integer.parseInt(props.getProperty(LAST_M));
}
private Character createReplaceChar(final Properties props) {
- MaskAlgorithmPropsChecker.checkSingleCharConfig(props, REPLACE_CHAR, getType());
+ MaskAlgorithmPropsChecker.checkSingleCharConfiguration(props, REPLACE_CHAR, this);
return props.getProperty(REPLACE_CHAR).charAt(0);
}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java
index 95e07deb7c3..22bd1730a6b 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.mask.algorithm.cover;
import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
-import org.apache.shardingsphere.mask.exception.algorithm.MaskAlgorithmInitializationException;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import java.util.Properties;
@@ -47,21 +47,21 @@ public final class KeepFromXToYMaskAlgorithm implements MaskAlgorithm<Object, St
fromX = createFromX(props);
toY = createToY(props);
replaceChar = createReplaceChar(props);
- ShardingSpherePreconditions.checkState(fromX <= toY, () -> new MaskAlgorithmInitializationException(getType(), "fromX must be less than or equal to toY"));
+ ShardingSpherePreconditions.checkState(fromX <= toY, () -> new AlgorithmInitializationException(this, "fromX must be less than or equal to toY"));
}
private Integer createFromX(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfig(props, FROM_X, getType());
+ MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props, FROM_X, this);
return Integer.parseInt(props.getProperty(FROM_X));
}
private Integer createToY(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfig(props, TO_Y, getType());
+ MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props, TO_Y, this);
return Integer.parseInt(props.getProperty(TO_Y));
}
private Character createReplaceChar(final Properties props) {
- MaskAlgorithmPropsChecker.checkSingleCharConfig(props, REPLACE_CHAR, getType());
+ MaskAlgorithmPropsChecker.checkSingleCharConfiguration(props, REPLACE_CHAR, this);
return props.getProperty(REPLACE_CHAR).charAt(0);
}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java
index 423dd6c44a0..f2317acf0b2 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java
@@ -43,12 +43,12 @@ public final class MaskAfterSpecialCharsAlgorithm implements MaskAlgorithm<Objec
}
private String createSpecialChars(final Properties props) {
- MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(props, SPECIAL_CHARS, getType());
+ MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(props, SPECIAL_CHARS, this);
return props.getProperty(SPECIAL_CHARS);
}
private Character createReplaceChar(final Properties props) {
- MaskAlgorithmPropsChecker.checkSingleCharConfig(props, REPLACE_CHAR, getType());
+ MaskAlgorithmPropsChecker.checkSingleCharConfiguration(props, REPLACE_CHAR, this);
return props.getProperty(REPLACE_CHAR).charAt(0);
}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java
index 48e01b22afb..44ecf231ff9 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java
@@ -43,12 +43,12 @@ public final class MaskBeforeSpecialCharsAlgorithm implements MaskAlgorithm<Obje
}
private String createSpecialChars(final Properties props) {
- MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(props, SPECIAL_CHARS, getType());
+ MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(props, SPECIAL_CHARS, this);
return props.getProperty(SPECIAL_CHARS);
}
private Character createReplaceChar(final Properties props) {
- MaskAlgorithmPropsChecker.checkSingleCharConfig(props, REPLACE_CHAR, getType());
+ MaskAlgorithmPropsChecker.checkSingleCharConfiguration(props, REPLACE_CHAR, this);
return props.getProperty(REPLACE_CHAR).charAt(0);
}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithm.java
index b463a39c994..069dd896db5 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithm.java
@@ -48,17 +48,17 @@ public final class MaskFirstNLastMMaskAlgorithm implements MaskAlgorithm<Object,
}
private Integer createFirstN(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfig(props, FIRST_N, getType());
+ MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props, FIRST_N, this);
return Integer.parseInt(props.getProperty(FIRST_N));
}
private Integer createLastM(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfig(props, LAST_M, getType());
+ MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props, LAST_M, this);
return Integer.parseInt(props.getProperty(LAST_M));
}
private Character createReplaceChar(final Properties props) {
- MaskAlgorithmPropsChecker.checkSingleCharConfig(props, REPLACE_CHAR, getType());
+ MaskAlgorithmPropsChecker.checkSingleCharConfiguration(props, REPLACE_CHAR, this);
return props.getProperty(REPLACE_CHAR).charAt(0);
}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java
index beae9f94b6e..db2fcf9a181 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.mask.algorithm.cover;
import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
-import org.apache.shardingsphere.mask.exception.algorithm.MaskAlgorithmInitializationException;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import java.util.Properties;
@@ -47,21 +47,21 @@ public final class MaskFromXToYMaskAlgorithm implements MaskAlgorithm<Object, St
fromX = createFromX(props);
toY = createToY(props);
replaceChar = createReplaceChar(props);
- ShardingSpherePreconditions.checkState(fromX <= toY, () -> new MaskAlgorithmInitializationException(getType(), "fromX must be less than or equal to toY"));
+ ShardingSpherePreconditions.checkState(fromX <= toY, () -> new AlgorithmInitializationException(this, "fromX must be less than or equal to toY"));
}
private Integer createFromX(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfig(props, FROM_X, getType());
+ MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props, FROM_X, this);
return Integer.parseInt(props.getProperty(FROM_X));
}
private Integer createToY(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfig(props, TO_Y, getType());
+ MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props, TO_Y, this);
return Integer.parseInt(props.getProperty(TO_Y));
}
private Character createReplaceChar(final Properties props) {
- MaskAlgorithmPropsChecker.checkSingleCharConfig(props, REPLACE_CHAR, getType());
+ MaskAlgorithmPropsChecker.checkSingleCharConfiguration(props, REPLACE_CHAR, this);
return props.getProperty(REPLACE_CHAR).charAt(0);
}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithm.java
index 0567762377f..39a18aa5d96 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithm.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.mask.algorithm.replace;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.mask.exception.algorithm.MaskAlgorithmInitializationException;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import java.security.SecureRandom;
@@ -65,11 +65,9 @@ public final class GenericTableRandomReplaceAlgorithm implements MaskAlgorithm<O
uppercaseLetterCodes = splitPropsToList(props.getProperty(UPPERCASE_LETTER_CODES, DEFAULT_UPPERCASE_LETTER_CODES));
lowercaseLetterCodes = splitPropsToList(props.getProperty(LOWERCASE_LETTER_CODES, DEFAULT_LOWERCASE_LETTER_CODES));
digitalCodes = splitPropsToList(props.getProperty(DIGITAL_CODES, DEFAULT_DIGITAL_CODES));
- ShardingSpherePreconditions.checkState(!digitalCodes.isEmpty(),
- () -> new MaskAlgorithmInitializationException(getType(), String.format("'%s' must be not empty", DIGITAL_CODES)));
+ ShardingSpherePreconditions.checkState(!digitalCodes.isEmpty(), () -> new AlgorithmInitializationException(this, String.format("'%s' must be not empty", DIGITAL_CODES)));
specialCodes = splitPropsToList(props.getProperty(SPECIAL_CODES, DEFAULT_SPECIAL_CODES));
- ShardingSpherePreconditions.checkState(!specialCodes.isEmpty(),
- () -> new MaskAlgorithmInitializationException(getType(), String.format("'%s' must be not empty", SPECIAL_CODES)));
+ ShardingSpherePreconditions.checkState(!specialCodes.isEmpty(), () -> new AlgorithmInitializationException(this, String.format("'%s' must be not empty", SPECIAL_CODES)));
}
private List<Character> splitPropsToList(final String props) {
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/exception/algorithm/MaskAlgorithmInitializationException.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/exception/algorithm/MaskAlgorithmInitializationException.java
deleted file mode 100644
index ba2696057ab..00000000000
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/exception/algorithm/MaskAlgorithmInitializationException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mask.exception.algorithm;
-
-import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.mask.exception.MaskSQLException;
-
-/**
- * Mask algorithm initialization exception.
- */
-public final class MaskAlgorithmInitializationException extends MaskSQLException {
-
- private static final long serialVersionUID = -2004166948563207100L;
-
- public MaskAlgorithmInitializationException(final String maskType, final String reason) {
- super(XOpenSQLState.GENERAL_ERROR, 80, "Mask algorithm `%s` initialization failed, reason is: %s.", maskType, reason);
- }
-}
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsCheckerTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsCheckerTest.java
index b7898fe61b1..4c5cb4cc47e 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsCheckerTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsCheckerTest.java
@@ -17,89 +17,98 @@
package org.apache.shardingsphere.mask.algorithm;
-import org.apache.shardingsphere.mask.exception.algorithm.MaskAlgorithmInitializationException;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
+import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
class MaskAlgorithmPropsCheckerTest {
@Test
void assertCheckSingleCharConfigWithLengthOne() {
- MaskAlgorithmPropsChecker.checkSingleCharConfig(PropertiesBuilder.build(new Property("singleChar", "1")), "singleChar", "maskType");
+ MaskAlgorithmPropsChecker.checkSingleCharConfiguration(PropertiesBuilder.build(new Property("singleChar", "1")), "singleChar", mockMaskAlgorithm());
}
@Test
void assertCheckSingleCharConfigWithEmptyString() {
- assertThrows(MaskAlgorithmInitializationException.class,
- () -> MaskAlgorithmPropsChecker.checkSingleCharConfig(PropertiesBuilder.build(new Property("singleChar", "")), "singleChar1", "maskType"));
+ assertThrows(AlgorithmInitializationException.class,
+ () -> MaskAlgorithmPropsChecker.checkSingleCharConfiguration(PropertiesBuilder.build(new Property("singleChar", "")), "singleChar1", mockMaskAlgorithm()));
}
@Test
void assertCheckSingleCharConfigWithDifferentKey() {
- assertThrows(MaskAlgorithmInitializationException.class,
- () -> MaskAlgorithmPropsChecker.checkSingleCharConfig(PropertiesBuilder.build(new Property("singleChar", "1")), "singleChar1", "maskType"));
+ assertThrows(AlgorithmInitializationException.class,
+ () -> MaskAlgorithmPropsChecker.checkSingleCharConfiguration(PropertiesBuilder.build(new Property("singleChar", "1")), "singleChar1", mockMaskAlgorithm()));
}
@Test
void assertCheckSingleCharConfigWithLengthMoreThanOne() {
- assertThrows(MaskAlgorithmInitializationException.class,
- () -> MaskAlgorithmPropsChecker.checkSingleCharConfig(PropertiesBuilder.build(new Property("singleChar", "123")), "singleChar", "maskType"));
+ assertThrows(AlgorithmInitializationException.class,
+ () -> MaskAlgorithmPropsChecker.checkSingleCharConfiguration(PropertiesBuilder.build(new Property("singleChar", "123")), "singleChar", mockMaskAlgorithm()));
}
@Test
void assertCheckSingleCharConfigWithNull() {
- assertThrows(MaskAlgorithmInitializationException.class, () -> MaskAlgorithmPropsChecker.checkSingleCharConfig(PropertiesBuilder.build(), "singleChar", "maskType"));
+ assertThrows(AlgorithmInitializationException.class, () -> MaskAlgorithmPropsChecker.checkSingleCharConfiguration(PropertiesBuilder.build(), "singleChar", mockMaskAlgorithm()));
}
@Test
void assertCheckAtLeastOneCharConfigWithLengthOne() {
- MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(PropertiesBuilder.build(new Property("AtLeastOneChar", "1")), "AtLeastOneChar", "maskType");
+ MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(PropertiesBuilder.build(new Property("AtLeastOneChar", "1")), "AtLeastOneChar", mockMaskAlgorithm());
}
@Test
void assertCheckAtLeastOneCharConfigWithLengthMoreThanOne() {
- MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(PropertiesBuilder.build(new Property("AtLeastOneChar", "1234")), "AtLeastOneChar", "maskType");
+ MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(PropertiesBuilder.build(new Property("AtLeastOneChar", "1234")), "AtLeastOneChar", mockMaskAlgorithm());
}
@Test
void assertCheckAtLeastOneCharConfigWithEmptyString() {
- assertThrows(MaskAlgorithmInitializationException.class,
- () -> MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(PropertiesBuilder.build(new Property("AtLeastOneChar", "")), "AtLeastOneChar", "maskType"));
+ assertThrows(AlgorithmInitializationException.class,
+ () -> MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(PropertiesBuilder.build(new Property("AtLeastOneChar", "")), "AtLeastOneChar", mockMaskAlgorithm()));
}
@Test
void assertCheckAtLeastOneCharConfigWithNull() {
- assertThrows(MaskAlgorithmInitializationException.class, () -> MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(PropertiesBuilder.build(), "AtLeastOneChar", "maskType"));
+ assertThrows(AlgorithmInitializationException.class, () -> MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(PropertiesBuilder.build(), "AtLeastOneChar", mockMaskAlgorithm()));
}
@Test
void assertCheckAtLeastOneCharConfigWithDifferentKey() {
- assertThrows(MaskAlgorithmInitializationException.class,
- () -> MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(PropertiesBuilder.build(new Property("singleChar", "123")), "AtLeastOneChar", "maskType"));
+ assertThrows(AlgorithmInitializationException.class,
+ () -> MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(PropertiesBuilder.build(new Property("singleChar", "123")), "AtLeastOneChar", mockMaskAlgorithm()));
}
@Test
void assertCheckIntegerTypeConfigWithInteger() {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfig(PropertiesBuilder.build(new Property("integerTypeConfigKey", "123")), "integerTypeConfigKey", "maskType");
+ MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(PropertiesBuilder.build(new Property("integerTypeConfigKey", "123")), "integerTypeConfigKey", mockMaskAlgorithm());
}
@Test
void assertCheckIntegerTypeConfigWithDifferentKey() {
- assertThrows(MaskAlgorithmInitializationException.class,
- () -> MaskAlgorithmPropsChecker.checkPositiveIntegerConfig(PropertiesBuilder.build(new Property("integerTypeConfigKey", "123")), "integerTypeConfigKey1", "maskType"));
+ assertThrows(AlgorithmInitializationException.class,
+ () -> MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(PropertiesBuilder.build(new Property("integerTypeConfigKey", "123")), "integerTypeConfigKey1", mockMaskAlgorithm()));
}
@Test
void assertCheckIntegerTypeConfigWithNotInteger() {
- assertThrows(MaskAlgorithmInitializationException.class,
- () -> MaskAlgorithmPropsChecker.checkPositiveIntegerConfig(PropertiesBuilder.build(new Property("integerTypeConfigKey", "123abc")), "integerTypeConfigKey", "maskType"));
+ assertThrows(AlgorithmInitializationException.class, () -> MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(
+ PropertiesBuilder.build(new Property("integerTypeConfigKey", "123abc")), "integerTypeConfigKey", mockMaskAlgorithm()));
}
@Test
void assertCheckIntegerTypeConfigWithNull() {
- assertThrows(MaskAlgorithmInitializationException.class, () -> MaskAlgorithmPropsChecker.checkPositiveIntegerConfig(PropertiesBuilder.build(), "integerTypeConfigKey", "maskType"));
+ assertThrows(AlgorithmInitializationException.class, () -> MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(PropertiesBuilder.build(), "integerTypeConfigKey", mockMaskAlgorithm()));
+ }
+
+ private MaskAlgorithm<?, ?> mockMaskAlgorithm() {
+ MaskAlgorithm<?, ?> result = mock(MaskAlgorithm.class);
+ when(result.getType()).thenReturn("maskType");
+ return result;
}
}
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithmTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithmTest.java
index 8210aadeb0c..7362486d137 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithmTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithmTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.mask.algorithm.cover;
-import org.apache.shardingsphere.mask.exception.algorithm.MaskAlgorithmInitializationException;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.api.BeforeEach;
@@ -85,19 +85,19 @@ class KeepFirstNLastMMaskAlgorithmTest {
@Test
void assertInitWhenFirstNIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new KeepFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("first-n", ""), new Property("last-m", "5"), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenLastMIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new KeepFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("first-n", "2"), new Property("last-m", ""), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenReplaceCharIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new KeepFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("first-n", "2"), new Property("last-m", "5"), new Property("replace-char", ""))));
}
}
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithmTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithmTest.java
index 98ba9c68cb0..fc6fe69ac8f 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithmTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithmTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.mask.algorithm.cover;
-import org.apache.shardingsphere.mask.exception.algorithm.MaskAlgorithmInitializationException;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.api.BeforeEach;
@@ -73,37 +73,37 @@ class KeepFromXToYMaskAlgorithmTest {
@Test
void assertInitWhenFromXIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new KeepFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("from-x", ""), new Property("to-y", "5"), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenToYIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new KeepFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("from-x", "2"), new Property("to-y", ""), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenReplaceCharIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new KeepFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("from-x", "2"), new Property("to-y", "5"), new Property("replace-char", ""))));
}
@Test
void assertInitWhenFromXIsNotPositive() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("from-x", "-3"), new Property("to-y", "5"), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenToYIsNotPositive() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("from-x", "3"), new Property("to-y", "-5"), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenFromXGreaterThanToY() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new KeepFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("from-x", "5"), new Property("to-y", "2"), new Property("replace-char", ""))));
}
}
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithmTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithmTest.java
index e881ec20fcf..f57468b3284 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithmTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithmTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.mask.algorithm.cover;
-import org.apache.shardingsphere.mask.exception.algorithm.MaskAlgorithmInitializationException;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.api.BeforeEach;
@@ -66,24 +66,24 @@ class MaskAfterSpecialCharsAlgorithmTest {
@Test
void assertInitWhenSpecialCharsIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskBeforeSpecialCharsAlgorithm().init(PropertiesBuilder.build(new Property("special-chars", ""), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenReplaceCharIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskBeforeSpecialCharsAlgorithm().init(PropertiesBuilder.build(new Property("special-chars", "d1"), new Property("replace-char", ""))));
}
@Test
void assertInitWhenReplaceCharIsMissing() {
- assertThrows(MaskAlgorithmInitializationException.class, () -> new MaskBeforeSpecialCharsAlgorithm().init(PropertiesBuilder.build(new Property("special-chars", "d1"))));
+ assertThrows(AlgorithmInitializationException.class, () -> new MaskBeforeSpecialCharsAlgorithm().init(PropertiesBuilder.build(new Property("special-chars", "d1"))));
}
@Test
void assertInitWhenPropertiesAreEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class, () -> new MaskBeforeSpecialCharsAlgorithm().init(PropertiesBuilder.build()));
+ assertThrows(AlgorithmInitializationException.class, () -> new MaskBeforeSpecialCharsAlgorithm().init(PropertiesBuilder.build()));
}
@Test
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithmTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithmTest.java
index 11ffa3df49c..f5212c827b5 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithmTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithmTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.mask.algorithm.cover;
-import org.apache.shardingsphere.mask.exception.algorithm.MaskAlgorithmInitializationException;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.api.BeforeEach;
@@ -65,13 +65,13 @@ class MaskBeforeSpecialCharsAlgorithmTest {
@Test
void assertInitWhenSpecialCharsIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskBeforeSpecialCharsAlgorithm().init(PropertiesBuilder.build(new Property("special-chars", ""), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenReplaceCharIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskBeforeSpecialCharsAlgorithm().init(PropertiesBuilder.build(new Property("special-chars", "d1"), new Property("replace-char", ""))));
}
}
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithmTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithmTest.java
index 6b0ecd4afe7..4f38f23add8 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithmTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithmTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.mask.algorithm.cover;
-import org.apache.shardingsphere.mask.exception.algorithm.MaskAlgorithmInitializationException;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.api.BeforeEach;
@@ -85,19 +85,19 @@ class MaskFirstNLastMMaskAlgorithmTest {
@Test
void assertInitWhenFirstNIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("first-n", ""), new Property("last-m", "5"), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenLastMIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("first-n", "3"), new Property("last-m", ""), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenReplaceCharIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("first-n", "3"), new Property("last-m", "5"), new Property("replace-char", ""))));
}
}
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithmTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithmTest.java
index 1475d990260..ad4785d34ec 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithmTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithmTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.mask.algorithm.cover;
-import org.apache.shardingsphere.mask.exception.algorithm.MaskAlgorithmInitializationException;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.api.BeforeEach;
@@ -73,37 +73,37 @@ class MaskFromXToYMaskAlgorithmTest {
@Test
void assertInitWhenFromXIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskFromXToYMaskAlgorithm().init(PropertiesBuilder.build(new Property("from-x", ""), new Property("to-y", "5"), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenToYIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskFromXToYMaskAlgorithm().init(PropertiesBuilder.build(new Property("from-x", "3"), new Property("to-y", ""), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenReplaceCharIsEmpty() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskFromXToYMaskAlgorithm().init(PropertiesBuilder.build(new Property("from-x", "3"), new Property("to-y", "5"), new Property("replace-char", ""))));
}
@Test
void assertInitWhenFromXIsNotPositive() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("from-x", "-3"), new Property("to-y", "5"), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenToYIsNotPositive() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new MaskFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("from-x", "3"), new Property("to-y", "-5"), new Property("replace-char", "*"))));
}
@Test
void assertInitWhenFromXGreaterThanToY() {
- assertThrows(MaskAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> new KeepFirstNLastMMaskAlgorithm().init(PropertiesBuilder.build(new Property("from-x", "5"), new Property("to-y", "2"), new Property("replace-char", ""))));
}
}
diff --git a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
index a78e137bb45..977eb96f049 100644
--- a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
+++ b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.readwritesplitting.checker;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import org.apache.shardingsphere.infra.algorithm.loadbalancer.core.exception.LoadBalanceAlgorithmInitializationException;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.config.rule.checker.RuleConfigurationChecker;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes;
@@ -96,7 +96,7 @@ class ReadwriteSplittingRuleConfigurationCheckerTest {
AlgorithmConfiguration algorithm = new AlgorithmConfiguration("WEIGHT", PropertiesBuilder.build(new Property("read_ds_2", "1"), new Property("read_ds_1", "2")));
when(config.getLoadBalancers()).thenReturn(Collections.singletonMap("weight_ds", algorithm));
RuleConfigurationChecker checker = OrderedSPILoader.getServicesByClass(RuleConfigurationChecker.class, Collections.singleton(config.getClass())).get(config.getClass());
- assertThrows(LoadBalanceAlgorithmInitializationException.class, () -> checker.check("test", config, mockDataSources(), Collections.emptyList()));
+ assertThrows(AlgorithmInitializationException.class, () -> checker.check("test", config, mockDataSources(), Collections.emptyList()));
}
@SuppressWarnings({"rawtypes", "unchecked"})
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/AbstractColumnMatchedShadowAlgorithm.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/AbstractColumnMatchedShadowAlgorithm.java
index 2e9f67c0f42..6da79e86634 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/AbstractColumnMatchedShadowAlgorithm.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/AbstractColumnMatchedShadowAlgorithm.java
@@ -18,12 +18,12 @@
package org.apache.shardingsphere.shadow.algorithm.shadow.column;
import lombok.Getter;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.shadow.algorithm.shadow.validator.ShadowValueValidator;
import org.apache.shardingsphere.shadow.api.shadow.ShadowOperationType;
import org.apache.shardingsphere.shadow.api.shadow.column.ColumnShadowAlgorithm;
import org.apache.shardingsphere.shadow.api.shadow.column.PreciseColumnShadowValue;
-import org.apache.shardingsphere.shadow.exception.algorithm.ShadowAlgorithmInitializationException;
import java.util.Optional;
import java.util.Properties;
@@ -50,16 +50,16 @@ public abstract class AbstractColumnMatchedShadowAlgorithm implements ColumnShad
private String getShadowColumn(final Properties props) {
String result = props.getProperty(COLUMN_PROPS_KEY);
- ShardingSpherePreconditions.checkNotNull(result, () -> new ShadowAlgorithmInitializationException(getType(), "Column shadow algorithm column cannot be null"));
+ ShardingSpherePreconditions.checkNotNull(result, () -> new AlgorithmInitializationException(this, "Column shadow algorithm column cannot be null"));
return result;
}
private ShadowOperationType getShadowOperationType(final Properties props) {
String operationType = props.getProperty(OPERATION_PROPS_KEY);
- ShardingSpherePreconditions.checkNotNull(operationType, () -> new ShadowAlgorithmInitializationException(getType(), "Column shadow algorithm operation cannot be null"));
+ ShardingSpherePreconditions.checkNotNull(operationType, () -> new AlgorithmInitializationException(this, "Column shadow algorithm operation cannot be null"));
Optional<ShadowOperationType> result = ShadowOperationType.contains(operationType);
ShardingSpherePreconditions.checkState(result.isPresent(),
- () -> new ShadowAlgorithmInitializationException(getType(), "Column shadow algorithm operation must be one of [select, insert, update, delete]"));
+ () -> new AlgorithmInitializationException(this, "Column shadow algorithm operation must be one of [select, insert, update, delete]"));
return result.get();
}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchedShadowAlgorithm.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchedShadowAlgorithm.java
index e3954adf022..d5e1c062b86 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchedShadowAlgorithm.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchedShadowAlgorithm.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.shadow.algorithm.shadow.column;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.shadow.exception.algorithm.ShadowAlgorithmInitializationException;
import java.util.Properties;
import java.util.regex.Pattern;
@@ -40,7 +40,7 @@ public final class ColumnRegexMatchedShadowAlgorithm extends AbstractColumnMatch
private Pattern getRegex(final Properties props) {
String regex = props.getProperty(REGEX_PROPS_KEY);
- ShardingSpherePreconditions.checkNotNull(regex, () -> new ShadowAlgorithmInitializationException(getType(), "Column regex match shadow algorithm regex cannot be null."));
+ ShardingSpherePreconditions.checkNotNull(regex, () -> new AlgorithmInitializationException(this, "Column regex match shadow algorithm regex cannot be null."));
return Pattern.compile(regex);
}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchedShadowAlgorithm.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchedShadowAlgorithm.java
index 860c86d0fda..318f6a869ca 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchedShadowAlgorithm.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchedShadowAlgorithm.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.shadow.algorithm.shadow.column;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.shadow.exception.algorithm.ShadowAlgorithmInitializationException;
import java.util.Properties;
@@ -39,7 +39,7 @@ public final class ColumnValueMatchedShadowAlgorithm extends AbstractColumnMatch
private String getShadowValue(final Properties props) {
String result = props.getProperty(VALUE_PROPS_KEY);
- ShardingSpherePreconditions.checkNotNull(result, () -> new ShadowAlgorithmInitializationException(getType(), "Column value match shadow algorithm value cannot be null."));
+ ShardingSpherePreconditions.checkNotNull(result, () -> new AlgorithmInitializationException(this, "Column value match shadow algorithm value cannot be null."));
return result;
}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/exception/algorithm/ShadowAlgorithmInitializationException.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/exception/algorithm/ShadowAlgorithmInitializationException.java
deleted file mode 100644
index dbbd164dee1..00000000000
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/exception/algorithm/ShadowAlgorithmInitializationException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.shadow.exception.algorithm;
-
-import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.shadow.exception.ShadowSQLException;
-
-/**
- * Shadow algorithm initialization exception.
- */
-public final class ShadowAlgorithmInitializationException extends ShadowSQLException {
-
- private static final long serialVersionUID = 3417656634861557424L;
-
- public ShadowAlgorithmInitializationException(final String shadowType, final String reason) {
- super(XOpenSQLState.GENERAL_ERROR, 80, "Shadow algorithm `%s` initialization failed, reason is: %s.", shadowType, reason);
- }
-}
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchShadowAlgorithmTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchShadowAlgorithmTest.java
index b1695c3d6a8..85e952df4d2 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchShadowAlgorithmTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchShadowAlgorithmTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.shadow.algorithm.shadow.column;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.shadow.exception.algorithm.ShadowAlgorithmInitializationException;
import org.apache.shardingsphere.shadow.exception.data.UnsupportedShadowColumnTypeException;
import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
@@ -26,8 +26,8 @@ import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
class ColumnRegexMatchShadowAlgorithmTest {
@@ -53,13 +53,13 @@ class ColumnRegexMatchShadowAlgorithmTest {
@Test
void assertPropertiesWithoutColumn() {
- assertThrows(ShadowAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> TypedSPILoader.getService(ShadowAlgorithm.class, "REGEX_MATCH", PropertiesBuilder.build(new Property("operation", "insert"), new Property("value", "[1]"))));
}
@Test
void assertPropertiesWithWrongOperation() {
- assertThrows(ShadowAlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShadowAlgorithm.class, "REGEX_MATCH",
+ assertThrows(AlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShadowAlgorithm.class, "REGEX_MATCH",
PropertiesBuilder.build(new Property("column", SHADOW_COLUMN), new Property("operation", "wrong"), new Property("value", "[1]"))));
}
}
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithmTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithmTest.java
index f7e66529a79..8715d39f3a2 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithmTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithmTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.shadow.algorithm.shadow.column;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.shadow.exception.algorithm.ShadowAlgorithmInitializationException;
import org.apache.shardingsphere.shadow.exception.data.UnsupportedShadowColumnTypeException;
import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
@@ -26,8 +26,8 @@ import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
class ColumnValueMatchShadowAlgorithmTest {
@@ -53,13 +53,13 @@ class ColumnValueMatchShadowAlgorithmTest {
@Test
void assertPropertiesWithoutColumn() {
- assertThrows(ShadowAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> TypedSPILoader.getService(ShadowAlgorithm.class, "VALUE_MATCH", PropertiesBuilder.build(new Property("operation", "insert"), new Property("value", "1"))));
}
@Test
void assertPropertiesWithWrongOperation() {
- assertThrows(ShadowAlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShadowAlgorithm.class, "VALUE_MATCH",
+ assertThrows(AlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShadowAlgorithm.class, "VALUE_MATCH",
PropertiesBuilder.build(new Property("column", SHADOW_COLUMN), new Property("operation", "wrong"), new Property("value", "1"))));
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java
index 7c940884443..a7c0328f962 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.sharding.algorithm.sharding.classbased;
import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
@@ -26,7 +27,6 @@ import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import java.util.Arrays;
import java.util.Collection;
@@ -62,17 +62,17 @@ public final class ClassBasedShardingAlgorithm implements StandardShardingAlgori
private ClassBasedShardingAlgorithmStrategyType getStrategy(final Properties props) {
String strategy = props.getProperty(STRATEGY_KEY);
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(strategy),
- () -> new ShardingAlgorithmInitializationException(getType(), String.format("Properties `%s` can not be null or empty when uses class based sharding strategy", STRATEGY_KEY)));
+ () -> new AlgorithmInitializationException(this, "Properties `%s` can not be null or empty when uses class based sharding strategy", STRATEGY_KEY));
String shardingAlgorithmStrategyType = strategy.toUpperCase().trim();
ShardingSpherePreconditions.checkState(
Arrays.stream(ClassBasedShardingAlgorithmStrategyType.values()).anyMatch(each -> each.name().equals(shardingAlgorithmStrategyType)),
- () -> new ShardingAlgorithmInitializationException(getType(), String.format("Unsupported sharding strategy `%s`", strategy)));
+ () -> new AlgorithmInitializationException(this, "Unsupported sharding strategy `%s`", strategy));
return ClassBasedShardingAlgorithmStrategyType.valueOf(shardingAlgorithmStrategyType);
}
private String getAlgorithmClassName(final Properties props) {
String result = props.getProperty(ALGORITHM_CLASS_NAME_KEY);
- ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(result), () -> new ShardingAlgorithmInitializationException(getType(), "Sharding algorithm class name can not be null or empty"));
+ ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(result), () -> new AlgorithmInitializationException(this, "Sharding algorithm class name can not be null or empty"));
return result;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java
index 9eaa07287b0..e53909424ad 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.datetime;
import com.google.common.collect.Range;
import lombok.Getter;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.util.datetime.DateTimeFormatterFactory;
import org.apache.shardingsphere.sharding.algorithm.sharding.ShardingAutoTableAlgorithmUtils;
@@ -26,7 +27,6 @@ import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorith
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.exception.data.InvalidDatetimeFormatException;
import org.apache.shardingsphere.sharding.exception.data.NullShardingValueException;
@@ -66,7 +66,7 @@ public final class AutoIntervalShardingAlgorithm implements StandardShardingAlgo
private LocalDateTime getDateTime(final Properties props) {
String value = props.getProperty(DATE_TIME_LOWER_KEY);
- ShardingSpherePreconditions.checkNotNull(value, () -> new ShardingAlgorithmInitializationException(getType(), String.format("%s cannot be null.", DATE_TIME_LOWER_KEY)));
+ ShardingSpherePreconditions.checkNotNull(value, () -> new AlgorithmInitializationException(this, String.format("%s cannot be null.", DATE_TIME_LOWER_KEY)));
try {
return LocalDateTime.parse(value, DateTimeFormatterFactory.getStandardFormatter());
} catch (final DateTimeParseException ignored) {
@@ -75,8 +75,7 @@ public final class AutoIntervalShardingAlgorithm implements StandardShardingAlgo
}
private long getShardingSeconds(final Properties props) {
- ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_SECONDS_KEY),
- () -> new ShardingAlgorithmInitializationException(getType(), String.format("%s cannot be null.", SHARDING_SECONDS_KEY)));
+ ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_SECONDS_KEY), () -> new AlgorithmInitializationException(this, String.format("%s cannot be null.", SHARDING_SECONDS_KEY)));
return Long.parseLong(props.getProperty(SHARDING_SECONDS_KEY));
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
index 321fcb98bbf..03f3b7d5ba0 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
@@ -20,12 +20,12 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.datetime;
import com.google.common.base.Strings;
import com.google.common.collect.BoundType;
import com.google.common.collect.Range;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.exception.data.InvalidDatetimeFormatException;
import org.apache.shardingsphere.sharding.exception.data.NullShardingValueException;
@@ -96,13 +96,13 @@ public final class IntervalShardingAlgorithm implements StandardShardingAlgorith
private String getDateTimePattern(final Properties props) {
ShardingSpherePreconditions.checkState(props.containsKey(DATE_TIME_PATTERN_KEY),
- () -> new ShardingAlgorithmInitializationException(getType(), String.format("%s can not be null", DATE_TIME_PATTERN_KEY)));
+ () -> new AlgorithmInitializationException(this, String.format("%s can not be null", DATE_TIME_PATTERN_KEY)));
return props.getProperty(DATE_TIME_PATTERN_KEY);
}
private TemporalAccessor getDateTimeLower(final Properties props, final String dateTimePattern) {
ShardingSpherePreconditions.checkState(props.containsKey(DATE_TIME_LOWER_KEY),
- () -> new ShardingAlgorithmInitializationException(getType(), String.format("%s can not be null.", DATE_TIME_LOWER_KEY)));
+ () -> new AlgorithmInitializationException(this, String.format("%s can not be null.", DATE_TIME_LOWER_KEY)));
return getDateTime(DATE_TIME_LOWER_KEY, props.getProperty(DATE_TIME_LOWER_KEY), dateTimePattern);
}
@@ -121,7 +121,7 @@ public final class IntervalShardingAlgorithm implements StandardShardingAlgorith
private DateTimeFormatter getTableSuffixPattern(final Properties props) {
String suffix = props.getProperty(SHARDING_SUFFIX_FORMAT_KEY);
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(suffix),
- () -> new ShardingAlgorithmInitializationException(getType(), String.format("%s can not be null or empty.", SHARDING_SUFFIX_FORMAT_KEY)));
+ () -> new AlgorithmInitializationException(this, String.format("%s can not be null or empty.", SHARDING_SUFFIX_FORMAT_KEY)));
return DateTimeFormatter.ofPattern(suffix);
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
index 61461842b0c..eee492b9007 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
@@ -17,11 +17,11 @@
package org.apache.shardingsphere.sharding.algorithm.sharding.hint;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.exception.data.NullShardingValueException;
import java.util.Collection;
@@ -50,7 +50,7 @@ public final class HintInlineShardingAlgorithm implements HintShardingAlgorithm<
private String getAlgorithmExpression(final Properties props) {
String algorithmExpression = props.getProperty(ALGORITHM_EXPRESSION_KEY, DEFAULT_ALGORITHM_EXPRESSION);
- ShardingSpherePreconditions.checkNotNull(algorithmExpression, () -> new ShardingAlgorithmInitializationException(getType(), "Inline sharding algorithm expression can not be null."));
+ ShardingSpherePreconditions.checkNotNull(algorithmExpression, () -> new AlgorithmInitializationException(this, "Inline sharding algorithm expression can not be null."));
return InlineExpressionParserFactory.newInstance(algorithmExpression.trim()).handlePlaceHolder();
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithm.java
index 130c8fcfe2c..fac2537c667 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithm.java
@@ -18,13 +18,13 @@
package org.apache.shardingsphere.sharding.algorithm.sharding.inline;
import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
import org.apache.shardingsphere.sharding.exception.algorithm.sharding.MismatchedComplexInlineShardingAlgorithmColumnAndValueSizeException;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.exception.data.NullShardingValueException;
import java.util.Arrays;
@@ -63,8 +63,7 @@ public final class ComplexInlineShardingAlgorithm implements ComplexKeysSharding
private String getAlgorithmExpression(final Properties props) {
String algorithmExpression = props.getProperty(ALGORITHM_EXPRESSION_KEY);
- ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(algorithmExpression),
- () -> new ShardingAlgorithmInitializationException(getType(), "Inline sharding algorithm expression can not be null."));
+ ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(algorithmExpression), () -> new AlgorithmInitializationException(this, "Inline sharding algorithm expression can not be null."));
return InlineExpressionParserFactory.newInstance(algorithmExpression.trim()).handlePlaceHolder();
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
index 22b81020cb1..a4aa860278e 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.inline;
import com.google.common.base.Strings;
import groovy.lang.MissingMethodException;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
@@ -26,7 +27,6 @@ import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingV
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import org.apache.shardingsphere.sharding.exception.algorithm.sharding.MismatchedInlineShardingAlgorithmExpressionAndColumnException;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.exception.data.NullShardingValueException;
import java.util.Collection;
@@ -56,8 +56,7 @@ public final class InlineShardingAlgorithm implements StandardShardingAlgorithm<
private String getAlgorithmExpression(final Properties props) {
String expression = props.getProperty(ALGORITHM_EXPRESSION_KEY);
- ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(expression),
- () -> new ShardingAlgorithmInitializationException(getType(), "Inline sharding algorithm expression cannot be null or empty"));
+ ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(expression), () -> new AlgorithmInitializationException(this, "Inline sharding algorithm expression cannot be null or empty"));
return InlineExpressionParserFactory.newInstance(expression.trim()).handlePlaceHolder();
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
index a92bfe4f6d1..c71344d9d8c 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
@@ -17,13 +17,13 @@
package org.apache.shardingsphere.sharding.algorithm.sharding.mod;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.sharding.algorithm.sharding.ShardingAutoTableAlgorithmUtils;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.exception.data.NullShardingValueException;
import java.util.Collection;
@@ -44,9 +44,9 @@ public final class HashModShardingAlgorithm implements StandardShardingAlgorithm
}
private int getShardingCount(final Properties props) {
- ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_COUNT_KEY), () -> new ShardingAlgorithmInitializationException(getType(), "Sharding count cannot be null."));
+ ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_COUNT_KEY), () -> new AlgorithmInitializationException(this, "Sharding count cannot be null."));
int result = Integer.parseInt(String.valueOf(props.getProperty(SHARDING_COUNT_KEY)));
- ShardingSpherePreconditions.checkState(result > 0, () -> new ShardingAlgorithmInitializationException(getType(), "Sharding count must be a positive integer."));
+ ShardingSpherePreconditions.checkState(result > 0, () -> new AlgorithmInitializationException(this, "Sharding count must be a positive integer."));
return result;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
index 6b516a61569..ab18d88ca80 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
@@ -17,13 +17,13 @@
package org.apache.shardingsphere.sharding.algorithm.sharding.mod;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.sharding.algorithm.sharding.ShardingAutoTableAlgorithmUtils;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.exception.data.NullShardingValueException;
import org.apache.shardingsphere.sharding.exception.data.ShardingValueOffsetException;
@@ -65,21 +65,21 @@ public final class ModShardingAlgorithm implements StandardShardingAlgorithm<Com
}
private int getShardingCount(final Properties props) {
- ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_COUNT_KEY), () -> new ShardingAlgorithmInitializationException(getType(), "Sharding count can not be null."));
+ ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_COUNT_KEY), () -> new AlgorithmInitializationException(this, "Sharding count can not be null."));
int result = Integer.parseInt(String.valueOf(props.getProperty(SHARDING_COUNT_KEY)));
- ShardingSpherePreconditions.checkState(result > 0, () -> new ShardingAlgorithmInitializationException(getType(), "Sharding count must be a positive integer."));
+ ShardingSpherePreconditions.checkState(result > 0, () -> new AlgorithmInitializationException(this, "Sharding count must be a positive integer."));
return result;
}
private int getStartOffset(final Properties props) {
int result = Integer.parseInt(String.valueOf(props.getProperty(START_OFFSET_INDEX_KEY, "0")));
- ShardingSpherePreconditions.checkState(result >= 0, () -> new ShardingAlgorithmInitializationException(getType(), "Start offset can not be less than 0."));
+ ShardingSpherePreconditions.checkState(result >= 0, () -> new AlgorithmInitializationException(this, "Start offset can not be less than 0."));
return result;
}
private int getStopOffset(final Properties props) {
int result = Integer.parseInt(String.valueOf(props.getProperty(STOP_OFFSET_INDEX_KEY, "0")));
- ShardingSpherePreconditions.checkState(result >= 0, () -> new ShardingAlgorithmInitializationException(getType(), "Stop offset can not be less than 0."));
+ ShardingSpherePreconditions.checkState(result >= 0, () -> new AlgorithmInitializationException(this, "Stop offset can not be less than 0."));
return result;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
index b43fcedbbf5..53949406561 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.range;
import com.google.common.base.Splitter;
import com.google.common.collect.Range;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import java.util.HashMap;
import java.util.List;
@@ -38,10 +38,10 @@ public final class BoundaryBasedRangeShardingAlgorithm extends AbstractRangeShar
@Override
public Map<Integer, Range<Comparable<?>>> calculatePartitionRange(final Properties props) {
- ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_RANGES_KEY), () -> new ShardingAlgorithmInitializationException(getType(), "Sharding ranges cannot be null."));
+ ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_RANGES_KEY), () -> new AlgorithmInitializationException(this, "Sharding ranges cannot be null."));
List<Long> partitionRanges = Splitter.on(",").trimResults().splitToList(props.getProperty(SHARDING_RANGES_KEY)).stream()
.map(this::parseLong).filter(Objects::nonNull).sorted().collect(Collectors.toList());
- ShardingSpherePreconditions.checkState(!partitionRanges.isEmpty(), () -> new ShardingAlgorithmInitializationException(getType(), "Sharding ranges can not be empty."));
+ ShardingSpherePreconditions.checkState(!partitionRanges.isEmpty(), () -> new AlgorithmInitializationException(this, "Sharding ranges can not be empty."));
Map<Integer, Range<Comparable<?>>> result = new HashMap<>(partitionRanges.size() + 1, 1F);
for (int i = 0; i < partitionRanges.size(); i++) {
Long rangeValue = partitionRanges.get(i);
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
index 731b5a427fa..7dc35710de5 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.range;
import com.google.common.collect.Range;
import com.google.common.math.LongMath;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import java.math.RoundingMode;
import java.util.HashMap;
@@ -40,13 +40,13 @@ public final class VolumeBasedRangeShardingAlgorithm extends AbstractRangeShardi
@Override
public Map<Integer, Range<Comparable<?>>> calculatePartitionRange(final Properties props) {
- ShardingSpherePreconditions.checkState(props.containsKey(RANGE_LOWER_KEY), () -> new ShardingAlgorithmInitializationException(getType(), "Lower range cannot be null."));
- ShardingSpherePreconditions.checkState(props.containsKey(RANGE_UPPER_KEY), () -> new ShardingAlgorithmInitializationException(getType(), "Upper range cannot be null."));
- ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_VOLUME_KEY), () -> new ShardingAlgorithmInitializationException(getType(), "Sharding volume cannot be null."));
+ ShardingSpherePreconditions.checkState(props.containsKey(RANGE_LOWER_KEY), () -> new AlgorithmInitializationException(this, "Lower range cannot be null."));
+ ShardingSpherePreconditions.checkState(props.containsKey(RANGE_UPPER_KEY), () -> new AlgorithmInitializationException(this, "Upper range cannot be null."));
+ ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_VOLUME_KEY), () -> new AlgorithmInitializationException(this, "Sharding volume cannot be null."));
long lower = Long.parseLong(props.getProperty(RANGE_LOWER_KEY));
long upper = Long.parseLong(props.getProperty(RANGE_UPPER_KEY));
long volume = Long.parseLong(props.getProperty(SHARDING_VOLUME_KEY));
- ShardingSpherePreconditions.checkState(upper - lower >= volume, () -> new ShardingAlgorithmInitializationException(getType(), "Range can not be smaller than volume."));
+ ShardingSpherePreconditions.checkState(upper - lower >= volume, () -> new AlgorithmInitializationException(this, "Range can not be smaller than volume."));
int partitionSize = Math.toIntExact(LongMath.divide(upper - lower, volume, RoundingMode.CEILING));
Map<Integer, Range<Comparable<?>>> result = new HashMap<>(partitionSize + 2, 1F);
result.put(0, Range.lessThan(lower));
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/ShardingAlgorithmInitializationException.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/ShardingAlgorithmInitializationException.java
deleted file mode 100644
index 163232bcd10..00000000000
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/ShardingAlgorithmInitializationException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sharding.exception.algorithm.sharding;
-
-import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
-
-/**
- * Sharding algorithm initialization exception.
- */
-public final class ShardingAlgorithmInitializationException extends ShardingSQLException {
-
- private static final long serialVersionUID = -2638422150430534412L;
-
- public ShardingAlgorithmInitializationException(final String shardingType, final String reason) {
- super(XOpenSQLState.GENERAL_ERROR, 83, "Sharding algorithm `%s` initialization failed, reason is: %s.", shardingType, reason);
- }
-}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
index 739912da655..f7bfe33d378 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
@@ -22,6 +22,7 @@ import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import lombok.Getter;
import org.apache.shardingsphere.infra.algorithm.core.context.AlgorithmSQLContext;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.algorithm.keygen.core.KeyGenerateAlgorithm;
import org.apache.shardingsphere.infra.algorithm.keygen.core.exception.GenerateKeyStrategyNotFoundException;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
@@ -34,8 +35,8 @@ import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.instance.InstanceContextAware;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
-import org.apache.shardingsphere.infra.rule.scope.DatabaseRule;
import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes;
+import org.apache.shardingsphere.infra.rule.scope.DatabaseRule;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -49,7 +50,6 @@ import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingS
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.cache.ShardingCache;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.exception.metadata.DuplicateSharingActualDataNodeException;
import org.apache.shardingsphere.sharding.exception.metadata.InvalidBindingTablesException;
import org.apache.shardingsphere.sharding.exception.metadata.ShardingTableRuleNotFoundException;
@@ -203,7 +203,7 @@ public final class ShardingRule implements DatabaseRule {
private void checkManualShardingAlgorithm(final String shardingAlgorithmName, final String logicTable) {
ShardingAlgorithm shardingAlgorithm = shardingAlgorithms.get(shardingAlgorithmName);
ShardingSpherePreconditions.checkState(!(shardingAlgorithm instanceof ShardingAutoTableAlgorithm),
- () -> new ShardingAlgorithmInitializationException(shardingAlgorithm.getType(), String.format("`%s` tables sharding configuration can not use auto sharding algorithm.", logicTable)));
+ () -> new AlgorithmInitializationException(shardingAlgorithm, "`%s` tables sharding configuration can not use auto sharding algorithm.", logicTable));
}
private Map<String, ShardingTable> createShardingAutoTables(final Collection<ShardingAutoTableRuleConfiguration> autoTableRuleConfigs,
@@ -221,7 +221,7 @@ public final class ShardingRule implements DatabaseRule {
private void checkAutoShardingAlgorithm(final String shardingAlgorithmName, final String logicTable) {
ShardingAlgorithm shardingAlgorithm = shardingAlgorithms.get(shardingAlgorithmName);
ShardingSpherePreconditions.checkState(shardingAlgorithm instanceof ShardingAutoTableAlgorithm,
- () -> new ShardingAlgorithmInitializationException(shardingAlgorithm.getType(), String.format("`%s` autoTables sharding configuration must use auto sharding algorithm.", logicTable)));
+ () -> new AlgorithmInitializationException(shardingAlgorithm, "`%s` autoTables sharding configuration must use auto sharding algorithm.", logicTable));
}
private String getDefaultGenerateKeyColumn(final KeyGenerateStrategyConfiguration defaultKeyGenerateStrategyConfig) {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmTest.java
index f12fb351eef..3a291578419 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.sharding.algorithm.sharding.classbased;
import com.google.common.collect.Range;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
@@ -25,7 +26,6 @@ import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmClassImplementationException;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.fixture.ClassBasedComplexKeysShardingAlgorithmFixture;
import org.apache.shardingsphere.sharding.fixture.ClassBasedHintShardingAlgorithmFixture;
import org.apache.shardingsphere.sharding.fixture.ClassBasedStandardShardingAlgorithmFixture;
@@ -45,24 +45,24 @@ class ClassBasedShardingAlgorithmTest {
@Test
void assertInitWithNullStrategy() {
- assertThrows(ShardingAlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShardingAlgorithm.class, "CLASS_BASED"));
+ assertThrows(AlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShardingAlgorithm.class, "CLASS_BASED"));
}
@Test
void assertInitWithWrongStrategy() {
- assertThrows(ShardingAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> TypedSPILoader.getService(ShardingAlgorithm.class, "CLASS_BASED", PropertiesBuilder.build(new Property("strategy", "wrong"))));
}
@Test
void assertInitWithNullClass() {
- assertThrows(ShardingAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> TypedSPILoader.getService(ShardingAlgorithm.class, "CLASS_BASED", PropertiesBuilder.build(new Property("strategy", "standard"))));
}
@Test
void assertInitWithEmptyClassName() {
- assertThrows(ShardingAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> TypedSPILoader.getService(ShardingAlgorithm.class, "CLASS_BASED", PropertiesBuilder.build(new Property("strategy", "standard"), new Property("algorithmClassName", ""))));
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithmTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithmTest.java
index 4d2f081167a..954cdab28cb 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithmTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithmTest.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.sharding.algorithm.sharding.inline;
import com.google.common.collect.Range;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
@@ -41,13 +41,13 @@ class ComplexInlineShardingAlgorithmTest {
@Test
void assertInitWithNullClass() {
- assertThrows(ShardingAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> TypedSPILoader.getService(ShardingAlgorithm.class, "COMPLEX_INLINE", PropertiesBuilder.build(new Property("wrong", ""))));
}
@Test
void assertInitWithEmptyClassName() {
- assertThrows(ShardingAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> TypedSPILoader.getService(ShardingAlgorithm.class, "COMPLEX_INLINE", PropertiesBuilder.build(new Property("algorithm-expression", ""))));
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java
index e3aa242c12b..1d9619450c3 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java
@@ -19,12 +19,12 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.inline;
import com.google.common.collect.Lists;
import com.google.common.collect.Range;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.exception.algorithm.sharding.MismatchedInlineShardingAlgorithmExpressionAndColumnException;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
@@ -64,13 +64,13 @@ class InlineShardingAlgorithmTest {
@Test
void assertInitWithNullClass() {
- assertThrows(ShardingAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> TypedSPILoader.getService(ShardingAlgorithm.class, "INLINE", PropertiesBuilder.build(new Property("wrong", ""))));
}
@Test
void assertInitWithEmptyClassName() {
- assertThrows(ShardingAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> TypedSPILoader.getService(ShardingAlgorithm.class, "INLINE", PropertiesBuilder.build(new Property("algorithm-expression", ""))));
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithmTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithmTest.java
index cb759dab79a..1c9d473226d 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithmTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithmTest.java
@@ -18,11 +18,11 @@
package org.apache.shardingsphere.sharding.algorithm.sharding.mod;
import com.google.common.collect.Range;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
@@ -65,6 +65,6 @@ class HashModShardingAlgorithmTest {
@Test
void assertRangeDoShardingWithWrongArgumentForShardingCount() {
Properties props = PropertiesBuilder.build(new Property("sharding-count", "0"));
- assertThrows(ShardingAlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShardingAlgorithm.class, "HASH_MOD", props));
+ assertThrows(AlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShardingAlgorithm.class, "HASH_MOD", props));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
index fa365e71616..dea9216ecb9 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
@@ -18,11 +18,11 @@
package org.apache.shardingsphere.sharding.algorithm.sharding.mod;
import com.google.common.collect.Range;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
@@ -34,8 +34,8 @@ import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
class ModShardingAlgorithmTest {
@@ -91,21 +91,21 @@ class ModShardingAlgorithmTest {
@Test
void assertRangeDoShardingWithWrongArgumentForShardingCount() {
- assertThrows(ShardingAlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShardingAlgorithm.class, "MOD", PropertiesBuilder.build(new Property("sharding-count", "0"))));
+ assertThrows(AlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShardingAlgorithm.class, "MOD", PropertiesBuilder.build(new Property("sharding-count", "0"))));
}
@Test
void assertRangeDoShardingWithWrongArgumentForStartOffset() {
Properties props = createZeroPaddingProperties();
props.setProperty("start-offset", "-1");
- assertThrows(ShardingAlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShardingAlgorithm.class, "MOD", props));
+ assertThrows(AlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShardingAlgorithm.class, "MOD", props));
}
@Test
void assertRangeDoShardingWithWrongArgumentForStopOffset() {
Properties props = createZeroPaddingProperties();
props.setProperty("stop-offset", "-1");
- assertThrows(ShardingAlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShardingAlgorithm.class, "MOD", props));
+ assertThrows(AlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShardingAlgorithm.class, "MOD", props));
}
private Properties createZeroPaddingProperties() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
index ae5277c8f80..489905fe24c 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.sharding.rule;
import org.apache.groovy.util.Maps;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.context.AlgorithmSQLContext;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.algorithm.keygen.core.exception.GenerateKeyStrategyNotFoundException;
import org.apache.shardingsphere.infra.algorithm.keygen.snowflake.SnowflakeKeyGenerateAlgorithm;
import org.apache.shardingsphere.infra.algorithm.keygen.uuid.UUIDKeyGenerateAlgorithm;
@@ -46,7 +47,6 @@ import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexSh
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.exception.metadata.DuplicateSharingActualDataNodeException;
import org.apache.shardingsphere.sharding.exception.metadata.InvalidBindingTablesException;
import org.apache.shardingsphere.sharding.exception.metadata.ShardingTableRuleNotFoundException;
@@ -121,7 +121,7 @@ class ShardingRuleTest {
ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();
ruleConfig.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "MOD"));
ruleConfig.getShardingAlgorithms().put("MOD", new AlgorithmConfiguration("MOD", PropertiesBuilder.build(new Property("sharding-count", "2"))));
- assertThrows(ShardingAlgorithmInitializationException.class, () -> new ShardingRule(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class)));
+ assertThrows(AlgorithmInitializationException.class, () -> new ShardingRule(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class)));
}
@Test
@@ -129,7 +129,7 @@ class ShardingRuleTest {
ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();
ruleConfig.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "MOD"));
ruleConfig.getShardingAlgorithms().put("MOD", new AlgorithmConfiguration("MOD", PropertiesBuilder.build(new Property("sharding-count", "2"))));
- assertThrows(ShardingAlgorithmInitializationException.class, () -> new ShardingRule(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class)));
+ assertThrows(AlgorithmInitializationException.class, () -> new ShardingRule(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class)));
}
@Test
@@ -139,7 +139,7 @@ class ShardingRuleTest {
tableRuleConfig.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "MOD"));
ruleConfig.getTables().add(tableRuleConfig);
ruleConfig.getShardingAlgorithms().put("MOD", new AlgorithmConfiguration("MOD", PropertiesBuilder.build(new Property("sharding-count", "2"))));
- assertThrows(ShardingAlgorithmInitializationException.class, () -> new ShardingRule(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class)));
+ assertThrows(AlgorithmInitializationException.class, () -> new ShardingRule(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class)));
}
@Test
@@ -149,7 +149,7 @@ class ShardingRuleTest {
tableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "MOD"));
ruleConfig.getTables().add(tableRuleConfig);
ruleConfig.getShardingAlgorithms().put("MOD", new AlgorithmConfiguration("MOD", PropertiesBuilder.build(new Property("sharding-count", "2"))));
- assertThrows(ShardingAlgorithmInitializationException.class, () -> new ShardingRule(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class)));
+ assertThrows(AlgorithmInitializationException.class, () -> new ShardingRule(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class)));
}
@Test
@@ -159,7 +159,7 @@ class ShardingRuleTest {
autoTableRuleConfig.setShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "INLINE"));
ruleConfig.getAutoTables().add(autoTableRuleConfig);
ruleConfig.getShardingAlgorithms().put("INLINE", new AlgorithmConfiguration("INLINE", PropertiesBuilder.build(new Property("algorithm-expression", "t_order_%{order_id % 2}"))));
- assertThrows(ShardingAlgorithmInitializationException.class, () -> new ShardingRule(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class)));
+ assertThrows(AlgorithmInitializationException.class, () -> new ShardingRule(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class)));
}
@Test
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/CoreAutoShardingAlgorithmFixture.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/CoreAutoShardingAlgorithmFixture.java
index 3203ccc73ab..a82f99864a1 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/CoreAutoShardingAlgorithmFixture.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/CoreAutoShardingAlgorithmFixture.java
@@ -18,13 +18,13 @@
package org.apache.shardingsphere.sharding.distsql.fixture.sharding;
import com.google.common.base.Preconditions;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.sharding.algorithm.sharding.ShardingAutoTableAlgorithmUtils;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
-import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import java.math.BigInteger;
import java.util.Collection;
@@ -63,19 +63,19 @@ public final class CoreAutoShardingAlgorithmFixture implements StandardShardingA
private int getShardingCount(final Properties props) {
Preconditions.checkArgument(props.containsKey(SHARDING_COUNT_KEY), "Sharding count can not be null.");
int result = Integer.parseInt(String.valueOf(props.getProperty(SHARDING_COUNT_KEY)));
- ShardingSpherePreconditions.checkState(result > 0, () -> new ShardingAlgorithmInitializationException(getType(), "Sharding count must be a positive integer."));
+ ShardingSpherePreconditions.checkState(result > 0, () -> new AlgorithmInitializationException(this, "Sharding count must be a positive integer."));
return result;
}
private int getStartOffset(final Properties props) {
int result = Integer.parseInt(String.valueOf(props.getProperty(START_OFFSET_INDEX_KEY, "0")));
- ShardingSpherePreconditions.checkState(result >= 0, () -> new ShardingAlgorithmInitializationException(getType(), "Start offset can not be less than 0."));
+ ShardingSpherePreconditions.checkState(result >= 0, () -> new AlgorithmInitializationException(this, "Start offset can not be less than 0."));
return result;
}
private int getStopOffset(final Properties props) {
int result = Integer.parseInt(String.valueOf(props.getProperty(STOP_OFFSET_INDEX_KEY, "0")));
- ShardingSpherePreconditions.checkState(result >= 0, () -> new ShardingAlgorithmInitializationException(getType(), "Stop offset can not be less than 0."));
+ ShardingSpherePreconditions.checkState(result >= 0, () -> new AlgorithmInitializationException(this, "Stop offset can not be less than 0."));
return result;
}
diff --git a/infra/algorithm/load-balancer/core/src/main/java/org/apache/shardingsphere/infra/algorithm/loadbalancer/core/exception/LoadBalanceSQLException.java b/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/AlgorithmInitializationException.java
similarity index 55%
rename from infra/algorithm/load-balancer/core/src/main/java/org/apache/shardingsphere/infra/algorithm/loadbalancer/core/exception/LoadBalanceSQLException.java
rename to infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/AlgorithmInitializationException.java
index 91689fe7592..4814b1862e7 100644
--- a/infra/algorithm/load-balancer/core/src/main/java/org/apache/shardingsphere/infra/algorithm/loadbalancer/core/exception/LoadBalanceSQLException.java
+++ b/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/AlgorithmInitializationException.java
@@ -15,21 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.algorithm.loadbalancer.core.exception;
+package org.apache.shardingsphere.infra.algorithm.core.exception;
-import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.SQLState;
-import org.apache.shardingsphere.infra.exception.core.external.sql.type.feature.FeatureSQLException;
+import org.apache.shardingsphere.infra.algorithm.core.ShardingSphereAlgorithm;
+import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.MetaDataSQLException;
/**
- * Load balance SQL exception.
+ * Algorithm initialization exception.
*/
-public abstract class LoadBalanceSQLException extends FeatureSQLException {
+public final class AlgorithmInitializationException extends MetaDataSQLException {
- private static final int FEATURE_CODE = 12;
+ private static final long serialVersionUID = -7634670846091616790L;
- private static final long serialVersionUID = -6834428848205322872L;
-
- protected LoadBalanceSQLException(final SQLState sqlState, final int errorCode, final String reason, final Object... messageArgs) {
- super(sqlState, FEATURE_CODE, errorCode, reason, messageArgs);
+ public AlgorithmInitializationException(final ShardingSphereAlgorithm algorithm, final String reason, final Object... args) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 11, "'%s.'%s' initialization failed, reason is: %s.",
+ algorithm.getClass().getSuperclass().getSimpleName(), algorithm.getType(), String.format(reason, args));
}
}
diff --git a/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/infra/algorithm/keygen/core/exception/KeyGenerateAlgorithmInitializationException.java b/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/infra/algorithm/keygen/core/exception/KeyGenerateAlgorithmInitializationException.java
deleted file mode 100644
index 565e14189dc..00000000000
--- a/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/infra/algorithm/keygen/core/exception/KeyGenerateAlgorithmInitializationException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.algorithm.keygen.core.exception;
-
-import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-
-/**
- * Key generate algorithm initialization exception.
- */
-public final class KeyGenerateAlgorithmInitializationException extends KeyGenerateSQLException {
-
- private static final long serialVersionUID = 4137100879778822323L;
-
- public KeyGenerateAlgorithmInitializationException(final String keyGenerateType, final String reason) {
- super(XOpenSQLState.GENERAL_ERROR, 81, "Key generate algorithm `%s` initialization failed, reason is: %s.", keyGenerateType, reason);
- }
-}
diff --git a/infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/infra/algorithm/keygen/snowflake/SnowflakeKeyGenerateAlgorithm.java b/infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/infra/algorithm/keygen/snowflake/SnowflakeKeyGenerateAlgorithm.java
index cb09f5a40b4..8b22391be31 100644
--- a/infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/infra/algorithm/keygen/snowflake/SnowflakeKeyGenerateAlgorithm.java
+++ b/infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/infra/algorithm/keygen/snowflake/SnowflakeKeyGenerateAlgorithm.java
@@ -19,13 +19,13 @@ package org.apache.shardingsphere.infra.algorithm.keygen.snowflake;
import lombok.Setter;
import lombok.SneakyThrows;
+import org.apache.shardingsphere.infra.algorithm.core.context.AlgorithmSQLContext;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
+import org.apache.shardingsphere.infra.algorithm.keygen.core.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.infra.algorithm.keygen.snowflake.exception.SnowflakeClockMoveBackException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.instance.InstanceContextAware;
-import org.apache.shardingsphere.infra.algorithm.keygen.core.KeyGenerateAlgorithm;
-import org.apache.shardingsphere.infra.algorithm.core.context.AlgorithmSQLContext;
-import org.apache.shardingsphere.infra.algorithm.keygen.core.exception.KeyGenerateAlgorithmInitializationException;
-import org.apache.shardingsphere.infra.algorithm.keygen.snowflake.exception.SnowflakeClockMoveBackException;
import java.time.Instant;
import java.time.LocalDateTime;
@@ -102,13 +102,13 @@ public final class SnowflakeKeyGenerateAlgorithm implements KeyGenerateAlgorithm
private int getMaxVibrationOffset(final Properties props) {
int result = Integer.parseInt(props.getOrDefault(MAX_VIBRATION_OFFSET_KEY, DEFAULT_VIBRATION_VALUE).toString());
- ShardingSpherePreconditions.checkState(result >= 0 && result <= SEQUENCE_MASK, () -> new KeyGenerateAlgorithmInitializationException(getType(), "Illegal max vibration offset."));
+ ShardingSpherePreconditions.checkState(result >= 0 && result <= SEQUENCE_MASK, () -> new AlgorithmInitializationException(this, "Illegal max vibration offset."));
return result;
}
private int getMaxTolerateTimeDifferenceMillis(final Properties props) {
int result = Integer.parseInt(props.getOrDefault(MAX_TOLERATE_TIME_DIFFERENCE_MILLIS_KEY, MAX_TOLERATE_TIME_DIFFERENCE_MILLIS).toString());
- ShardingSpherePreconditions.checkState(result >= 0, () -> new KeyGenerateAlgorithmInitializationException(getType(), "Illegal max tolerate time difference milliseconds."));
+ ShardingSpherePreconditions.checkState(result >= 0, () -> new AlgorithmInitializationException(this, "Illegal max tolerate time difference milliseconds."));
return result;
}
diff --git a/infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/infra/algorithm/keygen/snowflake/SnowflakeKeyGenerateAlgorithmTest.java b/infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/infra/algorithm/keygen/snowflake/SnowflakeKeyGenerateAlgorithmTest.java
index 0ec1070dacb..e79aa50da1b 100644
--- a/infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/infra/algorithm/keygen/snowflake/SnowflakeKeyGenerateAlgorithmTest.java
+++ b/infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/infra/algorithm/keygen/snowflake/SnowflakeKeyGenerateAlgorithmTest.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.infra.algorithm.keygen.snowflake;
import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.algorithm.core.context.AlgorithmSQLContext;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.algorithm.keygen.core.KeyGenerateAlgorithm;
-import org.apache.shardingsphere.infra.algorithm.keygen.core.exception.KeyGenerateAlgorithmInitializationException;
import org.apache.shardingsphere.infra.algorithm.keygen.snowflake.exception.SnowflakeClockMoveBackException;
import org.apache.shardingsphere.infra.algorithm.keygen.snowflake.fixture.FixedTimeService;
import org.apache.shardingsphere.infra.algorithm.keygen.snowflake.fixture.WorkerIdGeneratorFixture;
@@ -209,7 +209,7 @@ class SnowflakeKeyGenerateAlgorithmTest {
@Test
void assertSetMaxVibrationOffsetFailureWhenNegative() {
- assertThrows(KeyGenerateAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> TypedSPILoader.getService(KeyGenerateAlgorithm.class, "SNOWFLAKE", PropertiesBuilder.build(new Property("max-vibration-offset", "-1")))
.generateKeys(mock(AlgorithmSQLContext.class), 1));
}
@@ -224,7 +224,7 @@ class SnowflakeKeyGenerateAlgorithmTest {
@Test
void assertSetMaxVibrationOffsetFailureWhenOutOfRange() {
- assertThrows(KeyGenerateAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> TypedSPILoader.getService(KeyGenerateAlgorithm.class, "SNOWFLAKE", PropertiesBuilder.build(new Property("max-vibration-offset", "4096")))
.generateKeys(mock(AlgorithmSQLContext.class), 1));
}
@@ -237,7 +237,7 @@ class SnowflakeKeyGenerateAlgorithmTest {
@Test
void assertMaxTolerateTimeDifferenceMillisecondsWhenNegative() {
- assertThrows(KeyGenerateAlgorithmInitializationException.class,
+ assertThrows(AlgorithmInitializationException.class,
() -> TypedSPILoader.getService(KeyGenerateAlgorithm.class, "SNOWFLAKE", PropertiesBuilder.build(new Property("max-tolerate-time-difference-milliseconds", "-1")))
.generateKeys(mock(AlgorithmSQLContext.class), 1));
}
diff --git a/infra/algorithm/load-balancer/core/src/main/java/org/apache/shardingsphere/infra/algorithm/loadbalancer/core/exception/LoadBalanceAlgorithmInitializationException.java b/infra/algorithm/load-balancer/core/src/main/java/org/apache/shardingsphere/infra/algorithm/loadbalancer/core/exception/LoadBalanceAlgorithmInitializationException.java
deleted file mode 100644
index b8d6fbdf1b7..00000000000
--- a/infra/algorithm/load-balancer/core/src/main/java/org/apache/shardingsphere/infra/algorithm/loadbalancer/core/exception/LoadBalanceAlgorithmInitializationException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.algorithm.loadbalancer.core.exception;
-
-import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-
-/**
- * Load balance algorithm initialization exception.
- */
-public final class LoadBalanceAlgorithmInitializationException extends LoadBalanceSQLException {
-
- private static final long serialVersionUID = 3025471428679102820L;
-
- public LoadBalanceAlgorithmInitializationException(final String loadBalanceAlgorithmType, final String reason, final Object... args) {
- super(XOpenSQLState.CHECK_OPTION_VIOLATION, 80, "'%s' load balance algorithm initialization failed, reason is: %s.", loadBalanceAlgorithmType, String.format(reason, args));
- }
-}
diff --git a/infra/algorithm/load-balancer/type/weight/src/main/java/org/apache/shardingsphere/infra/algorithm/loadbalancer/weight/WeightLoadBalanceAlgorithm.java b/infra/algorithm/load-balancer/type/weight/src/main/java/org/apache/shardingsphere/infra/algorithm/loadbalancer/weight/WeightLoadBalanceAlgorithm.java
index cc7ffd4b224..f218100a26b 100644
--- a/infra/algorithm/load-balancer/type/weight/src/main/java/org/apache/shardingsphere/infra/algorithm/loadbalancer/weight/WeightLoadBalanceAlgorithm.java
+++ b/infra/algorithm/load-balancer/type/weight/src/main/java/org/apache/shardingsphere/infra/algorithm/loadbalancer/weight/WeightLoadBalanceAlgorithm.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.infra.algorithm.loadbalancer.weight;
import com.google.common.base.Preconditions;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.algorithm.loadbalancer.core.LoadBalanceAlgorithm;
-import org.apache.shardingsphere.infra.algorithm.loadbalancer.core.exception.LoadBalanceAlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import java.util.Arrays;
@@ -45,15 +45,15 @@ public final class WeightLoadBalanceAlgorithm implements LoadBalanceAlgorithm {
@Override
public void init(final Properties props) {
Collection<String> availableTargetNames = props.stringPropertyNames();
- ShardingSpherePreconditions.checkState(!availableTargetNames.isEmpty(), () -> new LoadBalanceAlgorithmInitializationException(getType(), "Available target is required."));
+ ShardingSpherePreconditions.checkState(!availableTargetNames.isEmpty(), () -> new AlgorithmInitializationException(this, "Available target is required."));
for (String each : availableTargetNames) {
String weight = props.getProperty(each);
ShardingSpherePreconditions.checkNotNull(weight,
- () -> new LoadBalanceAlgorithmInitializationException(getType(), "Weight of available target `%s` is required.", each));
+ () -> new AlgorithmInitializationException(this, "Weight of available target `%s` is required.", each));
try {
weightConfigMap.put(each, Double.parseDouble(weight));
} catch (final NumberFormatException ex) {
- throw new LoadBalanceAlgorithmInitializationException(getType(), "Weight `%s` of available target `%s` should be number.", weight, each);
+ throw new AlgorithmInitializationException(this, "Weight `%s` of available target `%s` should be number.", weight, each);
}
}
}
@@ -61,7 +61,7 @@ public final class WeightLoadBalanceAlgorithm implements LoadBalanceAlgorithm {
@Override
public void check(final String databaseName, final Collection<String> configuredTargetNames) {
weightConfigMap.keySet().forEach(each -> ShardingSpherePreconditions.checkState(configuredTargetNames.contains(each),
- () -> new LoadBalanceAlgorithmInitializationException(getType(), "Target `%s` is required in database `%s`.", each, databaseName)));
+ () -> new AlgorithmInitializationException(this, "Target `%s` is required in database `%s`.", each, databaseName)));
}
@Override
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/job/ratelimit/JobRateLimitAlgorithmInitializationException.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/job/ratelimit/JobRateLimitAlgorithmInitializationException.java
deleted file mode 100644
index 366aceee6d5..00000000000
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/job/ratelimit/JobRateLimitAlgorithmInitializationException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.data.pipeline.core.exception.job.ratelimit;
-
-import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
-
-public final class JobRateLimitAlgorithmInitializationException extends ShardingSQLException {
-
- private static final long serialVersionUID = 11009186982914568L;
-
- public JobRateLimitAlgorithmInitializationException(final String jobRateLimitType, final String reason) {
- super(XOpenSQLState.GENERAL_ERROR, 97, "Job rate limit algorithm `%s` initialization failed, reason is: %s.", jobRateLimitType, reason);
- }
-}
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/type/QPSJobRateLimitAlgorithm.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/type/QPSJobRateLimitAlgorithm.java
index a8fb5ed70f8..3b595947f1a 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/type/QPSJobRateLimitAlgorithm.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/type/QPSJobRateLimitAlgorithm.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.data.pipeline.core.ratelimit.type;
import com.google.common.base.Strings;
import com.google.common.util.concurrent.RateLimiter;
import org.apache.shardingsphere.data.pipeline.core.constant.PipelineSQLOperationType;
-import org.apache.shardingsphere.data.pipeline.core.exception.job.ratelimit.JobRateLimitAlgorithmInitializationException;
import org.apache.shardingsphere.data.pipeline.core.ratelimit.JobRateLimitAlgorithm;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import java.util.Properties;
@@ -42,7 +42,7 @@ public final class QPSJobRateLimitAlgorithm implements JobRateLimitAlgorithm {
String qpsValue = props.getProperty(QPS_KEY);
if (!Strings.isNullOrEmpty(qpsValue)) {
qps = Integer.parseInt(qpsValue);
- ShardingSpherePreconditions.checkState(qps > 0, () -> new JobRateLimitAlgorithmInitializationException(getType(), "QPS must be a positive number"));
+ ShardingSpherePreconditions.checkState(qps > 0, () -> new AlgorithmInitializationException(this, "QPS must be a positive number"));
}
rateLimiter = RateLimiter.create(qps);
}
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/type/TPSJobRateLimitAlgorithm.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/type/TPSJobRateLimitAlgorithm.java
index dae38e67339..7dfc48b85dd 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/type/TPSJobRateLimitAlgorithm.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/type/TPSJobRateLimitAlgorithm.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.data.pipeline.core.ratelimit.type;
import com.google.common.base.Strings;
import com.google.common.util.concurrent.RateLimiter;
import org.apache.shardingsphere.data.pipeline.core.constant.PipelineSQLOperationType;
-import org.apache.shardingsphere.data.pipeline.core.exception.job.ratelimit.JobRateLimitAlgorithmInitializationException;
import org.apache.shardingsphere.data.pipeline.core.ratelimit.JobRateLimitAlgorithm;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import java.util.Properties;
@@ -42,7 +42,7 @@ public final class TPSJobRateLimitAlgorithm implements JobRateLimitAlgorithm {
String tpsValue = props.getProperty(TPS_KEY);
if (!Strings.isNullOrEmpty(tpsValue)) {
tps = Integer.parseInt(tpsValue);
- ShardingSpherePreconditions.checkState(tps > 0, () -> new JobRateLimitAlgorithmInitializationException(getType(), "TPS must be a positive number"));
+ ShardingSpherePreconditions.checkState(tps > 0, () -> new AlgorithmInitializationException(this, "TPS must be a positive number"));
}
rateLimiter = RateLimiter.create(tps);
}
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/QPSJobRateLimitAlgorithmTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/QPSJobRateLimitAlgorithmTest.java
index 8c65ce155a2..781bbddb07c 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/QPSJobRateLimitAlgorithmTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/QPSJobRateLimitAlgorithmTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.data.pipeline.core.ratelimit;
-import org.apache.shardingsphere.data.pipeline.core.exception.job.ratelimit.JobRateLimitAlgorithmInitializationException;
import org.apache.shardingsphere.data.pipeline.core.constant.PipelineSQLOperationType;
import org.apache.shardingsphere.data.pipeline.core.ratelimit.type.QPSJobRateLimitAlgorithm;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.junit.jupiter.api.BeforeEach;
@@ -50,7 +50,7 @@ class QPSJobRateLimitAlgorithmTest {
@Test
void assertJobRateLimitWithWrongArgumentForQPS() {
Properties props = PropertiesBuilder.build(new PropertiesBuilder.Property("qps", "0"));
- assertThrows(JobRateLimitAlgorithmInitializationException.class, () -> TypedSPILoader.getService(JobRateLimitAlgorithm.class, "QPS", props));
+ assertThrows(AlgorithmInitializationException.class, () -> TypedSPILoader.getService(JobRateLimitAlgorithm.class, "QPS", props));
}
@Test
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/TPSJobRateLimitAlgorithmTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/TPSJobRateLimitAlgorithmTest.java
index ec2495ce3a0..beb64714db6 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/TPSJobRateLimitAlgorithmTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ratelimit/TPSJobRateLimitAlgorithmTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.data.pipeline.core.ratelimit;
-import org.apache.shardingsphere.data.pipeline.core.exception.job.ratelimit.JobRateLimitAlgorithmInitializationException;
import org.apache.shardingsphere.data.pipeline.core.constant.PipelineSQLOperationType;
import org.apache.shardingsphere.data.pipeline.core.ratelimit.type.TPSJobRateLimitAlgorithm;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.junit.jupiter.api.BeforeEach;
@@ -50,7 +50,7 @@ class TPSJobRateLimitAlgorithmTest {
@Test
void assertJobRateLimitWithWrongArgumentForTPS() {
Properties props = PropertiesBuilder.build(new PropertiesBuilder.Property("tps", "0"));
- assertThrows(JobRateLimitAlgorithmInitializationException.class, () -> TypedSPILoader.getService(JobRateLimitAlgorithm.class, "TPS", props));
+ assertThrows(AlgorithmInitializationException.class, () -> TypedSPILoader.getService(JobRateLimitAlgorithm.class, "TPS", props));
}
@Test
diff --git a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLMatchTrafficAlgorithm.java b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLMatchTrafficAlgorithm.java
index 8ff8aa042e1..8c12a171915 100644
--- a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLMatchTrafficAlgorithm.java
+++ b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLMatchTrafficAlgorithm.java
@@ -20,11 +20,11 @@ package org.apache.shardingsphere.traffic.algorithm.traffic.segment;
import com.google.common.base.CharMatcher;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtils;
import org.apache.shardingsphere.traffic.api.traffic.segment.SegmentTrafficAlgorithm;
import org.apache.shardingsphere.traffic.api.traffic.segment.SegmentTrafficValue;
-import org.apache.shardingsphere.traffic.exception.segment.SegmentTrafficAlgorithmInitializationException;
import java.util.Collection;
import java.util.Properties;
@@ -43,11 +43,9 @@ public final class SQLMatchTrafficAlgorithm implements SegmentTrafficAlgorithm {
@Override
public void init(final Properties props) {
- ShardingSpherePreconditions.checkState(props.containsKey(SQL_PROPS_KEY),
- () -> new SegmentTrafficAlgorithmInitializationException(SQLMatchTrafficAlgorithm.class.getName(), String.format("%s cannot be null", SQL_PROPS_KEY)));
+ ShardingSpherePreconditions.checkState(props.containsKey(SQL_PROPS_KEY), () -> new AlgorithmInitializationException(this, "%s cannot be null", SQL_PROPS_KEY));
sql = getExactlySQL(props.getProperty(SQL_PROPS_KEY));
- ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(String.valueOf(sql)),
- () -> new SegmentTrafficAlgorithmInitializationException(SQLMatchTrafficAlgorithm.class.getName(), "sql must be not empty"));
+ ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(String.valueOf(sql)), () -> new AlgorithmInitializationException(this, "SQL must be not empty"));
}
private Collection<String> getExactlySQL(final String value) {
diff --git a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithm.java b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithm.java
index fdc99f95a62..f2a4327263f 100644
--- a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithm.java
+++ b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithm.java
@@ -18,10 +18,10 @@
package org.apache.shardingsphere.traffic.algorithm.traffic.segment;
import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.traffic.api.traffic.segment.SegmentTrafficAlgorithm;
import org.apache.shardingsphere.traffic.api.traffic.segment.SegmentTrafficValue;
-import org.apache.shardingsphere.traffic.exception.segment.SegmentTrafficAlgorithmInitializationException;
import java.util.Properties;
import java.util.regex.Pattern;
@@ -37,11 +37,9 @@ public final class SQLRegexTrafficAlgorithm implements SegmentTrafficAlgorithm {
@Override
public void init(final Properties props) {
- ShardingSpherePreconditions.checkState(props.containsKey(REGEX_PROPS_KEY),
- () -> new SegmentTrafficAlgorithmInitializationException(SQLRegexTrafficAlgorithm.class.getName(), String.format("%s cannot be null", REGEX_PROPS_KEY)));
+ ShardingSpherePreconditions.checkState(props.containsKey(REGEX_PROPS_KEY), () -> new AlgorithmInitializationException(this, "%s cannot be null", REGEX_PROPS_KEY));
regex = Pattern.compile(props.getProperty(REGEX_PROPS_KEY));
- ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(String.valueOf(regex)),
- () -> new SegmentTrafficAlgorithmInitializationException(SQLRegexTrafficAlgorithm.class.getName(), "regex must be not empty"));
+ ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(String.valueOf(regex)), () -> new AlgorithmInitializationException(this, "Regex must be not empty"));
}
@Override
diff --git a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/exception/segment/SegmentTrafficAlgorithmInitializationException.java b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/exception/segment/SegmentTrafficAlgorithmInitializationException.java
deleted file mode 100644
index cd21d5eed1c..00000000000
--- a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/exception/segment/SegmentTrafficAlgorithmInitializationException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.traffic.exception.segment;
-
-import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.traffic.exception.TrafficException;
-
-/**
- * Segment traffic algorithm initialization exception.
- */
-public final class SegmentTrafficAlgorithmInitializationException extends TrafficException {
-
- private static final long serialVersionUID = 7514112348846701284L;
-
- public SegmentTrafficAlgorithmInitializationException(final String segmentTrafficType, final String reason) {
- super(XOpenSQLState.GENERAL_ERROR, 98, "Segmentation traffic algorithm `%s` initialization failed, reason is: %s.", segmentTrafficType, reason);
- }
-}
diff --git a/test/e2e/fixture/src/test/java/org/apache/shardingsphere/test/e2e/fixture/ITEncryptLikeAlgorithmFixture.java b/test/e2e/fixture/src/test/java/org/apache/shardingsphere/test/e2e/fixture/ITEncryptLikeAlgorithmFixture.java
index b5d4689a8c5..51ab4fa60b5 100644
--- a/test/e2e/fixture/src/test/java/org/apache/shardingsphere/test/e2e/fixture/ITEncryptLikeAlgorithmFixture.java
+++ b/test/e2e/fixture/src/test/java/org/apache/shardingsphere/test/e2e/fixture/ITEncryptLikeAlgorithmFixture.java
@@ -20,10 +20,10 @@ package org.apache.shardingsphere.test.e2e.fixture;
import com.google.common.base.Strings;
import lombok.Getter;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithmMetaData;
import org.apache.shardingsphere.infra.algorithm.core.context.AlgorithmSQLContext;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import java.io.IOException;
import java.io.InputStream;
@@ -76,7 +76,7 @@ public final class ITEncryptLikeAlgorithmFixture implements EncryptAlgorithm {
try {
return Integer.parseInt(props.getProperty(DELTA_KEY));
} catch (final NumberFormatException ignored) {
- throw new EncryptAlgorithmInitializationException(getType(), "delta can only be a decimal number");
+ throw new AlgorithmInitializationException(this, "delta can only be a decimal number");
}
}
return DEFAULT_DELTA;
@@ -87,7 +87,7 @@ public final class ITEncryptLikeAlgorithmFixture implements EncryptAlgorithm {
try {
return Integer.parseInt(props.getProperty(MASK_KEY));
} catch (final NumberFormatException ignored) {
- throw new EncryptAlgorithmInitializationException(getType(), "mask can only be a decimal number");
+ throw new AlgorithmInitializationException(this, "mask can only be a decimal number");
}
}
return DEFAULT_MASK;
@@ -98,7 +98,7 @@ public final class ITEncryptLikeAlgorithmFixture implements EncryptAlgorithm {
try {
return Integer.parseInt(props.getProperty(START_KEY));
} catch (final NumberFormatException ignored) {
- throw new EncryptAlgorithmInitializationException(getType(), "start can only be a decimal number");
+ throw new AlgorithmInitializationException(this, "start can only be a decimal number");
}
}
return DEFAULT_START;
diff --git a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteEncryptLikeAlgorithmFixture.java b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteEncryptLikeAlgorithmFixture.java
index a0685d17655..12f9dd31a48 100644
--- a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteEncryptLikeAlgorithmFixture.java
+++ b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteEncryptLikeAlgorithmFixture.java
@@ -20,10 +20,10 @@ package org.apache.shardingsphere.test.it.rewrite.fixture.encrypt;
import com.google.common.base.Strings;
import lombok.Getter;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithmMetaData;
import org.apache.shardingsphere.infra.algorithm.core.context.AlgorithmSQLContext;
+import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import java.io.IOException;
import java.io.InputStream;
@@ -76,7 +76,7 @@ public final class RewriteEncryptLikeAlgorithmFixture implements EncryptAlgorith
try {
return Integer.parseInt(props.getProperty(DELTA_KEY));
} catch (final NumberFormatException ignored) {
- throw new EncryptAlgorithmInitializationException(getType(), "delta can only be a decimal number");
+ throw new AlgorithmInitializationException(this, "delta can only be a decimal number");
}
}
return DEFAULT_DELTA;
@@ -87,7 +87,7 @@ public final class RewriteEncryptLikeAlgorithmFixture implements EncryptAlgorith
try {
return Integer.parseInt(props.getProperty(MASK_KEY));
} catch (final NumberFormatException ignored) {
- throw new EncryptAlgorithmInitializationException(getType(), "mask can only be a decimal number");
+ throw new AlgorithmInitializationException(this, "mask can only be a decimal number");
}
}
return DEFAULT_MASK;
@@ -98,7 +98,7 @@ public final class RewriteEncryptLikeAlgorithmFixture implements EncryptAlgorith
try {
return Integer.parseInt(props.getProperty(START_KEY));
} catch (final NumberFormatException ignored) {
- throw new EncryptAlgorithmInitializationException(getType(), "start can only be a decimal number");
+ throw new AlgorithmInitializationException(this, "start can only be a decimal number");
}
}
return DEFAULT_START;