Flink中JobMaster、ResourceManager、Dispatcher、WebMonitorEndpoint提供了基于zookeeper高可用,涉及到leader选举与监听, leader选举基于zookeeper开源客户端CuratorFramework 的LeaderLatch方式实现,监听则通过NodeCache实现。基于此Flink提供了zookeeper高可用ZooKeeperHaServices, 通过该工具类可以创建LeaderElectionService与LeaderRetrievalService,包含了对应与zookeeper的znode节点分别是
/resource_manager_lock
/dispatcher_lock
/job_manager_lock
/rest_server_lock
LeaderElectionService用于leader选举服务,基于zk的实现类是ZooKeeperLeaderElectionService,LeaderRetrievalService用于监听leader恢复服务,基于zk的实现类是ZooKeeperLeaderRetrievalService。
涉及到两个重要的角色&