Class GCounter

    • Constructor Detail

      • GCounter

        public GCounter​(scala.collection.immutable.Map<UniqueAddress,​scala.math.BigInt> state,
                        scala.Option<GCounter> delta)
    • Method Detail

      • $lessinit$greater$default$1

        public static scala.collection.immutable.Map<UniqueAddress,​scala.math.BigInt> $lessinit$greater$default$1()
        Implements a 'Growing Counter' CRDT, also called a 'G-Counter'.

        It is described in the paper A comprehensive study of Convergent and Commutative Replicated Data Types.

        A G-Counter is a increment-only counter (inspired by vector clocks) in which only increment and merge are possible. Incrementing the counter adds 1 to the count for the current node. Divergent histories are resolved by taking the maximum count for each node (like a vector clock merge). The value of the counter is the sum of all node counts.

        This class is immutable, i.e. "modifying" methods return a new instance.

      • $lessinit$greater$default$2

        public static scala.Option<GCounter> $lessinit$greater$default$2()
      • empty

        public static GCounter empty()
      • apply

        public static GCounter apply()
      • create

        public static GCounter create()
        Java API
      • unapply

        public static scala.Option<scala.math.BigInt> unapply​(GCounter c)
        Extract the value().
      • state

        public scala.collection.immutable.Map<UniqueAddress,​scala.math.BigInt> state()
      • delta

        public scala.Option<GCounter> delta()
        Description copied from interface: DeltaReplicatedData
        The accumulated delta of mutator operations since previous DeltaReplicatedData.resetDelta(). When the Replicator invokes the modify function of the Update message and the user code is invoking one or more mutator operations the data is collecting the delta of the operations and makes it available for the Replicator with the DeltaReplicatedData.delta() accessor. The modify function shall still return the full state in the same way as ReplicatedData without support for deltas.
        Specified by:
        delta in interface DeltaReplicatedData
      • value

        public scala.math.BigInt value()
        Scala API: Current total value of the counter.
      • getValue

        public java.math.BigInteger getValue()
        Java API: Current total value of the counter.
      • $colon$plus

        public GCounter $colon$plus​(long n,
                                    SelfUniqueAddress node)
        Increment the counter with the delta n specified. The delta must be zero or positive.
      • $plus

        public GCounter $plus​(long n,
                              Cluster node)
        Deprecated.
        Use `:+` that takes a `SelfUniqueAddress` parameter instead. Since 2.5.20.
      • increment

        public GCounter increment​(SelfUniqueAddress node,
                                  long n)
        Increment the counter with the delta n specified. The delta n must be zero or positive.
      • increment

        public GCounter increment​(Cluster node,
                                  long n)
        Deprecated.
        Use `increment` that takes a `SelfUniqueAddress` parameter instead. Since 2.5.20.
      • increment$default$2

        public long increment$default$2()
      • zero

        public GCounter zero()
        Description copied from interface: ReplicatedDelta
        The empty full state. This is used when a delta is received and no existing full state exists on the receiving side. Then the delta is merged into the zero to create the initial full state.
        Specified by:
        zero in interface ReplicatedDelta
      • resetDelta

        public GCounter resetDelta()
        Description copied from interface: DeltaReplicatedData
        Reset collection of deltas from mutator operations. When the Replicator invokes the modify function of the Update message the delta is always "reset" and when the user code is invoking one or more mutator operations the data is collecting the delta of the operations and makes it available for the Replicator with the DeltaReplicatedData.delta() accessor. When the Replicator has grabbed the delta it will invoke this method to get a clean data instance without the delta.
        Specified by:
        resetDelta in interface DeltaReplicatedData
      • modifiedByNodes

        public scala.collection.immutable.Set<UniqueAddress> modifiedByNodes()
        Description copied from interface: RemovedNodePruning
        The nodes that have changed the state for this data and would need pruning when such node is no longer part of the cluster.
        Specified by:
        modifiedByNodes in interface RemovedNodePruning
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object