This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new cb18ee4cc8f Add InvalidMGRModeException (#20752)
cb18ee4cc8f is described below
commit cb18ee4cc8f52672620c6a418d340cef23dc4737
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Sep 3 21:58:06 2022 +0800
Add InvalidMGRModeException (#20752)
---
.../content/user-manual/error-code/sql-error-code.cn.md | 3 ++-
.../content/user-manual/error-code/sql-error-code.en.md | 3 ++-
...nGroupMemberException.java => InvalidMGRModeException.java} | 10 +++++-----
.../exception/InvalidMGRReplicationGroupMemberException.java | 2 +-
.../mysql/type/MGRMySQLDatabaseDiscoveryProviderAlgorithm.java | 3 ++-
5 files changed, 12 insertions(+), 9 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 fa0fa9dfe68..9f64e5e8edb 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
@@ -68,7 +68,8 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| HY000 | 20051 | \`%s %s\` can not route correctly for %s \`%s\` |
| 42S02 | 20052 | Can not find data source in sharding rule, invalid
actual data node \`%s\` |
| HY000 | 23000 | MGR plugin is not active in database \`%s\` |
-| 44000 | 23001 | \`%s\` is not in MGR replication group member in
database \`%s\` |
+| 44000 | 23001 | MGR is not in single primary mode in database
\`%s\` |
+| 44000 | 23002 | \`%s\` is not in MGR replication group member in
database \`%s\` |
| HY004 | 27000 | Encrypt algorithm \`%s\` initialize failed, reason
is: %s |
| 0A000 | 27001 | The SQL clause \`%s\` is unsupported in encrypt
rule |
| 44000 | 27002 | Altered column \`%s\` must use same encrypt
algorithm with previous column \`%s\` in 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 54c221e3602..0e9e91454e4 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
@@ -68,7 +68,8 @@ SQL error codes provide by standard `SQL State`, `Vendor
Code` and `Reason`, whi
| HY000 | 20051 | \`%s %s\` can not route correctly for %s \`%s\` |
| 42S02 | 20052 | Can not find data source in sharding rule, invalid
actual data node \`%s\` |
| HY000 | 23000 | MGR plugin is not active in database \`%s\` |
-| 44000 | 23001 | \`%s\` is not in MGR replication group member in
database \`%s\` |
+| 44000 | 23001 | MGR is not in single primary mode in database
\`%s\` |
+| 44000 | 23002 | \`%s\` is not in MGR replication group member in
database \`%s\` |
| HY004 | 27000 | Encrypt algorithm \`%s\` initialize failed, reason
is: %s |
| 0A000 | 27001 | The SQL clause \`%s\` is unsupported in encrypt
rule |
| 44000 | 27002 | Altered column \`%s\` must use same encrypt
algorithm with previous column \`%s\` in table \`%s\` |
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/exception/InvalidMGRReplicationGroupMemberException.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/exception/InvalidMGRModeException.java
similarity index 69%
copy from
shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/exception/InvalidMGRReplicationGroupMemberException.java
copy to
shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/exception/InvalidMGRModeException.java
index 5e95e667d8a..e5f62e18edd 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/exception/InvalidMGRReplicationGroupMemberException.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/exception/InvalidMGRModeException.java
@@ -21,13 +21,13 @@ import
org.apache.shardingsphere.infra.util.exception.external.sql.ShardingSpher
import
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
/**
- * Invalid MGR replication group member exception.
+ * Invalid MGR mode exception.
*/
-public final class InvalidMGRReplicationGroupMemberException extends
ShardingSphereSQLException {
+public final class InvalidMGRModeException extends ShardingSphereSQLException {
- private static final long serialVersionUID = 3766206496827463146L;
+ private static final long serialVersionUID = -2190741601319220590L;
- public InvalidMGRReplicationGroupMemberException(final String url, final
String databaseName) {
- super(XOpenSQLState.CHECK_OPTION_VIOLATION, 23001, "`%s` is not in MGR
replication group member in database `%s`", url, databaseName);
+ public InvalidMGRModeException(final String databaseName) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 23001, "MGR is not in
single primary mode in database `%s`", databaseName);
}
}
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/exception/InvalidMGRReplicationGroupMemberException.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/exception/InvalidMGRReplicationGroupMemberException.java
index 5e95e667d8a..d72da63f9c0 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/exception/InvalidMGRReplicationGroupMemberException.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/exception/InvalidMGRReplicationGroupMemberException.java
@@ -28,6 +28,6 @@ public final class InvalidMGRReplicationGroupMemberException
extends ShardingSph
private static final long serialVersionUID = 3766206496827463146L;
public InvalidMGRReplicationGroupMemberException(final String url, final
String databaseName) {
- super(XOpenSQLState.CHECK_OPTION_VIOLATION, 23001, "`%s` is not in MGR
replication group member in database `%s`", url, databaseName);
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 23002, "`%s` is not in MGR
replication group member in database `%s`", url, databaseName);
}
}
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MGRMySQLDatabaseDiscoveryProviderAlgorithm.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MGRMySQLDatabaseDiscoveryProviderAlgorithm.java
index 036efe67709..7719e1cf642 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MGRMySQLDatabaseDiscoveryProviderAlgorithm.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MGRMySQLDatabaseDiscoveryProviderAlgorithm.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.dbdiscovery.mysql.type;
import com.google.common.base.Preconditions;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
+import
org.apache.shardingsphere.dbdiscovery.mysql.exception.InvalidMGRModeException;
import
org.apache.shardingsphere.dbdiscovery.mysql.exception.InvalidMGRPluginException;
import
org.apache.shardingsphere.dbdiscovery.mysql.exception.InvalidMGRReplicationGroupMemberException;
import
org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryProviderAlgorithm;
@@ -112,7 +113,7 @@ public final class
MGRMySQLDatabaseDiscoveryProviderAlgorithm implements Databas
private void checkSinglePrimaryMode(final String databaseName, final
Statement statement) throws SQLException {
try (ResultSet resultSet =
statement.executeQuery(QUERY_SINGLE_PRIMARY_MODE)) {
- Preconditions.checkState(resultSet.next() &&
"ON".equals(resultSet.getString("VARIABLE_VALUE")), "MGR is not in single
primary mode in database `%s`.", databaseName);
+ ShardingSpherePreconditions.checkStatus(resultSet.next() &&
"ON".equals(resultSet.getString("VARIABLE_VALUE")), new
InvalidMGRModeException(databaseName));
}
}