Package io.vertx.core.spi.cluster
Interface ClusterManager
-
- All Superinterfaces:
VertxServiceProvider
- All Known Implementing Classes:
HazelcastClusterManager
,IgniteClusterManager
,InfinispanClusterManager
,ZookeeperClusterManager
public interface ClusterManager extends VertxServiceProvider
A cluster provider for Vert.x must implement this interface. In order for HA to work correctly, all implementations of this interface MUST be implemented such that: 1. Whenever a node joins or leaves the cluster the registered NodeListener (if any) MUST be called with the appropriate join or leave event. 2. For all nodes that are part of the cluster, the registered NodeListener MUST be called with the exact same sequence of join and leave events on all nodes. 3. For any particular join or leave event that is handled in any NodeListener, anywhere in the cluster, the List of nodes returned by getNodes must be identical. 4. All of the methods in the implementation must return immediately, i.e. they must not block while the operation is being executed. If the underlying implementation does block, thenVertx.executeBlocking(java.util.concurrent.Callable<T>, boolean)
should be used to run the operation on a worker.- Author:
- Tim Fox
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addRegistration(String address, RegistrationInfo registrationInfo, Promise<Void> promise)
Share a new messaging handler registration with other nodes in the cluster.default String
clusterHost()
If the cluster manager has its own server for data/membership, this returns the host it is listening to.default String
clusterPublicHost()
If the cluster manager has its own server for data/membership, this returns the host it advertises to other nodes.<K,V>
voidgetAsyncMap(String name, Promise<AsyncMap<K,V>> promise)
Return anAsyncMap
for the givenname
.void
getCounter(String name, Promise<Counter> promise)
Return aCounter
for the givenname
.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 givenname
.default void
init(io.vertx.core.internal.VertxBootstrap builder)
Let the provider initialize the Vert.x builder.void
init(Vertx vertx)
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.void
nodeListener(NodeListener listener)
Set a listener that will be called when a node joins or leaves the cluster.void
registrationListener(RegistrationListener registrationListener)
Implementations must signal the providedregistrationListener
when messaging handler registrations are added or removed by sending aRegistrationUpdateEvent
withRegistrationListener.registrationsUpdated(RegistrationUpdateEvent)
.void
removeRegistration(String address, RegistrationInfo registrationInfo, Promise<Void> promise)
Signal removal of a messaging handler registration to other nodes in the cluster.void
setNodeInfo(NodeInfo nodeInfo, Promise<Void> promise)
Store the details about this clustered node.
-
-
-
Method Detail
-
init
default void init(io.vertx.core.internal.VertxBootstrap builder)
Description copied from interface:VertxServiceProvider
Let the provider initialize the Vert.x builder.- Specified by:
init
in interfaceVertxServiceProvider
- Parameters:
builder
- the builder
-
init
void init(Vertx vertx)
Invoked before this cluster node tries to join the cluster.- Parameters:
vertx
- the Vert.x instance
-
getAsyncMap
<K,V> void getAsyncMap(String name, Promise<AsyncMap<K,V>> promise)
Return anAsyncMap
for the givenname
.
-
getCounter
void getCounter(String name, Promise<Counter> promise)
Return aCounter
for the givenname
.
-
getNodeId
String getNodeId()
Return the unique node identifier for this node.
-
getNodes
List<String> getNodes()
Return a list of node identifiers corresponding to the nodes in the cluster.
-
nodeListener
void nodeListener(NodeListener listener)
Set a listener that will be called when a node joins or leaves the cluster.
-
setNodeInfo
void setNodeInfo(NodeInfo nodeInfo, Promise<Void> promise)
Store the details about this clustered node.
-
getNodeInfo
NodeInfo getNodeInfo()
Get details about this clustered node.
-
getNodeInfo
void getNodeInfo(String nodeId, Promise<NodeInfo> promise)
Get details about a specific node in the cluster.- Parameters:
nodeId
- the clustered node id
-
isActive
boolean isActive()
Is the cluster manager active?- Returns:
- true if active, false otherwise
-
registrationListener
void registrationListener(RegistrationListener registrationListener)
Implementations must signal the providedregistrationListener
when messaging handler registrations are added or removed by sending aRegistrationUpdateEvent
withRegistrationListener.registrationsUpdated(RegistrationUpdateEvent)
.- Parameters:
registrationListener
- the registration listener
-
addRegistration
void addRegistration(String address, RegistrationInfo registrationInfo, Promise<Void> promise)
Share a new messaging handler registration with other nodes in the cluster.
-
removeRegistration
void removeRegistration(String address, RegistrationInfo registrationInfo, Promise<Void> promise)
Signal removal of a messaging handler registration to other nodes in the cluster.
-
getRegistrations
void getRegistrations(String address, Promise<List<RegistrationInfo>> promise)
Get the messaging handler currently registered in the cluster.
-
clusterHost
default String clusterHost()
If the cluster manager has its own server for data/membership, this returns the host it is listening to. When users don't configure the eventbus cluster host, the value will serve as a default.- Returns:
- null if the cluster manager does not start a server or the host couldn't be determined
-
clusterPublicHost
default String clusterPublicHost()
If the cluster manager has its own server for data/membership, this returns the host it advertises to other nodes. When users don't configure the eventbus cluster public host, the value will serve as a default.- Returns:
- null if the cluster manager does not advertise a host that is different from the cluster host or the public host couldn't be determined
-
-