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 07:02:03 UTC
[GitHub] [shardingsphere] menghaoranss opened a new pull request #14824: add worker id generator for SnowflakeKeyGenerateAlgorithm
menghaoranss opened a new pull request #14824:
URL: https://github.com/apache/shardingsphere/pull/14824
For #14254
--
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
[GitHub] [shardingsphere] menghaoranss commented on a change in pull request #14824: add worker id generator for SnowflakeKeyGenerateAlgorithm
Posted by GitBox <gi...@apache.org>.
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #14824: add worker id generator for SnowflakeKeyGenerateAlgorithm
Posted by GitBox <gi...@apache.org>.
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
[GitHub] [shardingsphere] strongduanmu merged pull request #14824: add worker id generator for SnowflakeKeyGenerateAlgorithm
Posted by GitBox <gi...@apache.org>.
strongduanmu merged pull request #14824:
URL: https://github.com/apache/shardingsphere/pull/14824
--
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
[GitHub] [shardingsphere] menghaoranss commented on a change in pull request #14824: add worker id generator for SnowflakeKeyGenerateAlgorithm
Posted by GitBox <gi...@apache.org>.
menghaoranss commented on a change in pull request #14824:
URL: https://github.com/apache/shardingsphere/pull/14824#discussion_r785789484
##########
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:
BTW, thanks for you review
--
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
[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #14824: add worker id generator for SnowflakeKeyGenerateAlgorithm
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on a change in pull request #14824:
URL: https://github.com/apache/shardingsphere/pull/14824#discussion_r785792198
##########
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:
> s for you review
@menghaoranss Thank you for your explanation.
--
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