Package io.vertx.core.spi.cluster

## Interface ClusterManager

- All Superinterfaces:
    `ClusteredNode`, `VertxServiceProvider`
  All Known Implementing Classes:
    `HazelcastClusterManager`, `IgniteClusterManager`, `InfinispanClusterManager`, `ZookeeperClusterManager`

      public interface ClusterManager
      extends VertxServiceProvider, ClusteredNode

  A cluster provider for Vert.x must implement this interface. In order for HA to work correctly, all implementations of this interface MUST be implemented such that: 1. Whenever a node joins or leaves the cluster the registered NodeListener (if any) MUST be called with the appropriate join or leave event. 2. For all nodes that are part of the cluster, the registered NodeListener MUST be called with the exact same sequence of join and leave events on all nodes. 3. For any particular join or leave event that is handled in any NodeListener, anywhere in the cluster, the List of nodes returned by getNodes must be identical. 4. All of the methods in the implementation must return immediately, i.e. they must not block while the operation is being executed. If the underlying implementation does block, then `Vertx.executeBlocking(java.util.concurrent.Callable<T>, boolean)` should be used to run the operation on a worker.
  Author:
    Tim Fox

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default 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.
    `default String` | `clusterHost()` | If the cluster manager has its own server for data/membership, this returns the host it is listening to.
    `default String` | `clusterPublicHost()` | If the cluster manager has its own server for data/membership, this returns the host it advertises to other nodes.
    `<K,​V> void` | `getAsyncMap​(String name, Completable<AsyncMap<K,​V>> promise)` | Return an `AsyncMap` for the given `name`.
    `void` | `getCounter​(String name, Completable<Counter> promise)` | Return a `Counter` for the given `name`.
    `void` | `getLockWithTimeout​(String name, long timeout, Completable<Lock> promise)` | Attempts to acquire a `Lock` for the given `name` within `timeout` milliseconds.
    `<K,​V> Map<K,​V>` | `getSyncMap​(String name)` | Return a synchronous map for the given `name`.
    `default void` | `init​(io.vertx.core.internal.VertxBootstrap builder)` | Let the provider initialize the Vert.x builder.
    `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` | `setNodeInfo​(NodeInfo nodeInfo, Completable<Void> promise)` | Store the details about this clustered node.

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

      `getNodeId, getNodeInfo, getNodeInfo, getNodes, getRegistrations`

- - ### Method Detail

    - #### init

          default void init​(io.vertx.core.internal.VertxBootstrap builder)

      Description copied from interface: `VertxServiceProvider`
      Let the provider initialize the Vert.x builder.
      Specified by:
        `init` in interface `VertxServiceProvider`
      Parameters:
        `builder` - the builder

    - #### init

          void init​(Vertx vertx)

      Invoked before this cluster node tries to join the cluster.
      Parameters:
        `vertx` - the Vert.x instance

    - #### getAsyncMap

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

      Return an `AsyncMap` for the given `name`.

    - #### getSyncMap

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

      Return a synchronous map for the given `name`.

    - #### getLockWithTimeout

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

      Attempts to acquire a `Lock` for the given `name` within `timeout` milliseconds.

    - #### getCounter

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

      Return a `Counter` for the given `name`.

    - #### nodeListener

          void nodeListener​(NodeListener listener)

      Set a listener that will be called when a node joins or leaves the cluster.

    - #### setNodeInfo

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

      Store the details about this clustered node.

    - #### join

          void join​(Completable<Void> promise)

      Join the cluster.

    - #### leave

          void leave​(Completable<Void> promise)

      Leave the cluster.

    - #### isActive

          boolean isActive()

      Is the cluster manager active?
      Returns:
        true if active, false otherwise

    - #### registrationListener

          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)`.
      Parameters:
        `registrationListener` - the registration listener

    - #### addRegistration

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

      Share a new messaging handler registration with other nodes in the cluster.

    - #### removeRegistration

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

      Signal removal of a messaging handler registration to other nodes in the cluster.

    - #### clusterHost

          default String clusterHost()

      If the cluster manager has its own server for data/membership, this returns the host it is listening to. When users don't configure the eventbus cluster host, the value will serve as a default.
      Returns:
        null if the cluster manager does not start a server or the host couldn't be determined

    - #### clusterPublicHost

          default String clusterPublicHost()

      If the cluster manager has its own server for data/membership, this returns the host it advertises to other nodes. When users don't configure the eventbus cluster public host, the value will serve as a default.
      Returns:
        null if the cluster manager does not advertise a host that is different from the cluster host or the public host couldn't be determined