GithubHelp home page GithubHelp logo

brucemen711 / zookeeper-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bkatwal/zookeeper-demo

0.0 1.0 0.0 149 KB

Sample Distributed system created using spring boot app server and zookeeper as backbone

Java 100.00%

zookeeper-demo's Introduction

GitLab build status

alt text

Key features supported:

  • Model a database that is replicated across multiple servers.

  • The system should scale horizontally, meaning if any new server instance is added to the cluster, it should have the latest data and start serving update/read requests.

  • Data consistency. All update requests will be forwarded to the leader, and then the leader will broadcast data to all active servers and then returns the update status.

  • Data can be read from any of the replicas without any inconsistencies.

  • All server in the cluster will store the cluster state — Information like, who is the leader and server state(list of live/dead servers in the cluster). This info is required by the leader server to broadcast update request to active servers, and active follower servers need to forward any update request to their leader.

  • In the event of a change in the cluster state(leader goes down/any server goes down), all servers in the cluster need to be notified and store the latest change in local cluster data storage.

Setup and Usage

  1. Install and start Apache Zookeeper in any port. Follow guide: https://zookeeper.apache.org/doc/r3.1.2/zookeeperStarted.html
  2. Use below command to start the application in 3 ports:
java -Dserver.port=8081 -Dzk.url=localhost:2181 -Dleader.algo=2 -jar target/bkatwal-zookeeper-demo-1.0-SNAPSHOT.jar
java -Dserver.port=8082 -Dzk.url=localhost:2181 -Dleader.algo=2 -jar target/bkatwal-zookeeper-demo-1.0-SNAPSHOT.jar
java -Dserver.port=8081 -Dzk.url=localhost:2181 -Dleader.algo=2 -jar target/bkatwal-zookeeper-demo-1.0-SNAPSHOT.jar

server.port is spring app server port, zk.url is your zookeeper connection string and leader.algo if passed 2, application will use ephemeral sequential znodes for leader election else will use ephemeral znodes.

Look at swagger for API documentation for API details, Access swagger UI at /swagger-ui.html

GET /clusterInfo - This API will display all the nodes in cluster, current list of live nodes and current master.

GET /persons - This API will display all the saved Person.

PUT /person/{id}/{name} - Use this to save person data.

zookeeper-demo's People

Contributors

bkatwal avatar

Watchers

James Cloos 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.