Coder Social home page Coder Social logo

basic-zk's Introduction

basic-zk

High Availability and Fault Tolerance using Zookeeper

Download and install zookeeper.

Building the code: Download and install maven. Use "mvn package -DskipTests" to build the code. A jar called -jar-with-dependencies.jar is created under the "target" folder.

Ensure zookeeper server is running before attempting to run this code.

  1. Basic FT: Restart applications if they have terminated Running the application: java -cp target/maven-archetype-quickstart-1.0-jar-with-dependencies.jar com.zookeeper.client.ClusterNode For e.g.: java -cp target/maven-archetype-quickstart-1.0-jar-with-dependencies.jar com.zookeeper.client.ClusterNode localhost:2181 3

This will start 3 processes, out of which exactly 1 is master, and the rest are slaves. Kill one of the slaves - the master node will create another node to replace the one that expired. Kill the master node - one of the remaining slaves becomes the master, and creates new applications to replace the ones that have terminated.

  1. Monitoring an external application: Choose an application to monitor, and start it up. In this case, it will be "node index.js" Create a script to start the application, say for e.g. startServer.sh

Start the program through: java -cp target/maven-archetype-quickstart-1.0-jar-with-dependencies.jar com.zookeeper.client.MonitorApplication <script to start the application>

For e.g.: java -cp target/maven-archetype-quickstart-1.0-jar-with-dependencies.jar com.zookeeper.client.MonitorApplication localhost:2181 "node index.js" ~/startServer.sh

Start multiple instances of the program, and one of them will become the master, the rest act as slaves. If the application being monitored expires, then the master terminates itself. One of the remaining nodes becomes the master, and starts the application using the script provided.

basic-zk's People

Contributors

prashravoor avatar mayankmetha avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.