IDUtil { public static final String storeID(int version, MagicFlag mf) { String v = Integer.toHexString(version); if (v.length() == 1) v = "0" + v; String f = Integer.toHexString(mf.getNumber()); if (f.length() == 1) f = "0" + f; String ts = Long.toHexString(System.currentTimeMillis()); String hash = Integer.toHexString(ManagementFactory.getRuntimeMXBean().getName().hashCode()); int ranlen = 32 - ts.length() - hash.length(); StringBuilder buf = new StringBuilder(32); buf.append(v); buf.append(f); buf.append(ts); buf.append(hash); for (int i = 0; i < ranlen; i++) { buf.append(Integer.toHexString(ThreadLocalRandom.current().nextInt(0, 16))); } return buf.toString(); }  static final String storeID(int version, MagicFlag mf); static final String storeID(MagicFlag mf); static final MagicFlag toMagicFlag(String storeID); static final String uuid3();  }
@Test public void testStoreID() { String id = IDUtil.storeID(Const.V, MagicFlag.DIMIT_CONF); LOG.info("{} {}", id, IDUtil.toMagicFlag(id)); }