Skip to content

Commit e88ee21

Browse files
merging changes from main
Signed-off-by: Hardik Kapadia <thecoderenroute@gmail.com>
2 parents 1b4c864 + 65fcb94 commit e88ee21

27 files changed

+2196
-57
lines changed

MyDotFile.dot

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
digraph "Net Graph with 26 nodes" {
2+
edge ["class"="link-class"]
3+
4+
"0" ["color"="red","label"=<<b>Init</b>>,"fontcolor"="#1020d0"]
5+
"0" -> "1" ["weight"="9.0"]
6+
"0" -> "2" ["weight"="1.0"]
7+
"1" -> "10" ["weight"="6.0"]
8+
"2" -> "9" ["weight"="9.0"]
9+
"5" -> "4" ["weight"="4.0"]
10+
"4" -> "17" ["weight"="2.0"]
11+
"17" -> "12" ["weight"="8.0"]
12+
"10" -> "25" ["weight"="1.0"]
13+
"25" -> "8" ["weight"="8.0"]
14+
"14" -> "22" ["weight"="4.0"]
15+
"22" -> "7" ["weight"="2.0"]
16+
"20" -> "19" ["weight"="2.0"]
17+
"19" -> "5" ["weight"="9.0"]
18+
"21" -> "16" ["weight"="7.0"]
19+
"16" -> "20" ["weight"="3.0"]
20+
"9" -> "3" ["weight"="1.0"]
21+
"3" -> "23" ["weight"="2.0"]
22+
"23" -> "14" ["weight"="4.0"]
23+
"12" -> "18" ["weight"="8.0"]
24+
"18" -> "6" ["weight"="6.0"]
25+
"7" -> "11" ["weight"="1.0"]
26+
"11" -> "24" ["weight"="7.0"]
27+
"24" -> "13" ["weight"="4.0"]
28+
"8" -> "15" ["weight"="4.0"]
29+
"15" -> "21" ["weight"="3.0"]
30+
31+
// Additional random connections
32+
"13" -> "20" ["weight"="5.0"]
33+
"6" -> "17" ["weight"="7.0"]
34+
"3" -> "10" ["weight"="2.0"]
35+
"9" -> "6" ["weight"="3.0"]
36+
"15" -> "23" ["weight"="1.0"]
37+
"22" -> "19" ["weight"="8.0"]
38+
"4" -> "14" ["weight"="5.0"]
39+
"25" -> "12" ["weight"="3.0"]
40+
"13" -> "5" ["weight"="2.0"]
41+
"11" -> "0" ["weight"="6.0"] // Connect back to the initiator for interesting loop scenarios
42+
}

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,28 @@ sbt clean compile test
8282

8383
> [Simulation Plan](./mutexsimplan.json)
8484
85-
86-
### Telemetry
87-
88-
The below image shows the telemetry data for the simulation run with the `mutexsimplan.json` simulation plan.
89-
90-
![Mutex Telemetry](docs/assets/mutexsimplanrun.png)
91-
9285
### Election
9386
- Chang Roberts
9487
- Franklin
9588
- Dolev Klawe Rodeh
9689
- Tree Election
9790
- Echo Election
9891

99-
> [Election Plan](./electionSimPlan)
92+
> [Election Plan](./electionSimPlan.json)
93+
94+
95+
### Routing
96+
- Chandy-Misra Algorithm with Djikstra-Scholten Termination
97+
- Merlin-Segall Algorithm
98+
- Touegs Algorithm - Floyd Warshall Algorithm in Distributed Setting
99+
- Frederickson Algorithm
100+
101+
> [Routing Plans](./routingsimplan.json)
102+
103+
104+
### Telemetry
105+
106+
The below image shows the telemetry data for the simulation run with the `mutexsimplan.json` simulation plan.
107+
108+
![Mutex Telemetry](docs/assets/mutexsimplanrun.png)
100109

