Project of Lecture DBE14 Distributed Systems
- Markus Drespling
- Frederick Dehner
- David Lüttmann
Install:
- Update pip:
pip install --upgrade pip
- Update setuptools:
pip install --upgrade setuptools
- Install localshit:
pip install -e .
Run frontend server:
frontend
Run backend server(s) with custom frontend server IP:
localshit -f "172.17.0.2"
Open client:
http://[frontend-ip]:8081/index.html
Run tests:
pytest tests -s
All configuration parameters are stored in utils/config.py
:
config = {
"frontend_server": "192.168.0.179",
"ring_multicast_address": "224.1.1.1",
"ring_multicast_port": 5007,
"ring_unicast_port": 10001,
"content_websocket_port": 10013,
"frontend_unicast_port": 10012,
"frontend_webserver_port": 8081,
"reliable_socket": 10033,
"loglevel": "debug",
"chuck_norris": True,
"quote_intervall": 25,
"announcement_timeout": 1,
"heartbeat_intervall": 2,
"heartbeat_timeout": 6,
}
You can use docker to run multiple servers on one host. If you use multiple servers distributed on more than one host, use Vagrant because Docker doesn't support bridged networks to the local area network.
Build Docker image for backends (after every change)
docker build -f Dockerfile.backend -t localshit .
Run docker
docker run --rm localshit
Build Docker image for backends (after every change)
docker build -f Dockerfile.client -t localshit-client .
Run docker
docker run --rm localshit-client
Build Docker image for backends (after every change)
docker build -f Dockerfile.frontend -t localshit-frontend .
Run docker
docker run --rm localshit-frontend
pytest tests -s
Type | Parameter 1 | Parameter 2 | Description |
---|---|---|---|
SA | IP address | - | Service announcement - announce backend service to multicast |
SE | leader candidate IP | isLeader (True/False) | Start election - election messages in the ring |
HB | heartbeat GUID | - | Heartbeat messages |
FF | IP address of failed node | - | Failure message when heartbeat fails |
RP | IP address | - | Reply to sender of service announcement with own IP address |
LE | IP address of current leader | - | notifies frontend server about current leader |
CO | content | - | Content messages - send to clients |
CL | message | - | Notify clients that websocket of backend server is shutting down |
CR | comment | - | Message type for comments on quotes from the client |
AA | IP address | - | Send initial message via multicast to get a database update |
Because Docker doesn't support bridged networking, we choose Vagrant containers with VirtualBox.
- Install VirtualBox
- Install Vagrant
- Add hashicorp/bionic64 box image:
vagrant box add hashicorp/bionic64
- (Init Vagrantfile:
vagrant init hashicorp/bionic64
) vagrant up
sudo apt-get updates
sudo apt-get -y install python3-pip
- Update setuptools:
pip3 install setuptools
- Install localshit: pip3 install -e .
- sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
- Update pip:
pip install --upgrade pip
- Update setuptools:
pip install --upgrade setuptools
- Install localshit:
pip install -e .
- Start vagrant VM:
vagrant up
- Connect to VM via ssh:
vagrant ssh
- Navigate to
/home/vagrant/code
and start the server withlocalshit -f "[frontend_ip]"
- To stop the VM, use
vagrant halt
To run the examles within a docker container use
docker run -it --rm -v "$PWD/examples":"/usr/src/widget_app" python:3 python /usr/src/widget_app/dynamicdiscover.py