menghaoranss commented on a change in pull request #14824:
URL: https://github.com/apache/shardingsphere/pull/14824#discussion_r785788973



##########
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:
       @strongduanmu the workerId should be able to updated online, it's better 
to get it when need to use, and if workerId has been generated before, it will 
be retrieved directly from memory.
   




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to