public class HazelcastClusterManager extends Object implements ClusterManager, MembershipListener, LifecycleListener
Constructor and Description |
---|
HazelcastClusterManager()
Constructor - gets config from classpath
|
HazelcastClusterManager(Config conf)
Constructor - config supplied
|
HazelcastClusterManager(HazelcastInstance instance) |
Modifier and Type | Method and Description |
---|---|
void |
addRegistration(String address,
RegistrationInfo registrationInfo,
Promise<Void> promise)
Share a new messaging handler registration with other nodes in the cluster.
|
String |
clusterHost()
If the cluster manager has its own server for data/membership, this returns the host it is listening to.
|
String |
clusterPublicHost()
If the cluster manager has its own server for data/membership, this returns the host it advertises to other nodes.
|
<K,V> void |
getAsyncMap(String name,
Promise<AsyncMap<K,V>> promise)
Return an
AsyncMap for the given name . |
Config |
getConfig()
Get the Hazelcast config.
|
void |
getCounter(String name,
Promise<Counter> promise)
Return a
Counter for the given name . |
HazelcastInstance |
getHazelcastInstance() |
void |
getLockWithTimeout(String name,
long timeout,
Promise<Lock> promise)
|
String |
getNodeId()
Return the unique node identifier for this node.
|
NodeInfo |
getNodeInfo()
Get details about this clustered node.
|
void |
getNodeInfo(String nodeId,
Promise<NodeInfo> promise)
Get details about a specific node in the cluster.
|
List<String> |
getNodes()
Return a list of node identifiers corresponding to the nodes in the cluster.
|
void |
getRegistrations(String address,
Promise<List<RegistrationInfo>> promise)
Get the messaging handler currently registered in the cluster.
|
<K,V> Map<K,V> |
getSyncMap(String name)
Return a synchronous map for the given
name . |
void |
init(Vertx vertx,
NodeSelector nodeSelector)
Invoked before this cluster node tries to join the cluster.
|
boolean |
isActive()
Is the cluster manager active?
|
void |
join(Promise<Void> promise)
Join the cluster.
|
void |
leave(Promise<Void> promise)
Leave the cluster.
|
Config |
loadConfig()
Load Hazelcast config XML and transform it into a
Config object. |
void |
memberAdded(MembershipEvent membershipEvent) |
void |
memberRemoved(MembershipEvent membershipEvent) |
void |
nodeListener(NodeListener listener)
Set a listener that will be called when a node joins or leaves the cluster.
|
void |
removeRegistration(String address,
RegistrationInfo registrationInfo,
Promise<Void> promise)
Signal removal of a messaging handler registration to other nodes in the cluster.
|
void |
setConfig(Config config)
Set the Hazelcast config.
|
void |
setNodeInfo(NodeInfo nodeInfo,
Promise<Void> promise)
Store the details about this clustered node.
|
void |
stateChanged(LifecycleEvent lifecycleEvent) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
init
public HazelcastClusterManager()
public HazelcastClusterManager(Config conf)
conf
- Hazelcast config, not nullpublic HazelcastClusterManager(HazelcastInstance instance)
public void init(Vertx vertx, NodeSelector nodeSelector)
ClusterManager
Implementations must signal the provided nodeSelector
when messaging handler registrations are added or removed
by sending a RegistrationUpdateEvent
with NodeSelector.registrationsUpdated(RegistrationUpdateEvent)
.
init
in interface ClusterManager
vertx
- the Vert.x instancenodeSelector
- the NodeSelector
that must receive RegistrationUpdateEvent
.public void join(Promise<Void> promise)
ClusterManager
join
in interface ClusterManager
public String getNodeId()
ClusterManager
getNodeId
in interface ClusterManager
public List<String> getNodes()
ClusterManager
getNodes
in interface ClusterManager
public void nodeListener(NodeListener listener)
ClusterManager
nodeListener
in interface ClusterManager
public void setNodeInfo(NodeInfo nodeInfo, Promise<Void> promise)
ClusterManager
setNodeInfo
in interface ClusterManager
public NodeInfo getNodeInfo()
ClusterManager
getNodeInfo
in interface ClusterManager
public void getNodeInfo(String nodeId, Promise<NodeInfo> promise)
ClusterManager
getNodeInfo
in interface ClusterManager
nodeId
- the clustered node idpublic <K,V> void getAsyncMap(String name, Promise<AsyncMap<K,V>> promise)
ClusterManager
AsyncMap
for the given name
.getAsyncMap
in interface ClusterManager
public <K,V> Map<K,V> getSyncMap(String name)
ClusterManager
name
.getSyncMap
in interface ClusterManager
public void getLockWithTimeout(String name, long timeout, Promise<Lock> promise)
ClusterManager
getLockWithTimeout
in interface ClusterManager
public void getCounter(String name, Promise<Counter> promise)
ClusterManager
Counter
for the given name
.getCounter
in interface ClusterManager
public void leave(Promise<Void> promise)
ClusterManager
leave
in interface ClusterManager
public void memberAdded(MembershipEvent membershipEvent)
memberAdded
in interface MembershipListener
public void memberRemoved(MembershipEvent membershipEvent)
memberRemoved
in interface MembershipListener
public void stateChanged(LifecycleEvent lifecycleEvent)
stateChanged
in interface LifecycleListener
public boolean isActive()
ClusterManager
isActive
in interface ClusterManager
public void addRegistration(String address, RegistrationInfo registrationInfo, Promise<Void> promise)
ClusterManager
addRegistration
in interface ClusterManager
public void removeRegistration(String address, RegistrationInfo registrationInfo, Promise<Void> promise)
ClusterManager
removeRegistration
in interface ClusterManager
public void getRegistrations(String address, Promise<List<RegistrationInfo>> promise)
ClusterManager
getRegistrations
in interface ClusterManager
public String clusterHost()
ClusterManager
clusterHost
in interface ClusterManager
public String clusterPublicHost()
ClusterManager
clusterPublicHost
in interface ClusterManager
public Config getConfig()
public void setConfig(Config config)
config
- a config objectpublic Config loadConfig()
Config
object.
The content is read from:
vertx.hazelcast.config
sysprop, if present, orcluster.xml
file on the classpath, if present, orThe cluster manager uses this method to load the config when the node joins the cluster, if no config was provided upon creation.
You may use this method to get a base config and customize it before the node joins the cluster.
In this case, don't forget to invoke setConfig(Config)
after you applied your changes.
public HazelcastInstance getHazelcastInstance()
Copyright © 2024 Eclipse. All rights reserved.