Package io.atomix.utils.time
Class VectorClock<T extends Identifier>
- java.lang.Object
-
- io.atomix.utils.time.VectorClock<T>
-
- All Implemented Interfaces:
Clock<VectorTimestamp<T>>
@Beta public class VectorClock<T extends Identifier> extends Object implements Clock<VectorTimestamp<T>>
Vector clock.
-
-
Constructor Summary
Constructors Constructor Description VectorClock(VectorTimestamp<T> localTimestamp)VectorClock(VectorTimestamp<T> localTimestamp, Collection<VectorTimestamp<T>> vector)VectorClock(T localIdentifier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LogicalTimestampgetLocalTimestamp()Returns the local logical timestamp.VectorTimestamp<T>getTime()Returns the current time of the clock.LogicalTimestampgetTimestamp(T identifier)Returns the logical timestamp for the given identifier.Collection<VectorTimestamp<T>>getTimestamps()Returns a collection of identifier-timestamp pairs.StringtoString()voidupdate(VectorClock<T> clock)Updates the vector clock.voidupdate(VectorTimestamp<T> timestamp)Updates the given timestamp.
-
-
-
Constructor Detail
-
VectorClock
public VectorClock(T localIdentifier)
-
VectorClock
public VectorClock(VectorTimestamp<T> localTimestamp)
-
VectorClock
public VectorClock(VectorTimestamp<T> localTimestamp, Collection<VectorTimestamp<T>> vector)
-
-
Method Detail
-
getTime
public VectorTimestamp<T> getTime()
Description copied from interface:ClockReturns the current time of the clock.- Specified by:
getTimein interfaceClock<T extends Identifier>- Returns:
- the current time
-
getLocalTimestamp
public LogicalTimestamp getLocalTimestamp()
Returns the local logical timestamp.- Returns:
- the logical timestamp for the local identifier
-
getTimestamp
public LogicalTimestamp getTimestamp(T identifier)
Returns the logical timestamp for the given identifier.- Parameters:
identifier- the identifier for which to return the timestamp- Returns:
- the logical timestamp for the given identifier
-
getTimestamps
public Collection<VectorTimestamp<T>> getTimestamps()
Returns a collection of identifier-timestamp pairs.- Returns:
- a collection of identifier-timestamp pairs
-
update
public void update(VectorTimestamp<T> timestamp)
Updates the given timestamp.- Parameters:
timestamp- the timestamp to update
-
update
public void update(VectorClock<T> clock)
Updates the vector clock.- Parameters:
clock- the vector clock with which to update this clock
-
-