Package io.atomix.cluster.messaging.impl
Class DefaultClusterEventService
java.lang.Object
io.atomix.cluster.messaging.impl.DefaultClusterEventService
- All Implemented Interfaces:
ClusterMembershipEventListener,ClusterEventService,ManagedClusterEventService,EventFilter<ClusterMembershipEvent>,EventListener<ClusterMembershipEvent>,Managed<ClusterEventService>,AutoCloseable
public class DefaultClusterEventService
extends Object
implements ManagedClusterEventService, ClusterMembershipEventListener
Cluster event service.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultClusterEventService(ClusterMembershipService membershipService, MessagingService messagingService) -
Method Summary
Modifier and TypeMethodDescription<M> voidBroadcasts a message to all subscribers registered for the giventopic.voidevent(ClusterMembershipEvent event) getSubscribers(String topicName) Returns a list of remote members subscribed for the given topic.getSubscriptions(String topicName) Returns a list of subscriptions for the given topic.booleanstart()stop()Adds a new subscriber for the specified message topic.<M,R> CompletableFuture <Subscription> subscribe(String topic, Function<byte[], M> decoder, Function<M, CompletableFuture<R>> handler, Function<R, byte[]> encoder) Adds a new subscriber for the specified message topic.<M,R> CompletableFuture <Subscription> subscribe(String topic, Function<byte[], M> decoder, Function<M, R> handler, Function<R, byte[]> encoder, Executor executor) Adds a new subscriber for the specified message topic.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.atomix.cluster.messaging.ClusterEventService
broadcast, subscribe, subscribe, subscribeMethods inherited from interface io.atomix.utils.event.EventFilter
isRelevant
-
Constructor Details
-
DefaultClusterEventService
public DefaultClusterEventService(ClusterMembershipService membershipService, MessagingService messagingService)
-
-
Method Details
-
broadcast
Description copied from interface:ClusterEventServiceBroadcasts a message to all subscribers registered for the giventopic.- Specified by:
broadcastin interfaceClusterEventService- Type Parameters:
M- message type- Parameters:
topic- message topicmessage- message to sendencoder- function for encoding message to byte[]
-
subscribe
public <M,R> CompletableFuture<Subscription> subscribe(String topic, Function<byte[], M> decoder, Function<M, R> handler, Function<R, byte[]> encoder, Executor executor) Description copied from interface:ClusterEventServiceAdds a new subscriber for the specified message topic.- Specified by:
subscribein interfaceClusterEventService- Type Parameters:
M- incoming message typeR- reply message type- Parameters:
topic- message topicdecoder- decoder for resurrecting incoming messagehandler- handler function that processes the incoming message and produces a replyencoder- encoder for serializing replyexecutor- executor to run this handler on- Returns:
- future to be completed once the subscription has been propagated
-
subscribe
public <M,R> CompletableFuture<Subscription> subscribe(String topic, Function<byte[], M> decoder, Function<M, CompletableFuture<R>> handler, Function<R, byte[]> encoder) Description copied from interface:ClusterEventServiceAdds a new subscriber for the specified message topic.- Specified by:
subscribein interfaceClusterEventService- Type Parameters:
M- incoming message typeR- reply message type- Parameters:
topic- message topicdecoder- decoder for resurrecting incoming messagehandler- handler function that processes the incoming message and produces a replyencoder- encoder for serializing reply- Returns:
- future to be completed once the subscription has been propagated
-
subscribe
public <M> CompletableFuture<Subscription> subscribe(String topic, Function<byte[], M> decoder, Consumer<M> handler, Executor executor) Description copied from interface:ClusterEventServiceAdds a new subscriber for the specified message topic.- Specified by:
subscribein interfaceClusterEventService- Type Parameters:
M- incoming message type- Parameters:
topic- message topicdecoder- decoder to resurrecting incoming messagehandler- handler for handling messageexecutor- executor to run this handler on- Returns:
- future to be completed once the subscription has been propagated
-
getSubscriptions
Description copied from interface:ClusterEventServiceReturns a list of subscriptions for the given topic.- Specified by:
getSubscriptionsin interfaceClusterEventService- Parameters:
topicName- the topic for which to return subscriptions- Returns:
- the subscriptions for the given topic
-
getSubscribers
Description copied from interface:ClusterEventServiceReturns a list of remote members subscribed for the given topic.- Specified by:
getSubscribersin interfaceClusterEventService- Parameters:
topicName- the topic for which to return subscriptions- Returns:
- the subscribers for the given topic
-
start
- Specified by:
startin interfaceManaged<ClusterEventService>
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceManaged<ClusterEventService>
-
stop
- Specified by:
stopin interfaceManaged<ClusterEventService>
-
event
- Specified by:
eventin interfaceEventListener<ClusterMembershipEvent>
-