Package net.i2p.router
Class RouterClock
- java.lang.Object
- 
- net.i2p.util.Clock
- 
- net.i2p.router.RouterClock
 
 
- 
- All Implemented Interfaces:
- Timestamper.UpdateListener
 
 public class RouterClock extends 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). RouterClock is a subclass of Clock with access to router transports. Configuration permitting, it will block clock offset changes which would increase peer clock skew.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static interfaceRouterClock.ClockShiftListener- 
Nested classes/interfaces inherited from class net.i2p.util.ClockClock.ClockUpdateListener
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static intDEFAULT_STRATUM- 
Fields inherited from class net.i2p.util.Clock_alreadyChanged, _context, _isSystemClockBad, _offset, _startedOn, _statCreated, MAX_LIVE_OFFSET, MAX_OFFSET, MIN_OFFSET_CHANGE
 
- 
 - 
Constructor SummaryConstructors Constructor Description RouterClock(RouterContext context)Does not start.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddShiftListener(RouterClock.ClockShiftListener lsnr)longgetDeltaOffset()Deprecated.TimestampergetTimestamper()The RouterTimestamperlongnow()Retrieve the current time synchronized with whatever reference clock is in use.voidremoveShiftListener(RouterClock.ClockShiftListener lsnr)voidsetNow(long realTime, int stratum)Warning - overridden in RouterClockvoidsetOffset(long offsetMs, boolean force)Specify how far away from the "correct" time the computer is - a positive value means that the system time is slow, while a negative value means the system time is fast.voidstart()Cannot be stopped, but RouterTimestamper registers a shutdown task.- 
Methods inherited from class net.i2p.util.ClockaddUpdateListener, fireOffsetChanged, getInstance, getLog, getOffset, getUpdatedSuccessfully, removeUpdateListener, setNow, setOffset
 
- 
 
- 
- 
- 
Field Detail- 
DEFAULT_STRATUMpublic static final int DEFAULT_STRATUM - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
RouterClockpublic RouterClock(RouterContext context) Does not start. Caller MUST call start()
 
- 
 - 
Method Detail- 
startpublic void start() Cannot be stopped, but RouterTimestamper registers a shutdown task.- Since:
- 0.9.20
 
 - 
getTimestamperpublic Timestamper getTimestamper() The RouterTimestamper- Overrides:
- getTimestamperin class- Clock
 
 - 
setOffsetpublic void setOffset(long offsetMs, boolean force)Specify how far away from the "correct" time the computer is - a positive value means that the system time is slow, while a negative value means the system time is fast.
 - 
setNowpublic void setNow(long realTime, int stratum)Description copied from class:ClockWarning - overridden in RouterClock- Specified by:
- setNowin interface- Timestamper.UpdateListener
- Overrides:
- setNowin class- Clock
- Parameters:
- stratum- used to determine whether we should ignore
- Since:
- 0.7.12
 
 - 
nowpublic long now() Retrieve the current time synchronized with whatever reference clock is in use. Do really simple clock slewing, like NTP but without jitter prevention. Slew the clock toward the desired offset, but only up to a maximum slew rate, and never let the clock go backwards because of slewing. Take care to only access the volatile variables once for speed and to avoid having another thread change them This is called about a zillion times a second, so we can do the slewing right here rather than in some separate thread to keep it simple. Avoiding backwards clocks when updating in a thread would be hard too.
 - 
addShiftListenerpublic void addShiftListener(RouterClock.ClockShiftListener lsnr) 
 - 
removeShiftListenerpublic void removeShiftListener(RouterClock.ClockShiftListener lsnr) 
 - 
getDeltaOffset@Deprecated public long getDeltaOffset() Deprecated.
 
- 
 
-