This is an automated email from the ASF dual-hosted git repository.
jianglongtao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 8ff0b34a2a7 Add WorkIdAssignedException (#20312)
8ff0b34a2a7 is described below
commit 8ff0b34a2a77f8f03eee255057c4ccc72580f2ab
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Aug 19 23:12:31 2022 +0800
Add WorkIdAssignedException (#20312)
---
.../content/user-manual/error-code/sql-error-code.cn.md | 3 ++-
.../content/user-manual/error-code/sql-error-code.en.md | 3 ++-
.../core/exception/PipelineJobNotFoundException.java | 2 +-
.../registry/workerid/exception/WorkIdAssignedException.java | 12 ++++++------
.../workerid/generator/ClusterWorkerIdGenerator.java | 4 ++--
5 files changed, 13 insertions(+), 11 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 ed7772e9f76..c17c7d37cd2 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
@@ -18,6 +18,7 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| 44000 | 13000 | SQL check failed, error message: %s |
| HY000 | 14000 | The table \`%s\` of schema \`%s\` is locked |
| HY000 | 14001 | The table \`%s\` of schema \`%s\` lock wait
timeout of %s ms exceeded |
-| HY000 | 15000 | Can not find pipeline job \`%s\` |
+| HY000 | 15000 | Work ID assigned failed, which can not exceed 1024
|
+| HY000 | 16000 | Can not find pipeline job \`%s\` |
| HY004 | 25000 | Shadow column \`%s\` of table \`%s\` does not
support \`%s\` type |
| 42000 | 30000 | Unknown exception: %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 abbfc893763..39ee7af2df0 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
@@ -18,6 +18,7 @@ SQL error codes provide by standard `SQL State`, `Vendor
Code` and `Reason`, whi
| 44000 | 13000 | SQL check failed, error message: %s |
| HY000 | 14000 | The table \`%s\` of schema \`%s\` is locked |
| HY000 | 14001 | The table \`%s\` of schema \`%s\` lock wait
timeout of %s ms exceeded |
-| HY000 | 15000 | Can not find pipeline job \`%s\` |
+| HY000 | 15000 | Work ID assigned failed, which can not exceed 1024
|
+| HY000 | 16000 | Can not find pipeline job \`%s\` |
| HY004 | 25000 | Shadow column \`%s\` of table \`%s\` does not
support \`%s\` type |
| 42000 | 30000 | Unknown exception: %s |
diff --git
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/PipelineJobNotFoundException.java
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/PipelineJobNotFoundException.java
index 697179dc7d7..5abc0568011 100644
---
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/PipelineJobNotFoundException.java
+++
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/PipelineJobNotFoundException.java
@@ -28,6 +28,6 @@ public final class PipelineJobNotFoundException extends
ShardingSphereSQLExcepti
private static final long serialVersionUID = -903289953649758722L;
public PipelineJobNotFoundException(final String jobId) {
- super(XOpenSQLState.GENERAL_ERROR, 15000, "Can not find pipeline job
`%s`", jobId);
+ super(XOpenSQLState.GENERAL_ERROR, 16000, "Can not find pipeline job
`%s`", jobId);
}
}
diff --git
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/PipelineJobNotFoundException.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/exception/WorkIdAssignedException.java
similarity index 70%
copy from
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/PipelineJobNotFoundException.java
copy to
shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/exception/WorkIdAssignedException.java
index 697179dc7d7..6ca9ecbb47e 100644
---
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/PipelineJobNotFoundException.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/exception/WorkIdAssignedException.java
@@ -15,19 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.data.pipeline.core.exception;
+package
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.workerid.exception;
import
org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
import
org.apache.shardingsphere.infra.util.exception.sql.sqlstate.XOpenSQLState;
/**
- * Pipeline job not found exception.
+ * Work id assigned exception.
*/
-public final class PipelineJobNotFoundException extends
ShardingSphereSQLException {
+public final class WorkIdAssignedException extends ShardingSphereSQLException {
- private static final long serialVersionUID = -903289953649758722L;
+ private static final long serialVersionUID = 4782736481041926266L;
- public PipelineJobNotFoundException(final String jobId) {
- super(XOpenSQLState.GENERAL_ERROR, 15000, "Can not find pipeline job
`%s`", jobId);
+ public WorkIdAssignedException() {
+ super(XOpenSQLState.GENERAL_ERROR, 15000, "Work ID assigned failed,
which can not exceed 1024");
}
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java
index 19791d1a648..a08b5f8e8dd 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java
@@ -20,10 +20,10 @@ package
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.work
import com.google.common.base.Preconditions;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.workerid.WorkerIdGenerator;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.RegistryCenter;
+import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.workerid.exception.WorkIdAssignedException;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.workerid.node.WorkerIdNode;
import
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryException;
@@ -67,7 +67,7 @@ public final class ClusterWorkerIdGenerator implements
WorkerIdGenerator {
private Optional<Long> generateAvailableWorkerId() {
Set<Long> assignedWorkerIds =
registryCenter.getComputeNodeStatusService().getAssignedWorkerIds();
if (assignedWorkerIds.size() > 1024) {
- throw new ShardingSphereException("System assigned %s failed,
Illegal max vibration offset.", WORKER_ID_KEY);
+ throw new WorkIdAssignedException();
}
Collection<Long> maxAvailableIds = new ArrayList<>(1024);
for (int i = 0; i < 1024; i++) {