Class VectorClock

  extended by akka.cluster.VectorClock
All Implemented Interfaces:
java.io.Serializable, scala.Equals, scala.Product

public class VectorClock
extends java.lang.Object
implements scala.Product, scala.Serializable

Representation of a Vector-based clock (counting clock), inspired by Lamport logical clocks.

    1) Leslie Lamport (1978). "Time, clocks, and the ordering of events in a distributed system". Communications of the ACM 21 (7): 558-565.
    2) Friedemann Mattern (1988). "Virtual Time and Global States of Distributed Systems". Workshop on Parallel and Distributed Algorithms: pp. 215-226

Based on code from the 'vlock' VectorClock library by Coda Hale.

See Also:
Serialized Form

Nested Class Summary
static class VectorClock.After$
static class VectorClock.Before$
static class VectorClock.Concurrent$
static class VectorClock.Node$
static interface VectorClock.Ordering
static class VectorClock.Same$
static class VectorClock.Timestamp$
Constructor Summary
VectorClock(scala.collection.immutable.TreeMap<java.lang.String,java.lang.Object> versions)
Method Summary
 VectorClock.Ordering compareTo(VectorClock that)
          Compare two vector clocks.
 VectorClock merge(VectorClock that)
          Merges this VectorClock with another VectorClock.
 java.lang.String toString()
 scala.collection.immutable.TreeMap<java.lang.String,java.lang.Object> versions()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface scala.Product
productArity, productElement, productIterator, productPrefix
Methods inherited from interface scala.Equals
canEqual, equals

Constructor Detail


public VectorClock(scala.collection.immutable.TreeMap<java.lang.String,java.lang.Object> versions)
Method Detail


public scala.collection.immutable.TreeMap<java.lang.String,java.lang.Object> versions()


public VectorClock.Ordering compareTo(VectorClock that)
Compare two vector clocks. The outcome will be one of the following:

   1. Clock 1 is SAME (==)       as Clock 2 iff for all i c1(i) == c2(i)
   2. Clock 1 is BEFORE (<)      Clock 2 iff for all i c1(i) <= c2(i) and there exist a j such that c1(j) < c2(j)
   3. Clock 1 is AFTER (>)       Clock 2 iff for all i c1(i) >= c2(i) and there exist a j such that c1(j) > c2(j).
   4. Clock 1 is CONCURRENT (<>) to Clock 2 otherwise.


public VectorClock merge(VectorClock that)
Merges this VectorClock with another VectorClock. E.g. merges its versioned history.


public java.lang.String toString()
toString in class java.lang.Object