Class SnowflakeIdGenerator

  • All Implemented Interfaces:
    IdGenerator

    public class SnowflakeIdGenerator
    extends instep.util.LongIdGenerator
    implements IdGenerator
    基于twitter snowflake算法、64bit、默认秒级精度的发号器

    0 - timestamp - highPadding - worker - lowPadding - sequence

    • Nested Class Summary

      • Nested classes/interfaces inherited from class instep.util.LongIdGenerator

        instep.util.LongIdGenerator.Companion
    • Constructor Summary

      Constructors 
      Constructor Description
      SnowflakeIdGenerator​(int workerId)  
      SnowflakeIdGenerator​(int workerId, int timestampBits, int highPaddingBits, int workerIdBits, int lowPaddingBits)  
      SnowflakeIdGenerator​(int workerId, int timestampBits, int highPaddingBits, int workerIdBits, int lowPaddingBits, long epoch, int sequenceStartRange, java.util.Random random, int tickAccuracy)  
      SnowflakeIdGenerator​(int workerId, long epoch, int sequenceStartRange, int tickAccuracy)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getSequenceFromId​(long id)  
      long getTicksFromId​(long id)  
      long getTimestampFromId​(long id)  
      int getWorkerFromId​(long id)  
      • Methods inherited from class instep.util.LongIdGenerator

        generate, getEpochInMilliSeconds, getEpochInSeconds, getEpochTick, getHighPaddingBits, getLastTick, getLowPaddingBits, getMaxSequenceValue, getMaxWorkerId, getRandom, getSequence, getSequenceBits, getSequenceStartRange, getTickAccuracy, getTimestampBits, getTimestampShift, getWorkerId, getWorkerIdBits, getWorkerIdShift
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SnowflakeIdGenerator

        public SnowflakeIdGenerator​(int workerId,
                                    int timestampBits,
                                    int highPaddingBits,
                                    int workerIdBits,
                                    int lowPaddingBits,
                                    long epoch,
                                    int sequenceStartRange,
                                    @Nullable
                                    java.util.Random random,
                                    int tickAccuracy)
      • SnowflakeIdGenerator

        public SnowflakeIdGenerator​(int workerId,
                                    int timestampBits,
                                    int highPaddingBits,
                                    int workerIdBits,
                                    int lowPaddingBits)
      • SnowflakeIdGenerator

        public SnowflakeIdGenerator​(int workerId,
                                    long epoch,
                                    int sequenceStartRange,
                                    int tickAccuracy)
      • SnowflakeIdGenerator

        public SnowflakeIdGenerator​(int workerId)