Interface ClusterClock

All Known Implementing Classes:
MillisecondClusterClock, NanosecondClusterClock
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ClusterClock
A clock representing a number of TimeUnits since 1 Jan 1970 UTC. Defaults to TimeUnit.MILLISECONDS.

This is the clock used to timestamp sequenced messages for the cluster log and timers. Implementations should be efficient otherwise throughput of the cluster will be impacted due to frequency of use.

  • Method Details

    • timeUnit

      default TimeUnit timeUnit()
      The unit of time returned from the time() method.
      Returns:
      the unit of time returned from the time() method.
    • time

      long time()
      The count of timeUnit()s since 1 Jan 1970 UTC.
      Returns:
      the count of timeUnit()s since 1 Jan 1970 UTC.
    • timeMillis

      default long timeMillis()
      Get the current time in TimeUnit.MILLISECONDS.
      Returns:
      the current time in TimeUnit.MILLISECONDS.
    • timeMicros

      default long timeMicros()
      Get the current time in TimeUnit.MICROSECONDS.
      Returns:
      the current time in TimeUnit.MICROSECONDS.
    • timeNanos

      default long timeNanos()
      Get the current time in TimeUnit.NANOSECONDS.
      Returns:
      the current time in TimeUnit.NANOSECONDS.
    • convertToNanos

      default long convertToNanos(long time)
      Convert given Cluster time to TimeUnit.NANOSECONDS.
      Parameters:
      time - to convert to nanoseconds.
      Returns:
      time in TimeUnit.NANOSECONDS.
    • map

      static io.aeron.cluster.codecs.ClusterTimeUnit map(TimeUnit timeUnit)
      Map TimeUnit to a corresponding ClusterTimeUnit.
      Parameters:
      timeUnit - to map to a corresponding ClusterTimeUnit.
      Returns:
      a corresponding ClusterTimeUnit.
    • map

      static TimeUnit map(io.aeron.cluster.codecs.ClusterTimeUnit clusterTimeUnit)
      Map ClusterTimeUnit to a corresponding TimeUnit.
      Parameters:
      clusterTimeUnit - to map to a corresponding TimeUnit.
      Returns:
      a corresponding TimeUnit, if ClusterTimeUnit.NULL_VAL is passed then defaults to TimeUnit.MILLISECONDS.