Introduction to zookeeper
Zookeeper is a distributed, open-source distributed application.ProgramThe coordination service contains a simple set of primitives. distributed applications can implement synchronization services, configuration maintenance, and naming services based on it. Currently, Zookeeper is used in hadoop/hbase for node management. With zookeeper, you can easily develop some distributed control tools, such as distributed lock, barrier, countdown, and semaphore, some even use zookeeper to develop a distributed collections.
Zookeeper Client
We build a distributed logserver system, mainly using Zookeeper's directory service. zookeeper itself has APIs for us to use some of Zookeeper's features. However, Zookeeper's API interfaces are too stiff and inconvenient to use, however, many companies are using such a powerful zookeeper. They will certainly find problems with the existing APIs and certainly have a lot of excellent APIs. So we found the curator, curator is an open-source zookeeper client framework of Netflix. during the use of zookeeper, Netflix found that the client provided by zookeeper is too low-layer, and the application side needs to handle a lot of things on its own, so it wrapped it on the basis of it, provides a better client framework.
Curator mainly solves three problems:
Encapsulate connection processing between zookeeper client and zookeeper server;
Provides a set of fluent APIs;
Provides abstract encapsulation of zookeeper application scenarios (recipe, such as the shared lock service and cluster leader election mechanism.
The Zookeeper implemented by curator has the following features:
Use curator
Use curator to register a logserver with zookeeper.CodeSee the init method in the zookeepermanager class of logserver:
Use curator to obtain the logserver information registered to zookeeper from zookeeper. For the code, see the init method in the zoologclient class of the logserver project:
To sum up, you can use curator to register a logserver with zookeeper. The log client then uses curator to obtain the registered zookeeper information. When a logserver is on the machine, Zookeeper can notify the log client, to obtain the new logserver service.