routingsimplan.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"steps": [
3+
{
4+
"dotFilePath": "ExampleNetwork.dot",
5+
"isDirected": false,
6+
"createRing": false,
7+
"createClique": false,
8+
"createBinTree": false,
9+
"enableFailureDetector": false,
10+
"algorithm": "chandy-misra",
11+
"additionalParameters": {
12+
"l": 3,
13+
"totalNodes": 26,
14+
"kill": 1
15+
}
16+
},
17+
{
18+
"dotFilePath": "ExampleNetwork.dot",
19+
"isDirected": false,
20+
"createRing": false,
21+
"createClique": false,
22+
"createBinTree": false,
23+
"enableFailureDetector": false,
24+
"algorithm": "merlin-segall",
25+
"additionalParameters": {
26+
"l": 3,
27+
"totalNodes": 26,
28+
"kill": 1
29+
}
30+
},
31+
{
32+
"dotFilePath": "ExampleNetwork.dot",
33+
"isDirected": false,
34+
"createRing": false,
35+
"createClique": false,
36+
"createBinTree": false,
37+
"enableFailureDetector": false,
38+
"algorithm": "touegs",
39+
"additionalParameters": {
40+
"l": 3,
41+
"totalNodes": 26,
42+
"kill": 1
43+
}
44+
},
45+
{
46+
"dotFilePath": "ExampleNetwork.dot",
47+
"isDirected": false,
48+
"createRing": false,
49+
"createClique": false,
50+
"createBinTree": false,
51+
"enableFailureDetector": false,
52+
"algorithm": "frederickson",
53+
"additionalParameters": {
54+
"l": 3,
55+
"totalNodes": 26,
56+
"kill": 1
57+
}
58+
}
59+
]
60+
}

simplan.json

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44
"dotFilePath": "ExampleNetwork.dot",
55
"isDirected": false,
66
"createRing": false,
7-
"createClique": true,
7+
"createClique": false,
88
"createBinTree": false,
99
"enableFailureDetector": false,
10-
"algorithm": "ricart-agarwala",
10+
"algorithm": "chandy-misra",
1111
"additionalParameters": {
12-
"initiators": 5,
13-
"additional": 7,
12+
"l": 3,
13+
"totalNodes": 26,
1414
"kill": 1
1515
}
1616
},
1717
{
18-
"dotFilePath": "ExampleNetwork.dot",
19-
"isDirected": false,
20-
"createRing": false,
21-
"createClique": true,
22-
"createBinTree": false,
23-
"enableFailureDetector": false,
24-
"algorithm": "ra-carvalho",
25-
"additionalParameters": {
26-
"initiators": 5,
27-
"additional": 10,
28-
"kill": 1
29-
}
18+
"dotFilePath": "ExampleNetwork.dot",
19+
"isDirected": false,
20+
"createRing": false,
21+
"createClique": false,
22+
"createBinTree": false,
23+
"enableFailureDetector": false,
24+
"algorithm": "merlin-segall",
25+
"additionalParameters": {
26+
"l": 3,
27+
"totalNodes": 26,
28+
"kill": 1
29+
}
3030
},
3131
{
3232
"dotFilePath": "ExampleNetwork.dot",
@@ -35,24 +35,52 @@
3535
"createClique": false,
3636
"createBinTree": false,
3737
"enableFailureDetector": false,
38-
"algorithm": "raymonds-algo",
38+
"algorithm": "frederickson",
3939
"additionalParameters": {
40-
"initiators": 5,
41-
"additional": 0,
40+
"l": 3,
41+
"totalNodes": 26,
4242
"kill": 1
4343
}
4444
},
4545
{
46-
"dotFilePath": "ExampleNetwork.dot",
46+
"dotFilePath": "MyDotFile.dot",
4747
"isDirected": false,
4848
"createRing": false,
4949
"createClique": false,
50-
"createBinTree": true,
51-
"enableFailureDetector": true,
52-
"algorithm": "agrawal-elabbadi",
50+
"createBinTree": false,
51+
"enableFailureDetector": false,
52+
"algorithm": "chandy-misra",
5353
"additionalParameters": {
54-
"initiators": 5,
55-
"additional": 0,
54+
"l": 3,
55+
"totalNodes": 26,
56+
"kill": 1
57+
}
58+
},
59+
{
60+
"dotFilePath": "MyDotFile.dot",
61+
"isDirected": false,
62+
"createRing": false,
63+
"createClique": false,
64+
"createBinTree": false,
65+
"enableFailureDetector": false,
66+
"algorithm": "merlin-segall",
67+
"additionalParameters": {
68+
"l": 3,
69+
"totalNodes": 26,
70+
"kill": 1
71+
}
72+
},
73+
{
74+
"dotFilePath": "MyDotFile.dot",
75+
"isDirected": false,
76+
"createRing": false,
77+
"createClique": false,
78+
"createBinTree": false,
79+
"enableFailureDetector": false,
80+
"algorithm": "frederickson",
81+
"additionalParameters": {
82+
"l": 3,
83+
"totalNodes": 26,
5684
"kill": 1
5785
}
5886
},

