+cdd #16799 Add Distributed Data module

Previously know as [patriknw/akka-data-replication](https://github.com/patriknw/akka-data-replication),
which was originally inspired by [jboner/akka-crdt](https://github.com/jboner/akka-crdt).

The functionality is very similar to akka-data-replication 0.11.

Here is a list of the most important changes:

* The package name changed to `akka.cluster.ddata`
* The extension was renamed to `DistributedData`
* The keys changed from strings to classes with unique identifiers and type information of the data values,
  e.g. `ORSetKey[Int]("set2")`
* The optional read consistency parameter was removed from the `Update` message. If you need to read from
  other replicas before performing the update you have to first send a `Get` message and then continue with
  the ``Update`` when the ``GetSuccess`` is received.
* `BigInt` is used in `GCounter` and `PNCounter` instead of `Long`
* Improvements of java api
* Better documentation
This commit is contained in:
Patrik Nordwall 2015-05-17 12:28:47 +02:00
parent bf28260cd0
commit cbe5dd2cf5
69 changed files with 40036 additions and 3 deletions

View file

@ -0,0 +1,45 @@
/**
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.cluster.ddata
import akka.actor.Address
import akka.cluster.Member
import akka.cluster.UniqueAddress
/**
* INTERNAL API
*/
private[akka] object PruningState {
sealed trait PruningPhase
final case class PruningInitialized(seen: Set[Address]) extends PruningPhase
case object PruningPerformed extends PruningPhase
}
/**
* INTERNAL API
*/
private[akka] final case class PruningState(owner: UniqueAddress, phase: PruningState.PruningPhase) {
import PruningState._
def merge(that: PruningState): PruningState =
(this.phase, that.phase) match {
case (PruningPerformed, _) this
case (_, PruningPerformed) that
case (PruningInitialized(thisSeen), PruningInitialized(thatSeen))
if (this.owner == that.owner)
copy(phase = PruningInitialized(thisSeen ++ thatSeen))
else if (Member.addressOrdering.compare(this.owner.address, that.owner.address) > 0)
that
else
this
}
def addSeen(node: Address): PruningState = phase match {
case PruningInitialized(seen)
if (seen(node) || owner.address == node) this
else copy(phase = PruningInitialized(seen + node))
case _ this
}
}