类 SnowFlowerIdGenerator

  • 所有已实现的接口:
    com.alibaba.nacos.consistency.IdGenerator

    public class SnowFlowerIdGenerator
    extends java.lang.Object
    implements com.alibaba.nacos.consistency.IdGenerator
    copy from http://www.cluozy.com/home/hexo/2018/08/11/shariding-JDBC-snowflake/. WorkerId generation policy: Calculate the InetAddress hashcode

    The 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
    • 字段详细资料

      • 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
    • 构造器详细资料

      • SnowFlowerIdGenerator

        public SnowFlowerIdGenerator()
    • 方法详细资料

      • 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()