Vertx Cluster with Hazelcast - multiple machines - default cluster port

949 views
Skip to first unread message

Konstantinos Liakos

unread,
Oct 19, 2016, 6:57:20 AM10/19/16
to vert.x
Hi,

Following this example https://github.com/vert-x3/vertx-examples/tree/master/core-examples/src/main/java/io/vertx/example/core/eventbus/pointtopoint and having the custom cluster.xml removed from my classpath, two verticles in two different machines pair together successfully(Hazelacast autodiscovery via multicast is achieved).

Oct 19, 2016 1:48:00 PM com.hazelcast.cluster.ClusterService
INFO
: [192.168.1.67]:5701 [dev] [3.6.3]


Members [2] {
 
Member [192.168.1.67]:5701 this
 
Member [192.168.1.76]:5701
}

Oct 19, 2016 1:48:01 PM com.hazelcast.partition.InternalPartitionService
INFO: [192.168.1.67]:5701 [dev] [3.6.3] Re-partitioning cluster data... Migration queue size: 135


However the event bus messages fail to be received, unless I explicitly set the clusterHost in the VertxOptions.

Isn't it a bit odd that the the verticles are paired by Hazelcast, but you have to explicitly set the clusterHost on each one?

Following the -cluster-host documentation, it mentions:
-cluster-host - If the cluster option has also been specified then this determines which host address will be used for cluster communication with other Vert.x instances. 
By default it will try and pick one from the available interfaces.
If you have more than one interface and you want to use a specific one, specify it here.

However looking at the source code, I can see that the default host is always localhost


public static final String DEFAULT_CLUSTER_HOST = "localhost";

So it doesn't pick up an interface as the docs mention. It always uses localhost. This means that unless you explicitly set the cluster host, messages between different machines will not work.

Wouldn't it be better for the default cluster host to be something like:
 
Inet4Address.getLocalHost().getHostAddress()

that automatically picks up the local ip?

Otherwise, the default options work only for cluster in the same machine, which is not the common case for clustering.


Thomas SEGISMONT

unread,
Oct 24, 2016, 10:44:37 AM10/24/16
to ve...@googlegroups.com
Hi,

Comments inline.

2016-10-19 12:57 GMT+02:00 Konstantinos Liakos <liakosko...@gmail.com>:
Hi,

Following this example https://github.com/vert-x3/vertx-examples/tree/master/core-examples/src/main/java/io/vertx/example/core/eventbus/pointtopoint and having the custom cluster.xml removed from my classpath, two verticles in two different machines pair together successfully(Hazelacast autodiscovery via multicast is achieved).

Oct 19, 2016 1:48:00 PM com.hazelcast.cluster.ClusterService
INFO
: [192.168.1.67]:5701 [dev] [3.6.3]


Members [2] {
 
Member [192.168.1.67]:5701 this
 
Member [192.168.1.76]:5701
}

Oct 19, 2016 1:48:01 PM com.hazelcast.partition.InternalPartitionService
INFO: [192.168.1.67]:5701 [dev] [3.6.3] Re-partitioning cluster data... Migration queue size: 135


However the event bus messages fail to be received, unless I explicitly set the clusterHost in the VertxOptions.

Isn't it a bit odd that the the verticles are paired by Hazelcast, but you have to explicitly set the clusterHost on each one?

The nodes are paired by Hazelcast. But Hazelcast isn't used as event bus transport. See the documentation

"Cluster managers do not handle the event bus inter-node transport, this is done directly by Vert.x with TCP connections."

 

Following the -cluster-host documentation, it mentions:
-cluster-host - If the cluster option has also been specified then this determines which host address will be used for cluster communication with other Vert.x instances. 
By default it will try and pick one from the available interfaces.
If you have more than one interface and you want to use a specific one, specify it here.

However looking at the source code, I can see that the default host is always localhost


public static final String DEFAULT_CLUSTER_HOST = "localhost";

So it doesn't pick up an interface as the docs mention. It always uses localhost. This means that unless you explicitly set the cluster host, messages between different machines will not work.

Wouldn't it be better for the default cluster host to be something like:
 
Inet4Address.getLocalHost().getHostAddress()

that automatically picks up the local ip?

Otherwise, the default options work only for cluster in the same machine, which is not the common case for clustering.



This default is used only if you create an instance of EventBus options yourself. The Vert.x command line will update this value:


 

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/b56494ff-37dd-4f6c-9ffa-3305592f7546%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Konstantinos Liakos

unread,
Oct 24, 2016, 10:59:01 AM10/24/16
to vert.x
Hm, the -cluster-host is a command line param, so only by using the Starter class you get the default cluster host. I didn't get this correlation.

Maybe the examples could somehow use the actual Runner class from the vertx core, in order to utilize all these features.
Hi,

Comments inline.

To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages