public class IdWorker extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected long |
epoch
服务器运行时 开始时间戳
|
protected long |
lastMillis
上一次系统时间 时间戳
用于 判断系统 是否发生 时钟回拨 异常
|
protected org.slf4j.Logger |
logger |
protected long |
maxWorkerId
最大机器 id
结果为 1023
|
protected long |
sequence
并发冲突序列 (0-4095)
即毫秒内并发量
|
protected long |
sequenceBits
并发序列在 id 中占的位数
|
protected long |
sequenceMask
并发序列掩码
二进制表示为 12 位 1 (ob111111111111=0xfff=4095)
也表示序列号最大数
|
protected long |
thresholdMills
最近时间阈值
|
protected long |
thresholdSize
最近时间缓存时间戳大小阈值
|
protected long |
timestampLeftShift
时间戳 掩码
|
protected long |
workerId
工作机器 ID (0-1023)
|
protected long |
workerIdBits
机器 id 所占位数
|
protected long |
workerIdShift
机器 id 掩码
|
| 构造器和说明 |
|---|
IdWorker(long workerId) |
| 限定符和类型 | 方法和说明 |
|---|---|
long |
getEpoch() |
long |
getLastMillis() |
long |
getWorkerId() |
protected long |
millisGen() |
long |
nextId() |
protected long |
tilNextMillis(long lastMillis)
阻塞生成下一个更大的时间戳
|
protected long epoch
protected long workerIdBits
protected long maxWorkerId
protected long sequenceBits
protected long workerIdShift
protected long timestampLeftShift
protected long sequenceMask
protected long lastMillis
protected final long workerId
protected long sequence
protected long thresholdMills
protected long thresholdSize
protected org.slf4j.Logger logger
Copyright © 2023. All rights reserved.