Skip to content

It contains the manifest to demo the watch feature of the zookeeper.

Notifications You must be signed in to change notification settings

onebytellc/zookeeper-demo

Repository files navigation

Apache Zookeeper Demo

Overview

This repository hold manifests for Zookeeper demo.

Details:

  1. These files are required for the demo.
├── add-configuration.py # it will create a data node and add configuration on that node.
├── delete-node.py # it will delete the data node 
├── distributed-system-service.py # it will extract data from the data node
└── update_configuration.py # it will update the data node.
  1. Start Zookeeper service:

    • Download Zookeeper binaries.

    • Extract the content:

    tar -xvf apache-zookeeper-x.x.x-bin.tar.gz
    • Rename the default zookeeper config file. It is available in apache-zookeeper-x.x.x-bin/conf folder:
    mv zoo_sample.cfg zoo.cfg
    • Start the service using the command given below:
    # move inside the folder containing zookeeper manifests
    cd apache-zookeeper-x.x.x-bin
    
    # start the service
    sudo ./bin/zkServer.sh start
    • To stop the service, use the command given below:
    sudo ./bin/zkServer.sh stop
  2. Install python3.

  3. Install required python3 modules:

python3 install -r requirements.txt
  1. Now start the distributed system's service:
python3 distributed-system-service.py

It will perform following tasks:

  • It will check whether the data node is created or not, after a defined interval of 5 seconds.
  • Once data node is created it will populate SERVICE_CONFIG dict with the data on the node.
  • It will add watch method on the data node to update the SERVICE_CONFIG if any change occurs on the data node.
  • It will continue to print the SERVICE_CONFIG on the terminal at a interval of 10 seconds.
  1. Create a data node and populate it with data:
python3 add-configuration.py
  1. When the data node is created and populated with data the change can be seen in the service logs on the terminal that was started in the previous step.

  2. Update the data on the node:

python3 update_configuration.py

If the data node is updated successfully it can be seen in the service logs that the config is also updated.

  1. Delete the data node:
python3 delete-node.py