This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 fa835766799 modify worker id max value (#19309)
fa835766799 is described below
commit fa835766799e27379ab0290efe92f3f4941ddbce
Author: laststem <[email protected]>
AuthorDate: Wed Jul 20 01:13:11 2022 +0900
modify worker id max value (#19309)
---
.../sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
index f2ab00ef081..f97783428ac 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
@@ -59,7 +59,7 @@ public final class SnowflakeKeyGenerateAlgorithm implements
KeyGenerateAlgorithm
private static final long TIMESTAMP_LEFT_SHIFT_BITS =
WORKER_ID_LEFT_SHIFT_BITS + WORKER_ID_BITS;
- private static final long WORKER_ID_MAX_VALUE = 1L << WORKER_ID_BITS;
+ private static final long WORKER_ID_MAX_VALUE = (1L << WORKER_ID_BITS) - 1;
private static final int DEFAULT_VIBRATION_VALUE = 1;
@@ -118,7 +118,7 @@ public final class SnowflakeKeyGenerateAlgorithm implements
KeyGenerateAlgorithm
}
private void rangeValidate(final long workerId) {
- Preconditions.checkArgument(workerId >= 0L && workerId <
WORKER_ID_MAX_VALUE, "Illegal worker id.");
+ Preconditions.checkArgument(workerId >= 0L && workerId <=
WORKER_ID_MAX_VALUE, "Illegal worker id.");
}
private int getMaxVibrationOffset(final Properties props) {