Final project for the course of Distributed Systems and Cloud Computing of the University of Rome Tor Vergata (faculty Computer Engineering), 2023/2024. More details on the project can be found in the folder Documentation.
To simulate the execution of a leader election algorithm follow the next steps:
- Create an EC2 instance.
- Open one terminal in the directory where you have saved the rsa key and connect to the EC2 instance:
ssh -i <filename>.pem ec2-user@<public-ip>
- Install git on EC2 and clone this repository:
sudo yum update
sudo yum install git -y
git clone https://github.com/martinalupini/progetto-SDCC
- Install Docker and Docker Compose:
./install_docker.sh
Note
After running the script the instance will reboot. Wait a few seconds and connect again to the instance by typing from your terminal the command at point 1.
Now the environment is ready to start the simulation.
Warning
This step is mandatory
At first you need to choose between "Chang-Roberts" and "Bully" by writing in the file configuration.txt. If no algorithm is selected the default algorithm is Chang-Roberts.
- To start the simulation type from the directory progetto-SDCC/:
./Scripts/start.sh
After that 17 containers (15 nodes and the two registries) will be started. At the end, the node with the higher ID will be elected.
In the directory Scripts/ you can find several scripts to interact with the simulation. Once the composition is up and running, I suggest to open a new terminal, connect to the instance and run the following scripts from the directory progetto-SDCC/.
- To stop all the nodes but not the registries type:
./Scripts/stop_all.sh
- To see more in detail how the algorithm works you can start one container at a time by typing:
./Scripts/start_node.sh <container name>
- If you want to stop one container individually (for example the leader to see how the nodes will elect a new leader) you can run:
./Scripts/stop_node.sh <container name>
Warning
If you want to change the alghoritm you need to build the containers' images again. To do that and also start the simulation run again:
docker-compose build
docker-compose up