io.vertx.spi.cluster.hazelcast

## Class HazelcastClusterManager

- java.lang.Object
- - io.vertx.spi.cluster.hazelcast.HazelcastClusterManager

- All Implemented Interfaces:
    com.hazelcast.core.LifecycleListener, com.hazelcast.core.MembershipListener, ClusterManager, EventListener

      public class HazelcastClusterManager
      extends Object
      implements ClusterManager, com.hazelcast.core.MembershipListener, com.hazelcast.core.LifecycleListener

  A cluster manager that uses Hazelcast
  Author:
    Tim Fox

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HazelcastClusterManager()` Constructor - gets config from classpath
    `HazelcastClusterManager(com.hazelcast.config.Config conf)` Constructor - config supplied
    `HazelcastClusterManager(com.hazelcast.core.HazelcastInstance instance)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<K,V> void` | `getAsyncMap(String name, Handler<AsyncResult<AsyncMap<K,V>>> resultHandler)` Return an async map for the given name
    `<K,V> void` | `getAsyncMultiMap(String name, Handler<AsyncResult<AsyncMultiMap<K,V>>> resultHandler)` Every eventbus handler has an ID.
    `com.hazelcast.config.Config` | `getConfig()` Get the Hazelcast config.
    `void` | `getCounter(String name, Handler<AsyncResult<Counter>> resultHandler)`
    `com.hazelcast.core.HazelcastInstance` | `getHazelcastInstance()`
    `void` | `getLockWithTimeout(String name, long timeout, Handler<AsyncResult<Lock>> resultHandler)`
    `String` | `getNodeID()` Return the unique node ID for this node
    `List<String>` | `getNodes()` Return a list of node IDs corresponding to the nodes in the cluster
    `<K,V> Map<K,V>` | `getSyncMap(String name)` Return a synchronous map for the given name
    `boolean` | `isActive()` Is the cluster manager active?
    `void` | `join(Handler<AsyncResult<Void>> resultHandler)` Join the cluster
    `void` | `leave(Handler<AsyncResult<Void>> resultHandler)` Leave the cluster
    `com.hazelcast.config.Config` | `loadConfig()` Load Hazelcast config XML and transform it into a `Config` object.
    `void` | `memberAdded(com.hazelcast.core.MembershipEvent membershipEvent)`
    `void` | `memberAttributeChanged(com.hazelcast.core.MemberAttributeEvent memberAttributeEvent)`
    `void` | `memberRemoved(com.hazelcast.core.MembershipEvent membershipEvent)`
    `void` | `nodeListener(NodeListener listener)` Set a listener that will be called when a node joins or leaves the cluster.
    `void` | `setConfig(com.hazelcast.config.Config config)` Set the Hazelcast config.
    `void` | `setVertx(Vertx vertx)`
    `void` | `stateChanged(com.hazelcast.core.LifecycleEvent lifecycleEvent)`

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

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

- - ### Constructor Detail

    - #### HazelcastClusterManager

          public HazelcastClusterManager()

      Constructor - gets config from classpath

    - #### HazelcastClusterManager

          public HazelcastClusterManager(com.hazelcast.config.Config conf)

      Constructor - config supplied
      Parameters:
        `conf` - Hazelcast config, not null

    - #### HazelcastClusterManager

          public HazelcastClusterManager(com.hazelcast.core.HazelcastInstance instance)

  - ### Method Detail

    - #### setVertx

          public void setVertx(Vertx vertx)

      Specified by:
        `setVertx` in interface `ClusterManager`

    - #### join

          public void join(Handler<AsyncResult<Void>> resultHandler)

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

    - #### getAsyncMultiMap

          public <K,V> void getAsyncMultiMap(String name,
                                             Handler<AsyncResult<AsyncMultiMap<K,V>>> resultHandler)

      Every eventbus handler has an ID. SubsMap (subscriber map) is a MultiMap which maps handler-IDs with server-IDs and thus allows the eventbus to determine where to send messages.
      Specified by:
        `getAsyncMultiMap` in interface `ClusterManager`
      Parameters:
        `name` - A unique name by which the the MultiMap can be identified within the cluster. See the cluster config file (e.g. cluster.xml in case of HazelcastClusterManager) for additional MultiMap config parameters.
        `resultHandler` - handler receiving the multimap

    - #### getNodeID

          public String getNodeID()

      Description copied from interface: `ClusterManager`
      Return the unique node ID for this node
      Specified by:
        `getNodeID` in interface `ClusterManager`

    - #### getNodes

          public List<String> getNodes()

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

    - #### 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`

    - #### getAsyncMap

          public <K,V> void getAsyncMap(String name,
                                        Handler<AsyncResult<AsyncMap<K,V>>> resultHandler)

      Description copied from interface: `ClusterManager`
      Return an async map 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,
                                         Handler<AsyncResult<Lock>> resultHandler)

      Specified by:
        `getLockWithTimeout` in interface `ClusterManager`

    - #### getCounter

          public void getCounter(String name,
                                 Handler<AsyncResult<Counter>> resultHandler)

      Specified by:
        `getCounter` in interface `ClusterManager`

    - #### leave

          public void leave(Handler<AsyncResult<Void>> resultHandler)

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

    - #### memberAdded

          public void memberAdded(com.hazelcast.core.MembershipEvent membershipEvent)

      Specified by:
        `memberAdded` in interface `com.hazelcast.core.MembershipListener`

    - #### memberRemoved

          public void memberRemoved(com.hazelcast.core.MembershipEvent membershipEvent)

      Specified by:
        `memberRemoved` in interface `com.hazelcast.core.MembershipListener`

    - #### stateChanged

          public void stateChanged(com.hazelcast.core.LifecycleEvent lifecycleEvent)

      Specified by:
        `stateChanged` in interface `com.hazelcast.core.LifecycleListener`

    - #### 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

    - #### memberAttributeChanged

          public void memberAttributeChanged(com.hazelcast.core.MemberAttributeEvent memberAttributeEvent)

      Specified by:
        `memberAttributeChanged` in interface `com.hazelcast.core.MembershipListener`

    - #### getConfig

          public com.hazelcast.config.Config getConfig()

      Get the Hazelcast config.
      Returns:
        a config object

    - #### setConfig

          public void setConfig(com.hazelcast.config.Config config)

      Set the Hazelcast config.
      Parameters:
        `config` - a config object

    - #### loadConfig

          public com.hazelcast.config.Config loadConfig()

      Load Hazelcast config XML and transform it into a `Config` object. The content is read from:
      1. the location denoted by the `vertx.hazelcast.config` sysprop, if present, or
      2. the `cluster.xml` file on the classpath, if present, or
      3. the default config file

      The cluster manager uses this method to load the config when the node joins the cluster, if no config was provided upon creation.

      You may use this method to get a base config and customize it before the node joins the cluster. In this case, don't forget to invoke `setConfig(Config)` after you applied your changes.

      Returns:
        a config object

    - #### getHazelcastInstance

          public com.hazelcast.core.HazelcastInstance getHazelcastInstance()

Copyright © 2019 Eclipse. All rights reserved.