IdUtil类
public class IdUtil {
// 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动)
private final static long twepoch = 1288834974657L;
// 机器标识位数
private final static long workerIdBits = 5L;
// 数据中心标识位数
private final static long dataCenterIdBits = 5L;
// 机器ID最大值 这个是二进制运算,就是 5 bit最多只能有31个数字,也就是说机器id最多只能是32以内
private final static long maxWorkerId = -1L ^ (-1L << workerIdBits);
// 数据中心ID最大值 机房id最多只能是32以内
private final static long maxDataCenterId = -1L ^ (-1L << dataCenterIdBits);
// 毫秒内自增位
private final static long sequenceBits = 12L;
// 机器ID偏左移12位
private final static long workerIdShift = sequenceBits;
// 数据中心ID左移17位
private final static long dataCenterIdShift = sequenceBits + workerIdBits;
// 时间毫秒左移22位
private final static long timestampLeftShift = sequenceBits + workerIdBits + dataCenterIdBits;
// 生成序列的掩