@Test public void getGrpcUuid() throws Exception { long currentTime = System.currentTimeMillis(); String uuid = OrientsecUUIDGenerator.getGrpcUuid(Thread.currentThread().getId(), currentTime); Assert.assertEquals(36, uuid.length()); uuid = OrientsecUUIDGenerator.getGrpcUuid(201, currentTime); Assert.assertEquals(36, uuid.length()); }
public static String getGrpcUuid(long threadID, long currentTime) { if (threadID < MAX_THREAD_COUNT) { int index = (int) threadID; countList[index]++; char[] dstArray = new char[36]; threadID = (threadID << 4) + PID_LOCAL_IP_NUM; currentTime = currentTime + (countList[index] << 4); NessUUID.digits(dstArray, 0, 8, threadID >> 32); dstArray[8] = '-'; NessUUID.digits(dstArray, 9, 4, threadID >> 16); dstArray[13] = '-'; NessUUID.digits(dstArray, 14, 4, threadID); dstArray[18] = '-'; NessUUID.digits(dstArray, 19, 4, currentTime >> 48); dstArray[23] = '-'; NessUUID.digits(dstArray, 24, 12, currentTime); return new String(dstArray); } else { return UUIDGenerator.newRandomUUID(); } }
OrientsecUUIDGenerator { public static String getGrpcUuid(long threadID, long currentTime) { if (threadID < MAX_THREAD_COUNT) { int index = (int) threadID; countList[index]++; char[] dstArray = new char[36]; threadID = (threadID << 4) + PID_LOCAL_IP_NUM; currentTime = currentTime + (countList[index] << 4); NessUUID.digits(dstArray, 0, 8, threadID >> 32); dstArray[8] = '-'; NessUUID.digits(dstArray, 9, 4, threadID >> 16); dstArray[13] = '-'; NessUUID.digits(dstArray, 14, 4, threadID); dstArray[18] = '-'; NessUUID.digits(dstArray, 19, 4, currentTime >> 48); dstArray[23] = '-'; NessUUID.digits(dstArray, 24, 12, currentTime); return new String(dstArray); } else { return UUIDGenerator.newRandomUUID(); } } }
OrientsecUUIDGenerator { public static String getGrpcUuid(long threadID, long currentTime) { if (threadID < MAX_THREAD_COUNT) { int index = (int) threadID; countList[index]++; char[] dstArray = new char[36]; threadID = (threadID << 4) + PID_LOCAL_IP_NUM; currentTime = currentTime + (countList[index] << 4); NessUUID.digits(dstArray, 0, 8, threadID >> 32); dstArray[8] = '-'; NessUUID.digits(dstArray, 9, 4, threadID >> 16); dstArray[13] = '-'; NessUUID.digits(dstArray, 14, 4, threadID); dstArray[18] = '-'; NessUUID.digits(dstArray, 19, 4, currentTime >> 48); dstArray[23] = '-'; NessUUID.digits(dstArray, 24, 12, currentTime); return new String(dstArray); } else { return UUIDGenerator.newRandomUUID(); } }  }
OrientsecUUIDGenerator { public static String getGrpcUuid(long threadID, long currentTime) { if (threadID < MAX_THREAD_COUNT) { int index = (int) threadID; countList[index]++; char[] dstArray = new char[36]; threadID = (threadID << 4) + PID_LOCAL_IP_NUM; currentTime = currentTime + (countList[index] << 4); NessUUID.digits(dstArray, 0, 8, threadID >> 32); dstArray[8] = '-'; NessUUID.digits(dstArray, 9, 4, threadID >> 16); dstArray[13] = '-'; NessUUID.digits(dstArray, 14, 4, threadID); dstArray[18] = '-'; NessUUID.digits(dstArray, 19, 4, currentTime >> 48); dstArray[23] = '-'; NessUUID.digits(dstArray, 24, 12, currentTime); return new String(dstArray); } else { return UUIDGenerator.newRandomUUID(); } }  static String getGrpcUuid(long threadID, long currentTime); }
OrientsecUUIDGenerator { public static String getGrpcUuid(long threadID, long currentTime) { if (threadID < MAX_THREAD_COUNT) { int index = (int) threadID; countList[index]++; char[] dstArray = new char[36]; threadID = (threadID << 4) + PID_LOCAL_IP_NUM; currentTime = currentTime + (countList[index] << 4); NessUUID.digits(dstArray, 0, 8, threadID >> 32); dstArray[8] = '-'; NessUUID.digits(dstArray, 9, 4, threadID >> 16); dstArray[13] = '-'; NessUUID.digits(dstArray, 14, 4, threadID); dstArray[18] = '-'; NessUUID.digits(dstArray, 19, 4, currentTime >> 48); dstArray[23] = '-'; NessUUID.digits(dstArray, 24, 12, currentTime); return new String(dstArray); } else { return UUIDGenerator.newRandomUUID(); } }  static String getGrpcUuid(long threadID, long currentTime);  }