The aim is to implement two election distributed algorithms (i.e. Chang and Roberts algorithm, Bully algorithm). Furthermore, the following services must be implemented:
- Register service;
- Heartbeat monitoring service;
- Logging information service;
To deploy the application should be used Docker containers on EC2 instance.
For the local execution are required Docker and Docker Compose. Furthermore, a requirements.txt file has been defined to install all the python external libraries:
# to execute in SDCC/sdcc/
pip install -r requirements.txt
The complete list of flags is:
$ python3 run.py -h
usage: run.py [-h] [-v] [-d] [-a {ring,bully}] [-c CONFIG_FILE]
Implementation of distributed election algorithms. Generic node.
optional arguments:
-h, --help show this help message and exit
-v, --verbose increase output verbosity
-d, --delay generate a random delay to forwarding messages
-a {ring,bully}, --algorithm {ring,bully}
ring by default
-c CONFIG_FILE, --config_file CONFIG_FILE
needed a config file in json format
The local_config.json (in SDCC/sdcc) file has been defined to manage all network settings (i.e., IP addresses, port numbers). To display the options set:
python3 run.py -h
Firstly you make running the register node:
# to execute in SDCC/sdcc/register. The -v flag provides a verbose execution (i.e., all messages received and sent are shown)
python3 run.py -v -c ../local_config.json
A single node can be executed as:
# to execute in SDCC/sdcc/node. Without the '-a bully' option node runs the ring-based alg.
python3 run.py -v -a bully -c ../local_config.json
Test execution can be handled as:
# to execute in SDCC/sdcc
sudo python3 run_tests.py
Ansible service is used to automate the Docker installation and to copy the application code.
# To check the ec2 instance (optional)
ansible -i hosts.ini -m ping all
# To execute ansible in SDCC/sdcc/ansible
ansible-playbook -v -i hosts.ini deploy.yaml
# Connect to the EC2 instance
ssh -i "SDCC_key.pem" ubuntu@ip_instance
# To execute the whole application
sudo docker-compose up
Please see report for more details.