Package io.aeron.cluster.service
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.
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 Summary
Modifier and TypeMethodDescriptiondefault longconvertToNanos(long time) Convert given Cluster time toTimeUnit.NANOSECONDS.static TimeUnitmap(io.aeron.cluster.codecs.ClusterTimeUnit clusterTimeUnit) MapClusterTimeUnitto a correspondingTimeUnit.static io.aeron.cluster.codecs.ClusterTimeUnitMapTimeUnitto a correspondingClusterTimeUnit.longtime()The count oftimeUnit()s since 1 Jan 1970 UTC.default longGet the current time inTimeUnit.MICROSECONDS.default longGet the current time inTimeUnit.MILLISECONDS.default longGet the current time inTimeUnit.NANOSECONDS.default TimeUnittimeUnit()The unit of time returned from thetime()method.
-
Method Details
-
timeUnit
The unit of time returned from thetime()method.- Returns:
- the unit of time returned from the
time()method.
-
time
long time()The count oftimeUnit()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 inTimeUnit.MILLISECONDS.- Returns:
- the current time in
TimeUnit.MILLISECONDS.
-
timeMicros
default long timeMicros()Get the current time inTimeUnit.MICROSECONDS.- Returns:
- the current time in
TimeUnit.MICROSECONDS.
-
timeNanos
default long timeNanos()Get the current time inTimeUnit.NANOSECONDS.- Returns:
- the current time in
TimeUnit.NANOSECONDS.
-
convertToNanos
default long convertToNanos(long time) Convert given Cluster time toTimeUnit.NANOSECONDS.- Parameters:
time- to convert to nanoseconds.- Returns:
- time in
TimeUnit.NANOSECONDS.
-
map
MapTimeUnitto a correspondingClusterTimeUnit.- Parameters:
timeUnit- to map to a correspondingClusterTimeUnit.- Returns:
- a corresponding
ClusterTimeUnit.
-
map
MapClusterTimeUnitto a correspondingTimeUnit.- Parameters:
clusterTimeUnit- to map to a correspondingTimeUnit.- Returns:
- a corresponding
TimeUnit, ifClusterTimeUnit.NULL_VALis passed then defaults toTimeUnit.MILLISECONDS.
-