public class SnowFlowerIdGenerator extends java.lang.Object implements IdGenerator
The repeat rate of the dataCenterId, the value of the maximum dataCenterId times the time of each Raft election. The time for raft to select the master is generally measured in seconds. If the interval of an election is 5 seconds, it will take 150 seconds for the DataCenterId to be repeated. This is still based on the situation that the new master needs to be selected after each election of the Leader
| 限定符和类型 | 字段和说明 |
|---|---|
private long |
currentId |
private static java.lang.String |
DATETIME_PATTERN |
static long |
EPOCH
Start time intercept (2018-08-05 08:34)
|
private long |
lastTime |
private static org.slf4j.Logger |
logger |
private long |
monotonicStartTime |
private long |
sequence |
private static long |
SEQUENCE_BITS |
private static long |
SEQUENCE_MASK |
private long |
startWallTime |
private static long |
TIMESTAMP_LEFT_SHIFT_BITS |
private static long |
WORKER_ID_BITS |
private static long |
WORKER_ID_LEFT_SHIFT_BITS |
private static long |
WORKER_ID_MAX_VALUE |
private long |
workerId |
| 构造器和说明 |
|---|
SnowFlowerIdGenerator() |
| 限定符和类型 | 方法和说明 |
|---|---|
long |
currentId() |
private long |
currentTimeMillis() |
java.util.Map<java.lang.Object,java.lang.Object> |
info() |
void |
init() |
void |
initialize(long workerId)
init
|
long |
nextId() |
private long |
waitUntilNextTime(long lastTimestamp)
Block to the next millisecond until a new timestamp is obtained
|
long |
workerId() |
private static final java.lang.String DATETIME_PATTERN
public static final long EPOCH
private static final org.slf4j.Logger logger
private static final long SEQUENCE_BITS
private static final long WORKER_ID_BITS
private static final long SEQUENCE_MASK
private static final long WORKER_ID_LEFT_SHIFT_BITS
private static final long TIMESTAMP_LEFT_SHIFT_BITS
private static final long WORKER_ID_MAX_VALUE
private final long startWallTime
private final long monotonicStartTime
private long workerId
private long sequence
private long lastTime
private long currentId
public void init()
init 在接口中 IdGeneratorpublic long currentId()
currentId 在接口中 IdGeneratorpublic long workerId()
workerId 在接口中 IdGeneratorpublic long nextId()
nextId 在接口中 IdGeneratorpublic java.util.Map<java.lang.Object,java.lang.Object> info()
info 在接口中 IdGeneratorpublic void initialize(long workerId)
workerId - worker id (0~1024)private long waitUntilNextTime(long lastTimestamp)
lastTimestamp - The time intercept of the last ID generatedprivate long currentTimeMillis()
Copyright © 2018–2022 Alibaba Group. All rights reserved.