I want to use the ZooKeeper as a service registry which replicated identical services can register themselves and clients may discover available services's url to call them. As a starter to ZooKeeper I need the basic java code for registering and discovering the services on ZooKeeper.
ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. All of these kinds of services are used in some form or another by distributed applications.
You can implement dynamic service discovery by including an additional indirection step through ZooKeeper. The HS2 instances register with ZooKeeper under a namespace. When a HiveServer2 instance comes up, it registers itself with ZooKeeper by adding a znode in ZooKeeper.
Microservices Service Registry A service registry is a database used to keep track of the available instances of each microservice in an application. The service registry needs to be updated each time a new service comes online and whenever a service is taken offline or becomes unavailable.
To start the ZooKeeper server on a Linux system, use the Zookeeper/zookeeper/bin/zkServer.sh restart command from your Watson Explorer installation directory. On Microsoft Windows systems, use the Zookeeper\zookeeper\bin\zkServer. cmd command.
Check out Curator Discovery (part of Apache Curator), a Zookeeper-based service registry written in Java.
In SOA/distributed systems, services need to find each other. i.e. a web service might need to find a caching service, etc. DNS can be used for this but it is nowhere near flexible enough for services that are constantly changing. A Service Discovery system provides a mechanism for:
- Services to register their availability
- Locating a single instance of a particular service
- Notifying when the instances of a service change
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With