public class SnowflakeCreator extends Object
| Constructor and Description |
|---|
SnowflakeCreator(long datacenterIdBits,
long workerIdBits,
long datacenterId,
long workerId) |
| Modifier and Type | Method and Description |
|---|---|
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 SnowflakeCreator(long datacenterIdBits,
long workerIdBits,
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 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 © 2021. All rights reserved.