Add minimum cap for ReadMajority/WriteMajority #21618

This commit is contained in:
inakov 2017-01-18 14:13:40 +02:00
parent 91d6a3f125
commit e043a9fffe
4 changed files with 56 additions and 7 deletions

View file

@ -186,6 +186,14 @@ The ``Replicator`` writes and reads to a majority of replicas, i.e. **N / 2 + 1*
in a 5 node cluster it writes to 3 nodes and reads from 3 nodes. In a 6 node cluster it writes
to 4 nodes and reads from 4 nodes.
You can define a minimum number of nodes for ``WriteMajority`` and ``ReadMajority``,
this will minimize the risk of reading steal data. Minimum cap is
provided by minCap property of ``WriteMajority`` and ``ReadMajority`` and defines the required majority.
If the minCap is higher then **N / 2 + 1** the minCap will be used.
For example if the minCap is 5 the ``WriteMajority`` and ``ReadMajority`` for cluster of 3 nodes will be 3, for
cluster of 6 nodes will be 5 and for cluster of 12 nodes will be 7(**N / 2 + 1**).
Here is an example of using ``WriteMajority`` and ``ReadMajority``:
.. includecode:: ../../../akka-samples/akka-sample-distributed-data-scala/src/main/scala/sample/distributeddata/ShoppingCart.scala#read-write-majority