Package com.datastax.driver.core
Class LoggingMonotonicTimestampGenerator
- java.lang.Object
-
- com.datastax.driver.core.AbstractMonotonicTimestampGenerator
-
- com.datastax.driver.core.LoggingMonotonicTimestampGenerator
-
- All Implemented Interfaces:
TimestampGenerator
- Direct Known Subclasses:
AtomicMonotonicTimestampGenerator,ThreadLocalMonotonicTimestampGenerator
public abstract class LoggingMonotonicTimestampGenerator extends AbstractMonotonicTimestampGenerator
A monotonic timestamp generator that logs warnings when timestamps drift in the future (see this class's constructors andonDrift(long, long)for more information).
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLoggingMonotonicTimestampGenerator(long warningThreshold, TimeUnit warningThresholdUnit, long warningInterval, TimeUnit warningIntervalUnit)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidonDrift(long currentTick, long lastTimestamp)Called when generated timestamps drift into the future compared to the underlying clock (in other words, iflastTimestamp >= currentTick).-
Methods inherited from class com.datastax.driver.core.AbstractMonotonicTimestampGenerator
computeNext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.datastax.driver.core.TimestampGenerator
next
-
-
-
-
Constructor Detail
-
LoggingMonotonicTimestampGenerator
protected LoggingMonotonicTimestampGenerator(long warningThreshold, TimeUnit warningThresholdUnit, long warningInterval, TimeUnit warningIntervalUnit)Creates a new instance.- Parameters:
warningThreshold- how far in the future timestamps are allowed to drift before a warning is logged.warningThresholdUnit- the unit forwarningThreshold.warningInterval- how often the warning will be logged if timestamps keep drifting above the threshold.warningIntervalUnit- the unit forwarningIntervalUnit.
-
-
Method Detail
-
onDrift
protected void onDrift(long currentTick, long lastTimestamp)Called when generated timestamps drift into the future compared to the underlying clock (in other words, iflastTimestamp >= 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).
This implementation logs a warning at regular intervals when timestamps drift more than a specified threshold in the future. These messages are emitted at
WARNlevel in the categorycom.datastax.driver.core.TimestampGenerator.- Specified by:
onDriftin classAbstractMonotonicTimestampGenerator- Parameters:
currentTick- the current clock tick.lastTimestamp- the last timestamp that was generated.
-
-