src/main/project/build.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.9.9

src/main/scala/com/distcomp/common/Messages.scala

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ object TestAndSetSharedMemProtocol {
118118
}
119119

120120

121+
121122
object RicartaAgarwalProtocol {
122123

123124
case class RequestCS(timestamp: Long, from: ActorRef[Message]) extends Message
@@ -254,3 +255,39 @@ object BrachaMessages {
254255

255256
}
256257

258+
259+
object Routing {
260+
261+
case class StartRouting(initializer: String) extends Message
262+
263+
case class ShortestPathEstimate(distance: Int, sender: ActorRef[Message]) extends Message
264+
265+
case class Forward(distance: Int, from: ActorRef[Message], round: Int) extends Message
266+
267+
case class Explore(level: Int, from: ActorRef[Message]) extends Message
268+
269+
case class Reverse(level: Int, ack: Boolean, from: ActorRef[Message]) extends Message
270+
271+
}
272+
273+
object TouegProtocol {
274+
275+
// Message Definitions
276+
277+
case class StartRoutingT(allNodes: Set[ActorRef[Message]], pivots: Map[Int, ActorRef[Message]]) extends Message
278+
case class RequestRouting(round: Int, requester: ActorRef[Message]) extends Message
279+
case class ProvideRoutingInfo(map: Map[ActorRef[Message],Int], from: ActorRef[Message]) extends Message
280+
case object InitiateNextRoundT extends Message
281+
case class SetAllNodes(allNodes: Set[ActorRef[Message]]) extends Message
282+
}
283+
284+
285+
object TerminationDetection {
286+
sealed trait TerminationMessage extends Message
287+
case object Acknowledgment extends TerminationMessage
288+
case class Acknowledgment_true(parent: ActorRef[Message]) extends TerminationMessage
289+
case class Acknowledgment_false(parent: ActorRef[Message]) extends TerminationMessage
290+
case class ParentTerminated(sender: ActorRef[Message]) extends TerminationMessage
291+
sealed trait ControlToken extends Message
292+
case class Token(allClear: Boolean) extends ControlToken
293+
}

src/main/scala/com/distcomp/common/NodeActor.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.distcomp.common
22

3+
import akka.actor.typed.scaladsl.Behaviors
34
import akka.actor.typed.{ActorRef, Behavior}
45
import akka.actor.typed.scaladsl.Behaviors
56
import com.distcomp.common.SimulatorProtocol.{NodeReady, RegisterNode}
@@ -13,6 +14,9 @@ import com.distcomp.election.TreeElection
1314
import com.distcomp.election.Tree
1415
import com.distcomp.mutex.{BakeryAlgorithm, NodeActorBinaryTree, PetersonTournament, PetersonTwoProcess, RicartaAgarwal, RicartaAgarwalCarvalhoRoucairol, TestAndSetMutex, TestAndTestAndSetMutex}
1516

17+
import com.distcomp.mutex.{NodeActorBinaryTree, RicartaAgarwal, RicartaAgarwalCarvalhoRoucairol}
18+
import com.distcomp.routing.{ChandyMisra, Frederickson, Toueg}
19+
1620

1721
object NodeActor {
1822
// NodeActor now needs to know about the SimulatorActor to notify it when ready
@@ -121,6 +125,23 @@ object NodeActor {
121125
case "bracha-toueg" =>
122126
context.log.info("Switching to Bracha Toueg Algorithm")
123127
BrachaToueg(context.self.path.name, edges.keySet)
128+
129+
case "chandy-misra" =>
130+
context.log.info("Switching the algorithm to Chandy-Misra in nodeActor")
131+
ChandyMisra(context.self.path.name, edges, simulator)
132+
133+
case "merlin-segall" =>
134+
context.log.info("Switching to Spanning Tree Behavior, needs tree building")
135+
SpanningTreeBuilder(context.self.path.name, edges.keySet, edges, simulator, timestamp)
136+
137+
case "toueg" =>
138+
context.log.info("Switching the algorithm to Toueg in nodeActor")
139+
Toueg(context.self, edges, Set.empty, simulator)
140+
141+
case "frederickson" =>
142+
context.log.info("Switching the algorithm to Frederickson in nodeActor")
143+
Frederickson(context.self.path.name, edges, 3, simulator)
144+
124145
case _ =>
125146
context.log.info("Algorithm not recognized in nodeActor")
126147
Behaviors.unhandled

0 commit comments

Comments
 (0)