CRDT Module

CRDT module was designed to create collaborative editing applications with CRDT (conflict-free replicated data type) approach. Well suitable for some simple solutions (for example, a scalable eventually consistent key-value storage with CRDT conflict resolutions).

You can add CRDT module to your project by inserting dependency in pom.xml:

<dependency>
    <groupId>io.datakernel</groupId>
    <artifactId>datakernel-crdt</artifactId>
    <version>3.0.0-beta1</version>
</dependency>

Example

Note: To run the examples, you need to clone DataKernel from GitHub:
$ git clone https://github.com/softindex/datakernel
And import it as a Maven project. Before running the examples, build the project.
These examples are located at datakernel -> examples -> cloud -> crdt.

In this example, we have two replicas - independent nodes which store different information.

First replica stores:

first = [#1, #2, #3, #4]
second = ["#3", "#4", "#5", "#6"]

Second replica stores:

first = [#3, #4, #5, #6]
second = [#2, #4, <removed> #5, <removed> #6]

Then we merge replicas with CRDT approach and receive a result:

first = [#1, #2, #3, #4, #5, #6]
second = [#2, #3, #4]

In the example LWWSet (Last Write Wins) is utilized. It implements Set interface and is basically a Map<E, Timestamp>. Timestamp allows to merge LWWSets by choosing the most relevant versions in case of conflicts.