Class LWWMap<A,B>
- java.lang.Object
- 
- akka.cluster.ddata.LWWMap<A,B>
 
- 
- All Implemented Interfaces:
- DeltaReplicatedData,- RemovedNodePruning,- ReplicatedData,- ReplicatedDataSerialization,- java.io.Serializable
 
 public final class LWWMap<A,B> extends java.lang.Object implements DeltaReplicatedData, ReplicatedDataSerialization, RemovedNodePruning SpecializedORMapwithLWWRegistervalues.LWWRegisterrelies on synchronized clocks and should only be used when the choice of value is not important for concurrent updates occurring within the clock skew.Instead of using timestamps based on System.currentTimeMillis()time it is possible to use a timestamp value based on something else, for example an increasing version number from a database record that is used for optimistic concurrency control.The defaultClockis using max value ofSystem.currentTimeMillis()andcurrentTimestamp + 1. This means that the timestamp is increased for changes on the same node that occurs within the same millisecond. It also means that it is safe to use theLWWMapwithout synchronized clocks when there is only one active writer, e.g. a Cluster Singleton. Such a single writer should then first read current value withReadMajority(or more) before changing and writing the value withWriteMajority(or more).For first-write-wins semantics you can use the LWWRegister.reverseClock()instead of theLWWRegister.defaultClock()This class is immutable, i.e. "modifying" methods return a new instance. - See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classLWWMap.LWWMapTag$INTERNAL API
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LWWMap<A,B>$colon$plus(scala.Tuple2<A,B> entry, SelfUniqueAddress node)Adds an entry to the mapstatic LWWMap<java.lang.Object,java.lang.Object>apply()booleancontains(A key)static <A,B>
 LWWMap<A,B>create()Java APIscala.Option<ORMap.DeltaOp>delta()The accumulated delta of mutator operations since previousDeltaReplicatedData.resetDelta().static <A,B>
 LWWMap<A,B>empty()scala.collection.immutable.Map<A,B>entries()Scala API: All entries of the map.booleanequals(java.lang.Object o)scala.Option<B>get(A key)java.util.Map<A,B>getEntries()Java API: All entries of the map.inthashCode()booleanisEmpty()LWWMap<A,B>merge(LWWMap<A,B> that)LWWMap<A,B>mergeDelta(ORMap.DeltaOp thatDelta)scala.collection.immutable.Set<UniqueAddress>modifiedByNodes()The nodes that have changed the state for this data and would need pruning when such node is no longer part of the cluster.booleanneedPruningFrom(UniqueAddress removedNode)Does it have any state changes from a specific node, which has been removed from the cluster.LWWMap<A,B>prune(UniqueAddress removedNode, UniqueAddress collapseInto)When theremovednode has been removed from the cluster the state changes from that node will be pruned by collapsing the data entries to another node.LWWMap<A,B>pruningCleanup(UniqueAddress removedNode)Remove data entries from a node that has been removed from the cluster and already been pruned.LWWMap<A,B>put(SelfUniqueAddress node, A key, B value)Adds an entry to the mapLWWMap<A,B>put(SelfUniqueAddress node, A key, B value, LWWRegister.Clock<B> clock)Adds an entry to the map.LWWMap<A,B>remove(SelfUniqueAddress node, A key)Removes an entry from the map.LWWMap<A,B>resetDelta()Reset collection of deltas from mutator operations.intsize()java.lang.StringtoString()static <A,B>
 scala.Option<scala.collection.immutable.Map<A,B>>unapply(LWWMap<A,B> m)Extract theentries().- 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface akka.cluster.ddata.DeltaReplicatedDatamergeDelta
 - 
Methods inherited from interface akka.cluster.ddata.ReplicatedDatamerge
 
- 
 
- 
- 
- 
Method Detail- 
emptypublic static <A,B> LWWMap<A,B> empty() 
 - 
applypublic static LWWMap<java.lang.Object,java.lang.Object> apply() 
 - 
createpublic static <A,B> LWWMap<A,B> create() Java API
 - 
unapplypublic static <A,B> scala.Option<scala.collection.immutable.Map<A,B>> unapply(LWWMap<A,B> m) Extract theentries().
 - 
containspublic boolean contains(A key) 
 - 
isEmptypublic boolean isEmpty() 
 - 
sizepublic int size() 
 - 
$colon$pluspublic LWWMap<A,B> $colon$plus(scala.Tuple2<A,B> entry, SelfUniqueAddress node) Adds an entry to the map
 - 
putpublic LWWMap<A,B> put(SelfUniqueAddress node, A key, B value, LWWRegister.Clock<B> clock) Adds an entry to the map.You can provide your clockimplementation instead of using timestamps based onSystem.currentTimeMillis()time. The timestamp can for example be an increasing version number from a database record that is used for optimistic concurrency control.
 - 
removepublic LWWMap<A,B> remove(SelfUniqueAddress node, A key) Removes an entry from the map. Note that if there is a conflicting update on another node the entry will not be removed after merge.
 - 
resetDeltapublic LWWMap<A,B> resetDelta() Description copied from interface:DeltaReplicatedDataReset collection of deltas from mutator operations. When theReplicatorinvokes themodifyfunction of theUpdatemessage 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 theReplicatorwith theDeltaReplicatedData.delta()accessor. When theReplicatorhas grabbed thedeltait will invoke this method to get a clean data instance without the delta.- Specified by:
- resetDeltain interface- DeltaReplicatedData
 
 - 
deltapublic scala.Option<ORMap.DeltaOp> delta() Description copied from interface:DeltaReplicatedDataThe accumulated delta of mutator operations since previousDeltaReplicatedData.resetDelta(). When theReplicatorinvokes themodifyfunction of theUpdatemessage 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 theReplicatorwith theDeltaReplicatedData.delta()accessor. Themodifyfunction shall still return the full state in the same way asReplicatedDatawithout support for deltas.- Specified by:
- deltain interface- DeltaReplicatedData
 
 - 
mergeDeltapublic LWWMap<A,B> mergeDelta(ORMap.DeltaOp thatDelta) 
 - 
modifiedByNodespublic scala.collection.immutable.Set<UniqueAddress> modifiedByNodes() Description copied from interface:RemovedNodePruningThe 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:
- modifiedByNodesin interface- RemovedNodePruning
 
 - 
needPruningFrompublic boolean needPruningFrom(UniqueAddress removedNode) Description copied from interface:RemovedNodePruningDoes it have any state changes from a specific node, which has been removed from the cluster.- Specified by:
- needPruningFromin interface- RemovedNodePruning
 
 - 
prunepublic LWWMap<A,B> prune(UniqueAddress removedNode, UniqueAddress collapseInto) Description copied from interface:RemovedNodePruningWhen theremovednode has been removed from the cluster the state changes from that node will be pruned by collapsing the data entries to another node.- Specified by:
- prunein interface- RemovedNodePruning
 
 - 
pruningCleanuppublic LWWMap<A,B> pruningCleanup(UniqueAddress removedNode) Description copied from interface:RemovedNodePruningRemove data entries from a node that has been removed from the cluster and already been pruned.- Specified by:
- pruningCleanupin interface- RemovedNodePruning
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
equalspublic boolean equals(java.lang.Object o) - Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 
- 
 
-