类 SnowFlake

java.lang.Object
com.yuzhyn.azylee.core.datas.ids.SnowFlake

public class SnowFlake extends Object
雪花算法ID
  • 构造器详细资料

    • SnowFlake

      public SnowFlake(long datacenterId, long workerId)
    • SnowFlake

      public SnowFlake(long datacenterId, long workerId, long sequence)
  • 方法详细资料

    • getWorkerId

      public long getWorkerId()
    • getDatacenterId

      public long getDatacenterId()
    • getTimestamp

      public long getTimestamp()
    • next

      public long next()
    • nexts

      public String nexts()
    • createDataCenterIdAndWorkerId

      public static int[] createDataCenterIdAndWorkerId(List<Integer> currentDataCenterIds, List<Integer> currentWorkerIds, boolean random)
      自动计算数据中心ID和机器ID
      参数:
      currentDataCenterIds - 当前已有的数据中心ID
      currentWorkerIds - 当前已有的机器ID
      random - 是否随机,否则为顺序生成
      返回:
      返回 返回数组[0]-数据中心ID,[1]-机器ID(没有可以指派的ID时,返回-1)
    • main

      public static void main(String[] args)