public class MillisecondTimestampFactory extends Object
System.currentTimeMillis(). Timestamps reported by this factory are guarenteed to be distinct and strictly increasing during the life cycle of the JVM. No guarentee is made if across JVMs or system reboots. A means is available to inform the factory of the earliest timestamp that it may serve. This may be used on restart to ensure that time goes forward or when handing off from one timestamp service to another.
Note: Time as reported by
System.currentTimeMillis() can do crazy
things, including going backwards - presumably because of an error somewhere
in the time management stack (observed on Fedora core 6 with Sun JDK
1.6.0_03). In these cases a warning is logged and the timestamp factory
begins to assign up one long integers instead. If time catches up, then
another warning is logged and the factory again begins to report timestamps
System.currentTimeMillis(). Note that when the factory is
using a one-up assignment it may appear to have a resolution finer than one
Note: method on this class are
synchronized to ensure that
concurrent callers receive distinct timestamps. Likewise, the methods on this
static to ensure that assigned timestamps are global
for a JVM.
|Modifier and Type||Method and Description|
Generates a timestamp based on
Sets the lower bound for the generated timestamps.
public static boolean isAutoIncMode()
trueif the timestamp factory is in auto-increment mode.
public static void setLowerBound(long lowerBound)
lowerBound- The lower bound.
IllegalArgumentException- if the given timestamp is non-positive.
public static long nextMillis()
System.currentTimeMillis()that is guaranteed to be distinct from the last timestamp generated by this method during the life cycle of the JVM. No guarantee is made if across JVMs or system reboots. However, a means is available to inform the factory of the earliest timestamp that it may serve.
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.