|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.util.MillisecondTimestampFactory
public class MillisecondTimestampFactory
A timestamp factory based on 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
based on System.currentTimeMillis(). Note that when the factory is
using a one-up assignment it may appear to have a resolution finer than one
millisecond.
Note: method on this class are synchronized to ensure that
concurrent callers receive distinct timestamps. Likewise, the methods on this
class are static to ensure that assigned timestamps are global
for a JVM.
| Field Summary | |
|---|---|
protected static org.apache.log4j.Logger |
log
|
| Method Summary | |
|---|---|
static boolean |
isAutoIncMode()
Return true if the timestamp factory is in auto-increment
mode. |
static long |
nextMillis()
Generates a timestamp based on System.currentTimeMillis() that is
guaranteed to be distinct from the last timestamp generated by this
method during the life cycle of the JVM. |
static void |
setLowerBound(long lowerBound)
Sets the lower bound for the generated timestamps. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.log4j.Logger log
| Method Detail |
|---|
public static boolean isAutoIncMode()
true if 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.
System.currentTimeMillis()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||