I'm trying to figure out exactly what problems are being solved by Apache ZooKeeper ("ZK"), and perhaps their Recipe Page is the best place to start.
First, I make the following assumptions:
- The ZooKeeper API (available in both Java and C) provides these 7 simple methods , which then allow you to create your own usage patterns, known as “ZK recipes”
- Then you should use these ZK recipes to solve distributed programming problems yourself.
- Or instead of creating your own ZK recipes, you can simply use the ones that come with Apache Curator
- So, in any case, you use ZK recipes (again, homegrown or provided by the curator) to solve problems with distributed computing.
I believe Apache Kafka is an example of this, where Kafka uses ZK to create a distributed queue (which is one of the ZK recipes listed). Therefore, if my assumptions are correct, ZK provides these API methods, and the creators of Apache Kafka either used ZK directly, or used a curator to implement the ZK "Queue" recipe.
If any of my assumptions is wrong, start with a fix! Assuming I'm more or less on the go:
Looking at the list of ZK recipes, I see the following (non-exhaustive):
- Barriers
- Locks
- Leader election
To evaluate these recipes and the solutions they offer, I must first evaluate the problem that they solve! I understand what blocking is from basic Java concurrency, but I just don’t see a use case where “distributed lock” will ever be needed. For the leading elections, all I can think of - as an option for using it in the first place - would be if you created the application that you wanted to send, with a built-in master / subordinate or primary / secondary. Perhaps in this case you would use ZK to implement your own Leadership Election recipe, or maybe just use the Leader Capture curator. As for the barriers, I do not see how they differ from Locks. Therefore, I ask:
- Is my master / subordinate or primary / secondary problem the exact use case for the ZK Leader Election recipe?
- What would be an example of distributed locking? What problems are solved?
- The same goes for barriers: and what's the difference between locks and barriers?
java apache-zookeeper curator
DirtyMikeAndTheBoys
source share