Git Product home page Git Product logo

leader-election's Introduction

LEADER ELECTION USING ZOOKEEPER

This project is about leader election using zookeeper in which each jvm process will be leader or followers or observer. There can be only one leader at time and when that leader goes down then any of follower should became leader. Observer should not take participate in election but they need a leader too and without leader they should complain.

Requirement:

  1. Java-1.7

  2. Maven-3.x.x(To build project)

  3. Zookeeper-3.4.6

Usage

Build project

mvn clean package

This will create target directory with executable jar file(leader-election-1.0-jar-with-dependencies.jar).

Start zookeeper

You can read about zookeeper from here. From its getting started page you can bring up zookeeper server. By default zookeeper should be started on 2181 port and ip address will be host address of zookeeper.

Submit Node

You can start node by following command. Replace zookeeper host and zookeeper port.

java -jar leader-election-1.0-jar-with-dependencies.jar Ironman zookeeper_host:zookeeper_port   # Ironman node
java -jar leader-election-1.0-jar-with-dependencies.jar Hulk zookeeper_host:zookeeper_port   # Hulk node

Same name will not effect functionality but it is advised to choose unique name so that it will easy to distinguish which is leader now. By starting above node in order, Ironman will became leader and Hulk will became follower and when Ironman will be down then Hulk will became new leader and so on.

Observer Node

java -jar leader-election-1.0-jar-with-dependencies.jar Batman zookeeper_host:zookeeper_port observer     # Batman observer

leader-election's People

Contributors

shivamsharma avatar

Stargazers

 avatar

Watchers

 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.