See: Description
| Class | Description |
|---|---|
| HazelcastClusterManager |
A cluster manager that uses Hazelcast
|
examples.Examples#example1()
----
== Configuring this cluster manager
Usually the cluster manager is configured by a file
https://github.com/vert-x3/vertx-hazelcast/blob/master/src/main/resources/default-cluster.xml[`default-cluster.xml`]
which is packaged inside the jar.
If you want to override this configuration you can provide a file called `cluster.xml` on your classpath and this
will be used instead.
The xml file is a Hazelcast configuration file and is described in detail in the documentation on the Hazelcast
web-site.
You can also specify configuration programmatically if embedding:
[source,$lang]
----
examples.Examples#example2()
----
Hazelcast supports several different transports including multicast and TCP. The default configuration uses
multicast so you must have multicast enabled on your network for this to work.
For full documentation on how to configure the transport differently or use a different transport please consult the
Hazelcast documentation.
== Using an existing Hazelcast cluster
You can pass an existing `HazelcastInstance` in the cluster manager to reuse an existing cluster:
[source,$lang]
----
examples.Examples#example3(com.hazelcast.core.HazelcastInstance)
----
In this case, vert.x is not the cluster owner and so do not shutdown the cluster on close.
Notice that the custom Hazelcast instance need to be configured with:
[source, xml]
----
VertxOptions.setClusterHost(java.lang.String).
=== Using a VPN
This is a variation of the above case. VPN software often works by creating a virtual network interface which often
doesn't support multicast. If you have a VPN running and you do not specify the correct interface to use in both the
hazelcast configuration and to Vert.x then the VPN interface may be chosen instead of the correct interface.
So, if you have a VPN running you may have to configure both the Hazelcast and Vert.x to use the correct interface as
described in the previous section.
=== When multicast is not available
In some cases you may not be able to use multicast as it might not be available in your environment. In that case
you should configure another transport, e.g. TCP to use TCP sockets, or AWS when running on Amazon EC2.
For more information on available Hazelcast transports and how to configure them please consult the Hazelcast
documentation.
=== Enabling logging
When trouble-shooting clustering issues with Hazelcast it's often useful to get some logging output from Hazelcast
to see if it's forming a cluster properly. You can do this (when using the default JUL logging) by adding a file
called `vertx-default-jul-logging.properties` on your classpath. This is a standard java.util.loging (JUL)
configuration file. Inside it set:
----
com.hazelcast.level=INFO
----
and also
----
java.util.logging.ConsoleHandler.level=INFO
java.util.logging.FileHandler.level=INFO
----Copyright © 2016. All rights reserved.