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.Cloneable
Vector 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 VectorClock
clone()
static boolean
descends(VectorClock vc1, VectorClock vc2)
Determines if one vector clock descends from another.void
fromString(java.lang.String jsonString)
Deserialize a vector clock.int
get(java.lang.String key)
Get a value from the vector clock.void
incrementClock(java.lang.String key)
Increment the vector clock for an actor.static VectorClock
merge(VectorClock vc1, VectorClock vc2)
Merge two vector clocks and return a merged vector clock.org.json.JSONObject
toJsonObject()
Serialize a vector clock as JSON.java.lang.String
toString()
Serialize a vector clock as a string.
-
-
-
Method Detail
-
clone
public VectorClock clone()
- Overrides:
clone
in 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:
toString
in 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.
-
-