DA project submission #2 要求实现Localized Causal Broadcast,具体的定义在project repo的README中
- You must implement this on top of uniform reliable broadcast (URB).
- The
CONFIG
command-line argument for this algorithm consists of a file that contains an integerm
in its first line.m
defines how many messages each process should broadcast.- For a system of
n
processes, there aren
more lines in theCONFIG
file. Each linei
corresponds to processi
, and such a line indicates the identities of other processes which can affect processi
. See the example below.
- The FIFO property still needs to be maintained by localized causal broadcast. That is, messages broadcast by the same process must not be delivered in a different order then they were broadcast.
- The output format for localized causal broadcast remains the same as before.
Example ofCONFIG
file for a system of5
processes, where each one broadcastsm
messages:
1
2
3
4
5
6 m
1 4 5
2 1
3 1 2
4
5 3 4Note: Lines should end in
\n
, and numbers are separated by white-space characters.In this example we specify that process
1
is affected by messages broadcast by processes4
and5
. Similarly, we specify that process2
is only affected by process1
. Process4
is not affected by any other processes. Process5
is affected by processes3
and4
.We say that a process
x
is affected by a processz
if all the messages which processz
broadcasts and which processx
delivers become dependencies for all future messages broadcast by processx
. We call these dependencies localized. If a process is not affected by any other process, messages it broadcasts only depend on its previously broadcast messages (due to the FIFO property).Note: In the default causal broadcast (this algorithm will be discussed in one of the lectures) each process affects
all
processes. In this algorithm we can selectively define which process affects some other process.
关于dependency
process is affected by other processes,但消息的dependency是对每一条消息而言的。
(当用书上的vector clock方法实现时)也就是说,每一条LCB层消息在broadcast的时间点,需要拿到这个时间点、当前进程的vector clock,作为自己的dependency clock。可以作为消息内容传给其它process。
其它process收到消息,判断能否deliver,即判断自己的vector clock是否大于消息的dependency clock。
关于FIFO
根据sequence number可以保证FIFO。
基于vector clock也可以保证FIFO。
对于其它进程,都是在deliver消息时,增加该进程对应的vector clock值。
对于当前进程,可以做一些调整,在broadcast消息时就修改对应的vector clock值。
🌰:
1 | # in process 1 |
那么其它进程收到2时,必须先deliver 1。
可以保证当前进程广播的每一条消息,都有不同的vector clock(即使当前进程没有affected by任何进程),从而保证FIFO。
这样在deliver的时候,可以统一处理vector clock,而不用管sequence number。