This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.kiddcorp.zk; | |
| import java.io.IOException; | |
| import java.util.concurrent.CountDownLatch; | |
| import org.apache.zookeeper.WatchedEvent; | |
| import org.apache.zookeeper.Watcher; | |
| import org.apache.zookeeper.Watcher.Event.KeeperState; | |
| import org.apache.zookeeper.ZooKeeper; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.kiddcorp.zk; | |
| import org.apache.zookeeper.CreateMode; | |
| import org.apache.zookeeper.KeeperException; | |
| import org.apache.zookeeper.ZooDefs; | |
| import org.apache.zookeeper.ZooKeeper; | |
| /** | |
| * | |
| * @author jwkidd3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.kiddcorp.zk; | |
| import org.apache.zookeeper.KeeperException; | |
| import org.apache.zookeeper.ZooKeeper; | |
| import org.apache.zookeeper.data.Stat; | |
| /** | |
| * | |
| * @author jwkidd3 | |
| * | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.kiddcorp.zk; | |
| import java.util.concurrent.CountDownLatch; | |
| import org.apache.zookeeper.KeeperException; | |
| import org.apache.zookeeper.WatchedEvent; | |
| import org.apache.zookeeper.Watcher; | |
| import org.apache.zookeeper.ZooKeeper; | |
| import org.apache.zookeeper.data.Stat; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.kiddcorp.zk; | |
| import org.apache.zookeeper.KeeperException; | |
| import org.apache.zookeeper.ZooKeeper; | |
| /** | |
| * | |
| * @author jwkidd3 | |
| * | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.kiddcorp.zk; | |
| import java.util.List; | |
| import org.apache.zookeeper.KeeperException; | |
| import org.apache.zookeeper.ZooKeeper; | |
| import org.apache.zookeeper.data.Stat; | |
| /** | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.kiddcorp.zk; | |
| import org.apache.zookeeper.KeeperException; | |
| import org.apache.zookeeper.ZooKeeper; | |
| /** | |
| * | |
| * @author jwkidd3 | |
| * | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '2' | |
| services: | |
| zoo1: | |
| image: zookeeper | |
| restart: always | |
| ports: | |
| - 2181:2181 | |
| environment: | |
| ZOO_MY_ID: 1 | |
| ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class SyncPrimitive implements Watcher { | |
| static ZooKeeper zk = null; | |
| static Integer mutex; | |
| String root; | |
| SyncPrimitive(String address) { | |
| if(zk == null){ | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Runtime.getRuntime().addShutdownHook(new Thread() { | |
| @Override | |
| public void run() { | |
| for (TheConsumer consumerLoop : consumers) { | |
| consumerLoop.shutdown(); | |
| } | |
| executor.shutdown(); | |
| try { | |
| executor.awaitTermination(5000, TimeUnit.MILLISECONDS); |