类 SnowFlowerIdGenerator
- java.lang.Object
-
- com.alibaba.nacos.core.distributed.id.SnowFlowerIdGenerator
-
- 所有已实现的接口:
com.alibaba.nacos.consistency.IdGenerator
public class SnowFlowerIdGenerator extends java.lang.Object implements com.alibaba.nacos.consistency.IdGeneratorcopy from http://www.cluozy.com/home/hexo/2018/08/11/shariding-JDBC-snowflake/. WorkerId generation policy: Calculate the InetAddress hashcodeThe 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
- 作者:
- liaochuntao
-
-
字段概要
字段 修饰符和类型 字段 说明 private longcurrentIdprivate static java.lang.StringDATETIME_PATTERNstatic longEPOCHStart time intercept (2018-08-05 08:34)private longlastTimeprivate static org.slf4j.Loggerloggerprivate longmonotonicStartTimeprivate longsequenceprivate static longSEQUENCE_BITSprivate static longSEQUENCE_MASKprivate longstartWallTimeprivate static longTIMESTAMP_LEFT_SHIFT_BITSprivate static longWORKER_ID_BITSprivate static longWORKER_ID_LEFT_SHIFT_BITSprivate static longWORKER_ID_MAX_VALUEprivate longworkerId
-
构造器概要
构造器 构造器 说明 SnowFlowerIdGenerator()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 longcurrentId()private longcurrentTimeMillis()java.util.Map<java.lang.Object,java.lang.Object>info()voidinit()voidinitialize(long workerId)initlongnextId()private longwaitUntilNextTime(long lastTimestamp)Block to the next millisecond until a new timestamp is obtainedlongworkerId()
-
-
-
字段详细资料
-
DATETIME_PATTERN
private static final java.lang.String DATETIME_PATTERN
- 另请参阅:
- 常量字段值
-
EPOCH
public static final long EPOCH
Start time intercept (2018-08-05 08:34)- 另请参阅:
- 常量字段值
-
logger
private static final org.slf4j.Logger logger
-
SEQUENCE_BITS
private static final long SEQUENCE_BITS
- 另请参阅:
- 常量字段值
-
WORKER_ID_BITS
private static final long WORKER_ID_BITS
- 另请参阅:
- 常量字段值
-
SEQUENCE_MASK
private static final long SEQUENCE_MASK
- 另请参阅:
- 常量字段值
-
WORKER_ID_LEFT_SHIFT_BITS
private static final long WORKER_ID_LEFT_SHIFT_BITS
- 另请参阅:
- 常量字段值
-
TIMESTAMP_LEFT_SHIFT_BITS
private static final long TIMESTAMP_LEFT_SHIFT_BITS
- 另请参阅:
- 常量字段值
-
WORKER_ID_MAX_VALUE
private static final long WORKER_ID_MAX_VALUE
- 另请参阅:
- 常量字段值
-
startWallTime
private final long startWallTime
-
monotonicStartTime
private final long monotonicStartTime
-
workerId
private long workerId
-
sequence
private long sequence
-
lastTime
private long lastTime
-
currentId
private long currentId
-
-
方法详细资料
-
init
public void init()
- 指定者:
init在接口中com.alibaba.nacos.consistency.IdGenerator
-
currentId
public long currentId()
- 指定者:
currentId在接口中com.alibaba.nacos.consistency.IdGenerator
-
workerId
public long workerId()
- 指定者:
workerId在接口中com.alibaba.nacos.consistency.IdGenerator
-
nextId
public long nextId()
- 指定者:
nextId在接口中com.alibaba.nacos.consistency.IdGenerator
-
info
public java.util.Map<java.lang.Object,java.lang.Object> info()
- 指定者:
info在接口中com.alibaba.nacos.consistency.IdGenerator
-
initialize
public void initialize(long workerId)
init- 参数:
workerId- worker id (0~1024)
-
waitUntilNextTime
private long waitUntilNextTime(long lastTimestamp)
Block to the next millisecond until a new timestamp is obtained- 参数:
lastTimestamp- The time intercept of the last ID generated- 返回:
- Current timestamp
-
currentTimeMillis
private long currentTimeMillis()
-
-