Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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 Summary

Nested classes/interfaces inherited from class net.i2p.util.Clock
`Clock.ClockUpdateListener`

Field Summary
`(package private) RouterContext` | `_contextRC`

Fields inherited from class net.i2p.util.Clock
`_alreadyChanged, _context, _offset, _startedOn, _statCreated, MAX_LIVE_OFFSET, MAX_OFFSET, MIN_OFFSET_CHANGE`

Constructor Summary
`RouterClock(RouterContext context)`

Method Summary
`long` | `getDeltaOffset()`
`long` | `now()` Retrieve the current time synchronized with whatever reference clock is in use.
`void` | `setNow(long realTime, int stratum)`
`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 net.i2p.util.Clock
`addUpdateListener, fireOffsetChanged, getInstance, getLog, getOffset, getTimestamper, getUpdatedSuccessfully, removeUpdateListener, setNow, setOffset`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _contextRC

    RouterContext _contextRC

Constructor Detail

### RouterClock

    public RouterClock(RouterContext context)

Method Detail

### setOffset

    public 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.

  Overrides:
    `setOffset` in class `Clock`

### setNow

    public void setNow(long realTime,
                       int stratum)

  Specified by:
    `setNow` in interface `Timestamper.UpdateListener`
  Overrides:
    `setNow` in class `Clock`
  Parameters:
    `stratum` - used to determine whether we should ignore
  Since:
    0.7.12

### now

    public 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.

  Overrides:
    `now` in class `Clock`

### getDeltaOffset

    public long getDeltaOffset()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD