public class Snowflake extends Object
https://github.com/downgoon/snowflake
| 构造器和说明 |
|---|
Snowflake(long serverId)
datacenterId + workerId [0,1023]
|
Snowflake(long datacenterId,
long workerId) |
| 限定符和类型 | 方法和说明 |
|---|---|
String |
formatId(long id)
extract and display time stamp, datacenterId, workerId and sequence
number information from the given id in humanization format
|
long |
getEpoch() |
long |
getWaitCount() |
long |
nextId()
generate an unique and incrementing id
|
long[] |
parseId(long id)
extract time stamp, datacenterId, workerId and sequence number
information from the given id
|
protected long |
timestampGen()
get current time stamp
|
String |
toString()
show settings of Snowflake
|
protected long |
waitNextMillis(long currTimestamp)
running loop blocking until next millisecond
|
public Snowflake(long datacenterId,
long workerId)
datacenterId - data center number the process running on, value range: [0,31]workerId - machine or process number, value range: [0,31]public Snowflake(long serverId)
serverId - public long nextId()
public long getWaitCount()
waitNextMillis(long) methodprotected long waitNextMillis(long currTimestamp)
currTimestamp - current time stampprotected long timestampGen()
public long getEpoch()
public long[] parseId(long id)
id - a snowflake id generated by this objectpublic String formatId(long id)
id - snowflake id in Long formatCopyright © 2024 fossc. All rights reserved.