Skip to content

Commit

Permalink
Migrate to Hazelcast 5 (vert-x3#186)
Browse files Browse the repository at this point in the history
* Migrate to Hazelcast 5

Closes vert-x3#185

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>

* Revert assertj-core upgrade

Not compatible with upstream test dependency

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>

* GH Actions: testing with Hazelcast v5.3.2 is the new default

Thus relieving us from updating ci-5.x.yml now or in the future.

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>

---------

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
  • Loading branch information
tsegismont committed Sep 5, 2023
1 parent b814e2e commit ed36d75
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
default: ubuntu-latest
type: string
hz:
default: 4.2.8
default: 5.3.2
type: string
jobs:
Test:
Expand Down
19 changes: 13 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
<properties>
<stack.version>5.0.0-SNAPSHOT</stack.version>
<asciidoc.dir>${project.basedir}/src/main/asciidoc</asciidoc.dir>
<hazelcast.version>4.2.8</hazelcast.version>
<hazelcast-kubernetes.version>2.2.3</hazelcast-kubernetes.version>
<hazelcast.version>5.3.2</hazelcast.version>
<jar.manifest>${project.basedir}/src/main/resources/META-INF/MANIFEST.MF</jar.manifest>
</properties>

Expand Down Expand Up @@ -69,7 +68,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -115,7 +114,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.0</version>
<version>1.4.7</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -150,7 +149,11 @@
<hazelcast.logging.type>slf4j</hazelcast.logging.type>
</systemPropertyVariables>
<!-- Needs to be small enough to run in a EC2 1.7GB small instance -->
<argLine>-Xmx1200M</argLine>
<argLine>-Xmx1200M --add-modules java.se --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens
java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens
java.management/sun.management=ALL-UNNAMED --add-opens
jdk.management/com.sun.management.internal=ALL-UNNAMED
</argLine>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
</configuration>
Expand All @@ -169,7 +172,11 @@
<hazelcast.logging.type>slf4j</hazelcast.logging.type>
</systemPropertyVariables>
<!-- Needs to be small enough to run in a EC2 1.7GB small instance -->
<argLine>-Xmx1200M</argLine>
<argLine>-Xmx1200M --add-modules java.se --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens
java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens
java.management/sun.management=ALL-UNNAMED --add-opens
jdk.management/com.sun.management.internal=ALL-UNNAMED
</argLine>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
</configuration>
Expand Down
76 changes: 23 additions & 53 deletions src/main/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ The content is read from:

=== Discovery options

Hazelcast supports several different discovery options.
The default configuration uses multicast so you must have multicast enabled on your network for this to work.
Hazelcast supports several discovery options.
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 discovery differently please consult the Hazelcast documentation.

Expand Down Expand Up @@ -193,15 +193,15 @@ To change this value `hazelcast.max.no.heartbeat.seconds` system property such a

Afterwards a node will be removed from the cluster after 5 seconds without a heartbeat.

See https://docs.hazelcast.org/docs/latest/manual/html-single/#system-properties[Hazelcast system-properties].
See https://docs.hazelcast.com/hazelcast/5.3/system-properties[Hazelcast system-properties].

== Trouble shooting clustering
== Troubleshooting clustering

If the default multicast configuration is not working here are some common causes:

=== Multicast not enabled on the machine.

It is quite common in particular on OSX machines for multicast to be disabled by default. Please google for
It is quite common in particular on OSX machines for multicast to be disabled by default.Please google for
information on how to enable this.

=== Using wrong network interface
Expand Down Expand Up @@ -262,7 +262,7 @@ another library, you need to set the `hazelcast.logging.type` system property su
-Dhazelcast.logging.type=slf4j
----

See the http://docs.hazelcast.org/docs/3.6.1/manual/html-single/index.html#logging-configuration[hazelcast documentation] for more details.
See the https://docs.hazelcast.com/hazelcast/5.3/clusters/logging-configuration[hazelcast documentation] for more details.

== Using a different Hazelcast version

Expand Down Expand Up @@ -304,61 +304,30 @@ dependencies {

== Configuring for Kubernetes

On Kubernetes, Hazelcast should be configured to use the https://github.com/hazelcast/hazelcast-kubernetes[Hazelcast Kubernetes] plugin.
The first step is to configure the discovery plugin inside your Hazelcast configuration, by either providing a custom `cluster.xml` file or programmatically, as described in <<configcluster>>.

First, add the `io.vertx:vertx-hazelcast:${vertx.version}` and `com.hazelcast:hazelcast-kubernetes:${hazelcast-kubernetes.version}` dependencies to your project.
With Maven it looks like:

[source,xml]
----
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-hazelcast</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-kubernetes</artifactId>
<version>${hazelcast-kubernetes.version}</version>
</dependency>
----

NOTE: If you use a different version of the Hazelcast core library, make sure to use a compatible version of the Kubernetes discovery plugin.

The second step is to configure the discovery plugin inside of your Hazelcast configuration, by either providing a custom `cluster.xml` file or programmatically, as described in <<configcluster>>.

The plugin provides two https://github.com/hazelcast/hazelcast-kubernetes#understanding-discovery-modes[discovery modes]: _Kubernetes API_ and _DNS Lookup_.
https://docs.hazelcast.com/hazelcast/5.3/kubernetes/kubernetes-auto-discovery#discovering-members[discovery modes]: _Kubernetes API_ and _DNS Lookup_.
Please refer to the plugin project page for pros and cons of both modes.

In this document, we will use _DNS Lookup_ discovery. The following properties have to be changed / added:
In this document, we will use _DNS Lookup_ discovery.The following properties have to be changed / added:

[source,xml]
----
<hazelcast>
<properties>
<property name="hazelcast.discovery.enabled">true</property> <!--1-->
</properties>
<network>
<join>
<auto-detection enabled="false"/> <!--1-->
<multicast enabled="false"/> <!--2-->
<tcp-ip enabled="false" />
<discovery-strategies>
<discovery-strategy enabled="true"> <!--3-->
class="com.hazelcast.kubernetes.HazelcastKubernetesDiscoveryStrategy">
<properties>
<property name="service-dns">MY-SERVICE-DNS-NAME</property> <!--4-->
</properties>
</discovery-strategy>
</discovery-strategies>
<kubernetes enabled="true"> <!--3-->
<service-dns>MY-SERVICE-DNS-NAME</service-dns> <!--4-->
</kubernetes>
</join>
</network>
</hazelcast>
----
<1> Activate Discovery SPI
<2> Deactivate other discoveries
<3> Activate the Kubernetes plugin
<1> Disable discovery plugin auto-detection
<2> Disable multicast discovery
<3> Activate Kubernetes discovery
<4> Service DNS, usually in the form of `MY-SERVICE-NAME.MY-NAMESPACE.svc.cluster.local` but depends on the Kubernetes distribution

The `MY-SERVICE-DNS-NAME` value must be a *headless* Kubernetes service name that will be used by Hazelcast to identify all cluster members.
Expand All @@ -372,13 +341,14 @@ metadata:
namespace: MY-NAMESPACE
name: MY-SERVICE-NAME
spec:
type: ClusterIP
clusterIP: None
selector:
component: MY-SERVICE-NAME # <1>
clusterIP: None
ports:
- name: hz-port-name
port: 5701
protocol: TCP
- name: hazelcast
port: 5701
protocol: TCP
----
<1> Cluster members selected by label

Expand All @@ -397,7 +367,7 @@ spec:
component: MY-SERVICE-NAME
----

Further configuration details are available on the https://github.com/hazelcast/hazelcast-kubernetes[Hazelcast Kubernetes Plugin page].
Further configuration details are available on the https://docs.hazelcast.com/hazelcast/5.3/kubernetes/kubernetes-auto-discovery#discovering-members[Kubernetes Auto Discovery page].

=== Rolling updates

Expand Down Expand Up @@ -493,7 +463,7 @@ After creation, the health check can be exposed over HTTP with a link:../../vert

==== Using Lite Members

To minimize the time a Vert.x cluster spends accomodating a new topology, you may use external data nodes and mark Vert.x nodes as https://docs.hazelcast.org/docs/latest/manual/html-single/#enabling-lite-members[_Lite Members_].
To minimize the time a Vert.x cluster spends accomodating a new topology, you may use external data nodes and mark Vert.x nodes as https://docs.hazelcast.com/hazelcast/5.3/maintain-cluster/lite-members[_Lite Members_].

_Lite Members_ participate in a Hazelcast cluster like regular members, but they do not own any data partition.
Therefore, Hazelcast does not need to migrate partitions when such members are added or removed.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/default-cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config
https://www.hazelcast.com/schema/config/hazelcast-config-4.2.xsd">
https://www.hazelcast.com/schema/config/hazelcast-config-5.3.xsd">

<network>
<join>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package io.vertx.core;

import com.hazelcast.config.Config;
import com.hazelcast.config.JoinConfig;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import io.vertx.LoggingTestWatcher;
Expand Down Expand Up @@ -79,6 +80,9 @@ private Config createConfig() {
.setProperty("hazelcast.wait.seconds.before.join", "0")
.setProperty("hazelcast.local.localAddress", "127.0.0.1")
.setClusterName(System.getProperty("vertx.hazelcast.test.group.name"));
JoinConfig join = config.getNetworkConfig().getJoin();
join.getAutoDetectionConfig().setEnabled(false);
join.getMulticastConfig().setEnabled(true);
config.getMemberAttributeConfig().setAttribute("__vertx.nodeId", UUID.randomUUID().toString());
return config;
}
Expand Down
5 changes: 3 additions & 2 deletions src/test/resources/cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config
https://www.hazelcast.com/schema/config/hazelcast-config-4.2.xsd">
https://www.hazelcast.com/schema/config/hazelcast-config-5.3.xsd">

<properties>
<property name="hazelcast.wait.seconds.before.join">0</property>
Expand All @@ -27,7 +27,8 @@

<network>
<join>
<multicast/>
<auto-detection enabled="false"/>
<multicast enabled="true"/>
</join>
</network>

Expand Down

0 comments on commit ed36d75

Please sign in to comment.