public abstract class AbstractMonotonicTimestampGenerator extends Object implements TimestampGenerator
System.currentTimeMillis(). On some systems, however, it is possible to have a better granularity by using a JNR call to
gettimeofday. The driver will use this system call automatically whenever available, unless the system property
com.datastax.driver.USE_NATIVE_CLOCKis explicitly set to
false. Beware that to guarantee monotonicity, if more than one call to
TimestampGenerator.next()is made within the same microsecond, or in the event of a system clock skew, this generator might return timestamps that drift out in the future. Whe this happens,
onDrift(long, long)is invoked.
|Constructor and Description|
|Modifier and Type||Method and Description|
Compute the next timestamp, given the last timestamp previously generated.
Called when generated timestamps drift into the future compared to the underlying clock (in other words, if
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected long computeNext(long last)
onDrift(long, long)will be invoked. This implementation is inspired by
last- the last timestamp generated by this generator, in microseconds.
protected abstract void onDrift(long currentTick, long lastTimestamp)
lastTimestamp >= currentTick). This could happen if timestamps are requested faster than the clock granularity, or on a clock skew (for example because of a leap second).
currentTick- the current clock tick, in microseconds.
lastTimestamp- the last timestamp that was generated, in microseconds.
Copyright © 2012–2018. All rights reserved.