|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.util.Clock
public class Clock
Alternate location for determining the time which takes into account an offset. This offset will ideally be periodically updated so as to serve as the difference between the local computer's current time and the time as known by some reference (such as an NTP synchronized clock). Protected members are used in the subclass RouterClock, which has access to a router's transports (particularly peer clock skews) to second-guess the sanity of clock adjustments.
Nested Class Summary | |
---|---|
static interface |
Clock.ClockUpdateListener
|
Field Summary | |
---|---|
protected boolean |
_alreadyChanged
|
protected I2PAppContext |
_context
|
protected long |
_offset
|
protected long |
_startedOn
|
protected boolean |
_statCreated
|
static long |
MAX_LIVE_OFFSET
after we've started up and shifted the clock, don't allow shifts of more than 10 minutes |
static long |
MAX_OFFSET
if the clock is skewed by 3+ days, fuck 'em |
static long |
MIN_OFFSET_CHANGE
if the clock skewed changes by less than 1s, ignore the update (so we don't slide all over the place) |
Constructor Summary | |
---|---|
Clock(I2PAppContext context)
|
Method Summary | |
---|---|
void |
addUpdateListener(Clock.ClockUpdateListener lsnr)
|
protected void |
fireOffsetChanged(long delta)
|
static Clock |
getInstance()
|
protected Log |
getLog()
we fetch it on demand to avoid circular dependencies (logging uses the clock) |
long |
getOffset()
|
Timestamper |
getTimestamper()
|
boolean |
getUpdatedSuccessfully()
|
long |
now()
Retrieve the current time synchronized with whatever reference clock is in use. |
void |
removeUpdateListener(Clock.ClockUpdateListener lsnr)
|
void |
setNow(long realTime)
The time has been queried and we have a current value for 'now' |
void |
setOffset(long offsetMs)
|
void |
setOffset(long offsetMs,
boolean force)
Specify how far away from the "correct" time the computer is - a positive value means that we are slow, while a negative value means we are fast. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected I2PAppContext _context
protected long _startedOn
protected boolean _statCreated
protected volatile long _offset
protected boolean _alreadyChanged
public static final long MAX_OFFSET
public static final long MAX_LIVE_OFFSET
public static final long MIN_OFFSET_CHANGE
Constructor Detail |
---|
public Clock(I2PAppContext context)
Method Detail |
---|
public static Clock getInstance()
public Timestamper getTimestamper()
protected Log getLog()
public void setOffset(long offsetMs)
public void setOffset(long offsetMs, boolean force)
public long getOffset()
public boolean getUpdatedSuccessfully()
public void setNow(long realTime)
Timestamper.UpdateListener
setNow
in interface Timestamper.UpdateListener
public long now()
public void addUpdateListener(Clock.ClockUpdateListener lsnr)
public void removeUpdateListener(Clock.ClockUpdateListener lsnr)
protected void fireOffsetChanged(long delta)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |