zookeeperdistributedserver's Introduction
Zookeeper Server I have set up a basic Client-Server connection that runs on 3 nodes. The Client.java and Server.java processes are actually both "clients" to Zookeeper. In order to set up 3 servers, on 3 different machines run ./bin/zkServer.sh start in the Zookeeper directory. The Client.java and Server.java will both connect to the 3 servers. Run Server.java first. How this works is that there is a shared "/command" node shared between the Server.java and all Client.javas. When a Client.java wants to send a command, it knows the "/command" node exsists and modifies it. Server.java has set up a Watcher (CommandWatcher.java) that is started when it calls getData() on the "/command" node initally. When any other process calls setDat() on the "/command" node, the Watcher triggers, and the store is edited. You need to reset the watcher each time. In Commandwatcher, a new CommandWatcher is called at the end. In Client.java, it sets a new watcher each time it sends a request to Server.java. zoo.getData(path, boolean=false, -1) makes it so that there are no watchers. zoo.getData(path, Watcher, -1) makes it so that a watcher is set up. Any setData to that path will trigger the watcher. The Client.java also makes a epherenal node "Client1" and sets a watcher on that, and passes the node name to the Server. The Server watcher process writes to that node, and the Client reads that and prints out the response. The Server.java has a /store and /store/shoes nodes that it edits within itself. The Client.java never accesses these nodes directly. To compile the file: You need to include these files in your classpath: zookeeper-3.4.8.jar slf4j-api-1.6.1.jar slf4j-og5j12-1.6.1.jar log4j-1.2.16.jar jline-0.9.94.jar netty-3.7.0.Final.jar zookeeper-3.4.8.jar needs to be first, and I think that the two slf4j jars need to follow it. I tried including the files from the Zookeeper folder but it wouldn't recognize it for some reason. It worked when I put the jars directly inside the folder where you put the java files. If you find a better way to compile let me know. To compile, this was what I used. Change this depending on your folder setup javac -cp ~/zookeeper-3.4.8/build/zookeeper-3.4.8.jar:./slf4j-log4j12-1.6.1.jar:./slf4j-api-1.6.1.jar:./log4j-1.2.16.jar:./jline-0.9.94.jar:./netty-3.7.0.Final.jar Server.java CommandWatcher.java javac -cp ~/zookeeper-3.4.8/build/zookeeper-3.4.8.jar:./slf4j-log4j12-1.6.1.jar:./slf4j-api-1.6.1.jar:./log4j-1.2.16.jar:./jline-0.9.94.jar:./netty-3.7.0.Final.jar Client.java To run, I also needed to include the classpath. java -cp ~/zookeeper-3.4.8/build/zookeeper-3.4.8.jar:./slf4j-log4j12-1.6.1.jar:./slf4j-api-1.6.1.jar:./log4j-1.2.16.jar:./jline-0.9.94.jar:./netty-3.7.0.Final.jar:. Server java -cp ~/zookeeper-3.4.8/build/zookeeper-3.4.8.jar:./slf4j-log4j12-1.6.1.jar:./slf4j-api-1.6.1.jar:./log4j-1.2.16.jar:./jline-0.9.94.jar:./netty-3.7.0.Final.jar:. Client
zookeeperdistributedserver's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.