https://vertx.io/docs/vertx-hazelcast/java/#_using_an_existing_hazelcast_cluster说";您可以在集群管理器中传递现有的HazelcastInstance以重用现有集群";。如果有一个Hazelcast集群已经在运行,我如何在代码中获得它?
您可以使用getAllHazelcastInstances
方法获得JVM中运行的所有Hazelcast实例:
Set<HazelcastInstance> hzSet =
com.hazelcast.core.Hazelcast.getAllHazelcastInstances();
或者,您可以在Hazelcast成员配置中配置实例名称,然后按给定名称检索:
HazelcastInstance hz =
com.hazelcast.core.Hazelcast.getHazelcastInstanceByName(String);
有关其他可能性,请检查Hazelcast
类的JavaDoc:
- https://docs.hazelcast.org/docs/4.1/javadoc/com/hazelcast/core/Hazelcast.html