You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/01/17 09:32:45 UTC
[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #14824: add worker id generator for SnowflakeKeyGenerateAlgorithm
strongduanmu commented on a change in pull request #14824:
URL: https://github.com/apache/shardingsphere/pull/14824#discussion_r785777839
##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
##########
@@ -96,13 +96,15 @@
@Override
public void init() {
- workerId = getWorkerId();
maxVibrationOffset = getMaxVibrationOffset();
maxTolerateTimeDifferenceMilliseconds = getMaxTolerateTimeDifferenceMilliseconds();
}
private long getWorkerId() {
- long result = Long.parseLong(props.getOrDefault(WORKER_ID_KEY, WORKER_ID).toString());
+ if (null == instanceContext) {
+ return DEFAULT_WORKER_ID;
+ }
+ long result = instanceContext.getWorkerId();
Review comment:
@menghaoranss Why not init workerId in `init` method?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org