List of utility methods to do AtomicLong
long | getNowMicrosUtc() Return wall clock time, in microseconds since Unix Epoch (1/1/1970 UTC midnight). long now = System.currentTimeMillis() * 1000; long time = PREVIOUS_TIME_VALUE.getAndIncrement(); if (now > time) { PREVIOUS_TIME_VALUE.compareAndSet(time + 1, now); return PREVIOUS_TIME_VALUE.getAndIncrement(); return time; |
long | getRAMUniqueID() a simple counter which is garanteed to be unique ONLY within one instance of a virtual machine. return ramid.incrementAndGet();
|
String | getRandomTopicName() get Random Topic Name return "ut_topic_" + System.currentTimeMillis() + "_" + counter.addAndGet(1); |
String | getSequenceNumber() get Sequence Number long id = atomicLong.addAndGet(1); return String.valueOf(id); |
String | getTempDirName() Return a string which can be used to create a directory in the temporary workspace of whatever is the meaning of the temp space in the present execution environment. return tmpDirPath + uniqueId.incrementAndGet();
|
long | getTomorrowTime() Returns the first millisecond of tomorrow. final long current = System.currentTimeMillis(); synchronized (TOMORROW) { if (current > TOMORROW.get()) { GregorianCalendar cal = new GregorianCalendar(); cal.add(Calendar.DATE, 1); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); ... |
String | getTrackedAllocationStatus() get Tracked Allocation Status long directByteBufferUsage = DIRECT_BYTE_BUFFER_USAGE.get(); long mmapBufferUsage = MMAP_BUFFER_USAGE.get(); return "direct " + (directByteBufferUsage / BYTES_IN_MEGABYTE) + " MB, mmap " + (mmapBufferUsage / BYTES_IN_MEGABYTE) + " MB, total " + ((directByteBufferUsage + mmapBufferUsage) / BYTES_IN_MEGABYTE) + " MB"; |
String | getUniqueURIString() Returns a URI unique within a test run. return "http://example.com/" + Long.toString(uriCounter.incrementAndGet()); |
void | greaterAndSet(long value, AtomicLong atomicValue) greater And Set synchronized (atomicValue) { if (value > atomicValue.get()) atomicValue.set(value); |
boolean | isAtomicLong(final N number) Check if the number is an AtomicLong return isNumberType(number, AtomicLong.class); |