Class VectorClock
- java.lang.Object
-
- cloud.filibuster.instrumentation.datatypes.VectorClock
-
- All Implemented Interfaces:
java.lang.Cloneable
public class VectorClock extends java.lang.Object implements java.lang.CloneableVector Clock.
-
-
Constructor Summary
Constructors Constructor Description VectorClock()Build a new vector clock.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description VectorClockclone()static booleandescends(VectorClock vc1, VectorClock vc2)Determines if one vector clock descends from another.voidfromString(java.lang.String jsonString)Deserialize a vector clock.intget(java.lang.String key)Get a value from the vector clock.voidincrementClock(java.lang.String key)Increment the vector clock for an actor.static VectorClockmerge(VectorClock vc1, VectorClock vc2)Merge two vector clocks and return a merged vector clock.org.json.JSONObjecttoJsonObject()Serialize a vector clock as JSON.java.lang.StringtoString()Serialize a vector clock as a string.
-
-
-
Method Detail
-
clone
public VectorClock clone()
- Overrides:
clonein classjava.lang.Object
-
get
public int get(java.lang.String key)
Get a value from the vector clock.- Parameters:
key- actor identifier.- Returns:
- integer representing the number of actions for that actor.
-
incrementClock
public void incrementClock(java.lang.String key)
Increment the vector clock for an actor.- Parameters:
key- actor identifier.
-
toJsonObject
public org.json.JSONObject toJsonObject()
Serialize a vector clock as JSON.- Returns:
- serialized vector clock.
-
toString
public java.lang.String toString()
Serialize a vector clock as a string.- Overrides:
toStringin classjava.lang.Object- Returns:
- serialized vector clock.
-
fromString
public void fromString(java.lang.String jsonString)
Deserialize a vector clock.- Parameters:
jsonString- serialized vector clock.
-
merge
public static VectorClock merge(VectorClock vc1, VectorClock vc2)
Merge two vector clocks and return a merged vector clock.- Parameters:
vc1- vector clock.vc2- vector clock.- Returns:
- merge vector clock.
-
descends
public static boolean descends(@Nullable VectorClock vc1, @Nullable VectorClock vc2)Determines if one vector clock descends from another.- Parameters:
vc1- vector clock.vc2- vector clock.- Returns:
- boolean if vc2 descends vc1.
-
-