Package com.datastax.driver.core
Class AtomicMonotonicTimestampGenerator
- java.lang.Object
-
- com.datastax.driver.core.AbstractMonotonicTimestampGenerator
-
- com.datastax.driver.core.LoggingMonotonicTimestampGenerator
-
- com.datastax.driver.core.AtomicMonotonicTimestampGenerator
-
- All Implemented Interfaces:
TimestampGenerator
public class AtomicMonotonicTimestampGenerator extends LoggingMonotonicTimestampGenerator
A timestamp generator that guarantees monotonically increasing timestamps among all client threads, and logs warnings when timestamps drift in the future.- See Also:
AbstractMonotonicTimestampGenerator
-
-
Constructor Summary
Constructors Constructor Description AtomicMonotonicTimestampGenerator()Creates a new instance with a warning threshold and warning interval of one second.AtomicMonotonicTimestampGenerator(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 longnext()Returns the next timestamp.-
Methods inherited from class com.datastax.driver.core.LoggingMonotonicTimestampGenerator
onDrift
-
Methods inherited from class com.datastax.driver.core.AbstractMonotonicTimestampGenerator
computeNext
-
-
-
-
Constructor Detail
-
AtomicMonotonicTimestampGenerator
public AtomicMonotonicTimestampGenerator()
Creates a new instance with a warning threshold and warning interval of one second.
-
AtomicMonotonicTimestampGenerator
public AtomicMonotonicTimestampGenerator(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
-
next
public long next()
Description copied from interface:TimestampGeneratorReturns the next timestamp.Implementors should enforce increasing monotonicity of timestamps, that is, a timestamp returned should always be strictly greater that any previously returned timestamp.
Implementors should strive to achieve microsecond precision in the best possible way, which is usually largely dependent on the underlying operating system's capabilities.
- Returns:
- the next timestamp (in microseconds). If it equals
Long.MIN_VALUE, it won't be sent by the driver, letting Cassandra generate a server-side timestamp.
-
-