voldemort.versioning
Class VectorClockUtils

java.lang.Object
  extended by voldemort.versioning.VectorClockUtils

public class VectorClockUtils
extends java.lang.Object


Constructor Summary
VectorClockUtils()
           
 
Method Summary
static Occurred compare(VectorClock v1, VectorClock v2)
          Compare two VectorClocks, the outcomes will be one of the following:
-- Clock 1 is BEFORE clock 2, if there exists an nodeId such that c1(nodeId) <= c2(nodeId) and there does not exist another nodeId such that c1(nodeId) > c2(nodeId).
static VectorClock makeClock(java.util.Set<java.lang.Integer> serverIds, long clockValue, long timestamp)
          Generates a vector clock with the provided values
static VectorClock makeClockWithCurrentTime(java.util.Set<java.lang.Integer> serverIds)
          Generates a vector clock with the provided nodes and current time stamp This clock can be used to overwrite the existing value avoiding obsolete version exceptions in most cases, except If the existing Vector Clock was generated in custom way.
static java.util.List<Versioned<byte[]>> resolveVersions(java.util.List<Versioned<byte[]>> values)
          Given a set of versions, constructs a resolved list of versions based on the compare function above
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VectorClockUtils

public VectorClockUtils()
Method Detail

compare

public static Occurred compare(VectorClock v1,
                               VectorClock v2)
Compare two VectorClocks, the outcomes will be one of the following:
-- Clock 1 is BEFORE clock 2, if there exists an nodeId such that c1(nodeId) <= c2(nodeId) and there does not exist another nodeId such that c1(nodeId) > c2(nodeId).
-- Clock 1 is CONCURRENT to clock 2 if there exists an nodeId, nodeId2 such that c1(nodeId) < c2(nodeId) and c1(nodeId2) > c2(nodeId2)
-- Clock 1 is AFTER clock 2 otherwise

Parameters:
v1 - The first VectorClock
v2 - The second VectorClock

resolveVersions

public static java.util.List<Versioned<byte[]>> resolveVersions(java.util.List<Versioned<byte[]>> values)
Given a set of versions, constructs a resolved list of versions based on the compare function above

Parameters:
values -
Returns:
list of values after resolution

makeClock

public static VectorClock makeClock(java.util.Set<java.lang.Integer> serverIds,
                                    long clockValue,
                                    long timestamp)
Generates a vector clock with the provided values

Parameters:
serverIds - servers in the clock
clockValue - value of the clock for each server entry
timestamp - ts value to be set for the clock
Returns:

makeClockWithCurrentTime

public static VectorClock makeClockWithCurrentTime(java.util.Set<java.lang.Integer> serverIds)
Generates a vector clock with the provided nodes and current time stamp This clock can be used to overwrite the existing value avoiding obsolete version exceptions in most cases, except If the existing Vector Clock was generated in custom way. (i.e. existing vector clock does not use milliseconds)

Parameters:
serverIds - servers in the clock


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu