Interface ClusterManager

  • All Superinterfaces:
    VertxServiceProvider
    All Known Implementing Classes:
    HazelcastClusterManager, IgniteClusterManager, InfinispanClusterManager, ZookeeperClusterManager

    public interface ClusterManager
    extends VertxServiceProvider
    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 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
      • getSyncMap

        <K,​V> Map<K,​V> getSyncMap​(String name)
        Return a synchronous map for the given name.
      • getLockWithTimeout

        void getLockWithTimeout​(String name,
                                long timeout,
                                Promise<Lock> promise)
        Attempts to acquire a Lock for the given name within timeout milliseconds.
      • getNodeId

        String getNodeId()
        Return the unique node identifier for this node.
      • getNodes

        List<String> getNodes()
        Return a list of node identifiers corresponding to the nodes in the cluster.
      • 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,
                         Promise<Void> promise)
        Store the details about this clustered node.
      • getNodeInfo

        NodeInfo getNodeInfo()
        Get details about this clustered node.
      • getNodeInfo

        void getNodeInfo​(String nodeId,
                         Promise<NodeInfo> promise)
        Get details about a specific node in the cluster.
        Parameters:
        nodeId - the clustered node id
      • join

        void join​(Promise<Void> promise)
        Join the cluster.
      • leave

        void leave​(Promise<Void> promise)
        Leave the cluster.
      • isActive

        boolean isActive()
        Is the cluster manager active?
        Returns:
        true if active, false otherwise
      • addRegistration

        void addRegistration​(String address,
                             RegistrationInfo registrationInfo,
                             Promise<Void> promise)
        Share a new messaging handler registration with other nodes in the cluster.
      • removeRegistration

        void removeRegistration​(String address,
                                RegistrationInfo registrationInfo,
                                Promise<Void> promise)
        Signal removal of a messaging handler registration to other nodes in the cluster.
      • getRegistrations

        void getRegistrations​(String address,
                              Promise<List<RegistrationInfo>> promise)
        Get the messaging handler currently registered 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