[MP]Morning Pater CRDT
There are two approaches to replication
CRDT
- Conflict-free replicated Data Type;
- Commutative Replicated Data Types
- Convergent Replicated Data Types
Operations at primary
- Date type:
Convergent Replicated Data Types.
Replicate the result
- Date type:
Commutative Replicated Data Types.
简单累加时钟模型
两个计数器 每个计数器要么增长要么保持不变,对于两个时钟的一系列操作,最终一致是Max(每个步骤)并将Max的结果求和
两个时钟模型
- 两个时钟一个加一个减
- 需要全局的时钟来计算所有可以减的值(当前的净资产)【依赖于同步】
如何实现CRDT
1:LastWriter-Win
merge函数就是取时间戳的最大值
2: 多值寄存器
merge就是依赖于一个版本控制向量,取得最大的向量的数就是最终结果
3:Grow Set
4: 2P-Set
两步骤操作,一个操作中可以被增加和减少,但是第二步中智能减少
5:A Last-Writer-Wins element Set
keeps an add-set and a remove-set, with timestamped entries
6:A 2P2P-Graph
which is the combination of two 2P-Sets for vertices and edges
7:An add-only monotonic DAG.
8:An add-and-remove partial order data type
A couple of data types supporting collaborative text editing