Reputation: 155
I want to get the nodeId of the current node in cluster.
I didn't configuring the cluster programmatically when I start vertx, i just provide a file called cluster.xml on my classpath. In this case, I have no ClusterManager object.
I tried to find the right API in the Vertx object, but I couldn't find it.
So, how can i get the nodeId?
Upvotes: 0
Views: 446
Reputation: 9128
The cluster manager instance is not accessible from the Vert.x public API. But you can cast the Vert.x object to VertxInternal
:
VertxInternal vertxInternal = (VertxInternal) vertx;
ClusterManager clusterManager = vertxInternal.getClusterManager();
String nodeId = clusterManager.getNodeID();
Upvotes: 2
Reputation: 1521
Have you tried
Config hazelcastConfig = ConfigUtil.loadConfig(); // load config from cluster xml
ClusterManager mgr = new HazelcastClusterManager(hazelcastConfig);
mdr.nodeId
Upvotes: 0