学习快照算法
Chandy & Lamport Snapshot Algorithm 是在分布式系统中获取全局状态的算法。伪代码如下:
- Marker receiving rule:
When I receive a marker on channel c
If (I am not yet taking part in this snapshot) {
Record my state now (count # of each commodity in hand only)
Do Marker sending rule
Record that the state of channel c is empty
Begin keeping track of state all other incoming channels (except c):
} else if this marker is coming in from a new channel c {
Record that the state of channel c is all messages it has received since it began keeping track. (No more coming.)
Stop recording any further messages on channel c (they are now post-shapshot)
If (this is last channel to receive marker on) send records to Monitor process
}
- Marker sending rule:
For (each outgoing channel c) {
Send one marker message over c
}
(未完待续...)