Apache Curator源码地址:https://github.com/apache/curator
Apache Curator是什么?
官方是这样介绍的:
Apache Curator is a Java/JVM client library for Apache ZooKeeper, a distributed coordination service.
翻译:Apache Curator是为ZooKeeper开发的一套Java客户端类库,它是一个分布式协调服务。
Apache Curator includes a high-level API framework and utilities to make using Apache ZooKeeper much easier and more reliable. It also includes recipes for common use cases and extensions such as service discovery and a Java 8 asynchronous DSL.
翻译:Apache Curator包含一套高级API框架和工具类,让我们使用ZooKeeper变得更加容易,可靠。它也包含经常使用的模块和类似服务发现,异步DSL这样的扩展模块。
Apache Curator解决了哪些问题?
- 封装ZooKeeper client与ZooKeeper server之间的连接处理;
- 提供了一套Fluent风格的操作API;
- 提供ZooKeeper各种应用场景(分布式锁,选举)的抽象封装.
Apache Curator包含哪些模块?
从上图我们看到Curator主要client,framework,recipes模块,examples是示例模块,也很重要。
curator-client:封装操作原生ZooKeeper的底层,包括连接,重试,集群等。
curator-framework:提供高层抽象API简化ZooKeeper的使用,更重要的是封装了管理到ZooKeeper集群的连接以及重试机制的复杂性,是Curator对外提供的接口。
curator-recipes:构建在Curator Framework框架之上,实现了原生ZooKeeper中的分布式工具特征recipes。
curator-examples:提供了Curator使用例子,包括服务发现、选举、分布式锁,缓存等。
以上就是Apache Curator大概情况,下一节我们讲基于Apache Curator实现zookeeper分布式锁。