Skip to content

Commit

Permalink
Added versions of NRP fault tolerance example.
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardalee committed Oct 18, 2024
1 parent 38cec27 commit a1213c7
Show file tree
Hide file tree
Showing 7 changed files with 1,123 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/C/src/leader-election/NRP_FD_NobodyFails.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* This version of NRP_FD simply has the primary (node1) failing after 5 seconds and the backup
* (node2) failing at at 15s. The backup detects simultaneous loss of the heartbeat on both networks
* and hence assumes that the primary has failed rather than there being a network failure. Switch 1
* remains the NRP.
*
* @author Edward A. Lee
* @author Marjan Sirjani
*/
target C {
coordination: decentralized,
timeout: 1000 hours
}
import Switch, Node from "NRP_FD.lf"

federated reactor(heartbeat_period: time = 1 s, delay: time = 10 ms) {
node1 = new Node(heartbeat_period=heartbeat_period, id=1)
node2 = new Node(heartbeat_period=heartbeat_period, id=2)

switch1 = new Switch(id=1)
switch2 = new Switch(id=2)
switch3 = new Switch(id=3)
switch4 = new Switch(id=4)

node1.out -> switch1.in1, switch3.in1 after delay
switch1.out1, switch3.out1 -> node1.in after delay

switch1.out2 -> switch2.in2 after delay
switch2.out2 -> switch1.in2 after delay

switch2.out1, switch4.out1 -> node2.in after delay
node2.out -> switch2.in1, switch4.in1 after delay

switch3.out2 -> switch4.in2 after delay
switch4.out2 -> switch3.in2 after delay
}
Loading

0 comments on commit a1213c7

Please sign in to comment.