public abstract class AbstractSnowflakeId extends java.lang.Object implements SnowflakeId
| Modifier and Type | Field and Description |
|---|---|
protected long |
epoch |
protected long |
lastTimestamp |
protected int |
machineBit |
protected long |
machineId |
protected long |
machineLeft |
protected long |
maxMachine |
protected long |
maxSequence |
protected long |
maxTimestamp |
protected long |
sequence |
protected int |
sequenceBit |
protected int |
timestampBit |
protected long |
timestampLeft |
TOTAL_BIT| Constructor and Description |
|---|
AbstractSnowflakeId(long epoch,
int timestampBit,
int machineBit,
int sequenceBit,
long machineId,
long sequenceResetThreshold) |
| Modifier and Type | Method and Description |
|---|---|
long |
generate()
Generate distributed ID.
|
protected abstract long |
getCurrentTime()
get current timestamp.
|
long |
getEpoch() |
long |
getLastTimestamp() |
int |
getMachineBit() |
long |
getMachineId() |
long |
getMaxMachine() |
long |
getMaxSequence() |
long |
getMaxTimestamp() |
int |
getSequenceBit() |
int |
getTimestampBit() |
protected long |
nextTime() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdefaultSequenceResetThreshold, isSafeJavascriptgenerateAsString, idConverterprotected final long epoch
protected final int timestampBit
protected final int machineBit
protected final int sequenceBit
protected final long maxTimestamp
protected final long maxSequence
protected final long maxMachine
protected final long machineLeft
protected final long timestampLeft
protected final long machineId
protected long sequence
protected long lastTimestamp
public AbstractSnowflakeId(long epoch,
int timestampBit,
int machineBit,
int sequenceBit,
long machineId,
long sequenceResetThreshold)
protected long nextTime()
protected abstract long getCurrentTime()
public long generate()
IdGeneratorgenerate in interface IdGeneratorpublic long getEpoch()
getEpoch in interface SnowflakeIdpublic int getTimestampBit()
getTimestampBit in interface SnowflakeIdpublic int getMachineBit()
getMachineBit in interface SnowflakeIdpublic int getSequenceBit()
getSequenceBit in interface SnowflakeIdpublic long getMaxTimestamp()
getMaxTimestamp in interface SnowflakeIdpublic long getMaxMachine()
getMaxMachine in interface SnowflakeIdpublic long getMaxSequence()
getMaxSequence in interface SnowflakeIdpublic long getLastTimestamp()
getLastTimestamp in interface SnowflakeIdpublic long getMachineId()
getMachineId in interface SnowflakeId