Package io.vertx.spi.cluster.zookeeper

## Class ZookeeperClusterManager

- java.lang.Object
- - io.vertx.spi.cluster.zookeeper.ZookeeperClusterManager

- All Implemented Interfaces:
    `ClusteredNode`, `ClusterManager`, `VertxServiceProvider`, `org.apache.curator.framework.recipes.cache.PathChildrenCacheListener`

      public class ZookeeperClusterManager
      extends Object
      implements ClusterManager, org.apache.curator.framework.recipes.cache.PathChildrenCacheListener

  A cluster manager that uses Zookeeper
  Author:
    Stream.Liu

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ZookeeperClusterManager()` |
    `ZookeeperClusterManager​(JsonObject config)` |
    `ZookeeperClusterManager​(String resourceLocation)` |
    `ZookeeperClusterManager​(org.apache.curator.framework.CuratorFramework curator)` |
    `ZookeeperClusterManager​(org.apache.curator.framework.CuratorFramework curator, String nodeId)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addRegistration​(String address, RegistrationInfo registrationInfo, Completable<Void> promise)` | Share a new messaging handler registration with other nodes in the cluster.
    `void` | `childEvent​(org.apache.curator.framework.CuratorFramework client, org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent event)` |
    `<K,​V> void` | `getAsyncMap​(String name, Completable<AsyncMap<K,​V>> promise)` | Return an `AsyncMap` for the given `name`.
    `JsonObject` | `getConfig()` |
    `void` | `getCounter​(String name, Completable<Counter> promise)` | Return a `Counter` for the given `name`.
    `org.apache.curator.framework.CuratorFramework` | `getCuratorFramework()` |
    `void` | `getLockWithTimeout​(String name, long timeout, Completable<Lock> promise)` | Attempts to acquire a `Lock` for the given `name` within `timeout` milliseconds.
    `String` | `getNodeId()` | Return the unique node identifier for this node.
    `NodeInfo` | `getNodeInfo()` | Get details about this clustered node.
    `void` | `getNodeInfo​(String nodeId, Completable<NodeInfo> promise)` | Get details about a specific node in the cluster.
    `List<String>` | `getNodes()` | Return a list of node identifiers corresponding to the nodes in the cluster.
    `void` | `getRegistrations​(String address, Completable<List<RegistrationInfo>> promise)` | Get the messaging handler currently registered in the cluster.
    `<K,​V> Map<K,​V>` | `getSyncMap​(String name)` | Return a synchronous map for the given `name`.
    `void` | `init​(Vertx vertx)` | Invoked before this cluster node tries to join the cluster.
    `boolean` | `isActive()` | Is the cluster manager active?
    `void` | `join​(Completable<Void> promise)` | Join the cluster.
    `void` | `leave​(Completable<Void> promise)` | Leave the cluster.
    `void` | `nodeListener​(NodeListener listener)` | Set a listener that will be called when a node joins or leaves the cluster.
    `void` | `registrationListener​(RegistrationListener registrationListener)` | Implementations must signal the provided `registrationListener` when messaging handler registrations are added or removed by sending a `RegistrationUpdateEvent` with `RegistrationListener.registrationsUpdated(RegistrationUpdateEvent)`.
    `void` | `removeRegistration​(String address, RegistrationInfo registrationInfo, Completable<Void> promise)` | Signal removal of a messaging handler registration to other nodes in the cluster.
    `void` | `setConfig​(JsonObject conf)` |
    `void` | `setNodeInfo​(NodeInfo nodeInfo, Completable<Void> promise)` | Store the details about this clustered node.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface io.vertx.core.spi.cluster.ClusterManager

      `clusterHost, clusterPublicHost, init`

- - ### Constructor Detail

    - #### ZookeeperClusterManager

          public ZookeeperClusterManager()

    - #### ZookeeperClusterManager

          public ZookeeperClusterManager​(org.apache.curator.framework.CuratorFramework curator)

    - #### ZookeeperClusterManager

          public ZookeeperClusterManager​(String resourceLocation)

    - #### ZookeeperClusterManager

          public ZookeeperClusterManager​(org.apache.curator.framework.CuratorFramework curator,
                                         String nodeId)

    - #### ZookeeperClusterManager

          public ZookeeperClusterManager​(JsonObject config)

  - ### Method Detail

    - #### setConfig

          public void setConfig​(JsonObject conf)

    - #### getConfig

          public JsonObject getConfig()

    - #### getCuratorFramework

          public org.apache.curator.framework.CuratorFramework getCuratorFramework()

    - #### init

          public void init​(Vertx vertx)

      Description copied from interface: `ClusterManager`
      Invoked before this cluster node tries to join the cluster.
      Specified by:
        `init` in interface `ClusterManager`
      Parameters:
        `vertx` - the Vert.x instance

    - #### getAsyncMap

          public <K,​V> void getAsyncMap​(String name,
                                              Completable<AsyncMap<K,​V>> promise)

      Description copied from interface: `ClusterManager`
      Return an `AsyncMap` for the given `name`.
      Specified by:
        `getAsyncMap` in interface `ClusterManager`

    - #### getSyncMap

          public <K,​V> Map<K,​V> getSyncMap​(String name)

      Description copied from interface: `ClusterManager`
      Return a synchronous map for the given `name`.
      Specified by:
        `getSyncMap` in interface `ClusterManager`

    - #### getLockWithTimeout

          public void getLockWithTimeout​(String name,
                                         long timeout,
                                         Completable<Lock> promise)

      Description copied from interface: `ClusterManager`
      Attempts to acquire a `Lock` for the given `name` within `timeout` milliseconds.
      Specified by:
        `getLockWithTimeout` in interface `ClusterManager`

    - #### getCounter

          public void getCounter​(String name,
                                 Completable<Counter> promise)

      Description copied from interface: `ClusterManager`
      Return a `Counter` for the given `name`.
      Specified by:
        `getCounter` in interface `ClusterManager`

    - #### getNodeId

          public String getNodeId()

      Description copied from interface: `ClusteredNode`
      Return the unique node identifier for this node.
      Specified by:
        `getNodeId` in interface `ClusteredNode`

    - #### getNodes

          public List<String> getNodes()

      Description copied from interface: `ClusteredNode`
      Return a list of node identifiers corresponding to the nodes in the cluster.
      Specified by:
        `getNodes` in interface `ClusteredNode`

    - #### registrationListener

          public void registrationListener​(RegistrationListener registrationListener)

      Description copied from interface: `ClusterManager`
      Implementations must signal the provided `registrationListener` when messaging handler registrations are added or removed by sending a `RegistrationUpdateEvent` with `RegistrationListener.registrationsUpdated(RegistrationUpdateEvent)`.
      Specified by:
        `registrationListener` in interface `ClusterManager`
      Parameters:
        `registrationListener` - the registration listener

    - #### nodeListener

          public void nodeListener​(NodeListener listener)

      Description copied from interface: `ClusterManager`
      Set a listener that will be called when a node joins or leaves the cluster.
      Specified by:
        `nodeListener` in interface `ClusterManager`

    - #### setNodeInfo

          public void setNodeInfo​(NodeInfo nodeInfo,
                                  Completable<Void> promise)

      Description copied from interface: `ClusterManager`
      Store the details about this clustered node.
      Specified by:
        `setNodeInfo` in interface `ClusterManager`

    - #### getNodeInfo

          public NodeInfo getNodeInfo()

      Description copied from interface: `ClusteredNode`
      Get details about this clustered node.
      Specified by:
        `getNodeInfo` in interface `ClusteredNode`

    - #### getNodeInfo

          public void getNodeInfo​(String nodeId,
                                  Completable<NodeInfo> promise)

      Description copied from interface: `ClusteredNode`
      Get details about a specific node in the cluster.
      Specified by:
        `getNodeInfo` in interface `ClusteredNode`
      Parameters:
        `nodeId` - the clustered node id

    - #### join

          public void join​(Completable<Void> promise)

      Description copied from interface: `ClusterManager`
      Join the cluster.
      Specified by:
        `join` in interface `ClusterManager`

    - #### leave

          public void leave​(Completable<Void> promise)

      Description copied from interface: `ClusterManager`
      Leave the cluster.
      Specified by:
        `leave` in interface `ClusterManager`

    - #### isActive

          public boolean isActive()

      Description copied from interface: `ClusterManager`
      Is the cluster manager active?
      Specified by:
        `isActive` in interface `ClusterManager`
      Returns:
        true if active, false otherwise

    - #### addRegistration

          public void addRegistration​(String address,
                                      RegistrationInfo registrationInfo,
                                      Completable<Void> promise)

      Description copied from interface: `ClusterManager`
      Share a new messaging handler registration with other nodes in the cluster.
      Specified by:
        `addRegistration` in interface `ClusterManager`

    - #### removeRegistration

          public void removeRegistration​(String address,
                                         RegistrationInfo registrationInfo,
                                         Completable<Void> promise)

      Description copied from interface: `ClusterManager`
      Signal removal of a messaging handler registration to other nodes in the cluster.
      Specified by:
        `removeRegistration` in interface `ClusterManager`

    - #### getRegistrations

          public void getRegistrations​(String address,
                                       Completable<List<RegistrationInfo>> promise)

      Description copied from interface: `ClusteredNode`
      Get the messaging handler currently registered in the cluster.
      Specified by:
        `getRegistrations` in interface `ClusteredNode`

    - #### childEvent

          public void childEvent​(org.apache.curator.framework.CuratorFramework client,
                                 org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent event)
                          throws Exception

      Specified by:
        `childEvent` in interface `org.apache.curator.framework.recipes.cache.PathChildrenCacheListener`
      Throws:
        `Exception`