Interface ClusterCommunicationService
-
public interface ClusterCommunicationService
Service for assisting communications between controller cluster nodes.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description <M> void
addSubscriber(MessageSubject subject, Function<byte[],M> decoder, Consumer<M> handler, Executor executor)
Adds a new subscriber for the specified message subject.<M,R>
voidaddSubscriber(MessageSubject subject, Function<byte[],M> decoder, Function<M,CompletableFuture<R>> handler, Function<R,byte[]> encoder)
Adds a new subscriber for the specified message subject.<M,R>
voidaddSubscriber(MessageSubject subject, Function<byte[],M> decoder, Function<M,R> handler, Function<R,byte[]> encoder, Executor executor)
Adds a new subscriber for the specified message subject.void
addSubscriber(MessageSubject subject, ClusterMessageHandler subscriber, ExecutorService executor)
Deprecated.in Cardinal Release<M> void
broadcast(M message, MessageSubject subject, Function<M,byte[]> encoder)
Broadcasts a message to all controller nodes.<M> void
broadcastIncludeSelf(M message, MessageSubject subject, Function<M,byte[]> encoder)
Broadcasts a message to all controller nodes including self.<M> void
multicast(M message, MessageSubject subject, Function<M,byte[]> encoder, Set<NodeId> nodeIds)
Multicasts a message to a set of controller nodes.void
removeSubscriber(MessageSubject subject)
Removes a subscriber for the specified message subject.default <M,R>
CompletableFuture<R>sendAndReceive(M message, MessageSubject subject, Function<M,byte[]> encoder, Function<byte[],R> decoder, NodeId toNodeId)
Sends a message and expects a reply.<M,R>
CompletableFuture<R>sendAndReceive(M message, MessageSubject subject, Function<M,byte[]> encoder, Function<byte[],R> decoder, NodeId toNodeId, Duration timeout)
Sends a message and expects a reply.<M> CompletableFuture<Void>
unicast(M message, MessageSubject subject, Function<M,byte[]> encoder, NodeId toNodeId)
Sends a message to the specified controller node.
-
-
-
Method Detail
-
addSubscriber
@Deprecated void addSubscriber(MessageSubject subject, ClusterMessageHandler subscriber, ExecutorService executor)
Deprecated.in Cardinal ReleaseAdds a new subscriber for the specified message subject.- Parameters:
subject
- message subjectsubscriber
- message subscriberexecutor
- executor to use for running handler.
-
broadcast
<M> void broadcast(M message, MessageSubject subject, Function<M,byte[]> encoder)
Broadcasts a message to all controller nodes.- Type Parameters:
M
- message type- Parameters:
message
- message to sendsubject
- message subjectencoder
- function for encoding message to byte[]
-
broadcastIncludeSelf
<M> void broadcastIncludeSelf(M message, MessageSubject subject, Function<M,byte[]> encoder)
Broadcasts a message to all controller nodes including self.- Type Parameters:
M
- message type- Parameters:
message
- message to sendsubject
- message subjectencoder
- function for encoding message to byte[]
-
unicast
<M> CompletableFuture<Void> unicast(M message, MessageSubject subject, Function<M,byte[]> encoder, NodeId toNodeId)
Sends a message to the specified controller node.- Type Parameters:
M
- message type- Parameters:
message
- message to sendsubject
- message subjectencoder
- function for encoding message to byte[]toNodeId
- destination node identifier- Returns:
- future that is completed when the message is sent
-
multicast
<M> void multicast(M message, MessageSubject subject, Function<M,byte[]> encoder, Set<NodeId> nodeIds)
Multicasts a message to a set of controller nodes.- Type Parameters:
M
- message type- Parameters:
message
- message to sendsubject
- message subjectencoder
- function for encoding message to byte[]nodeIds
- recipient node identifiers
-
sendAndReceive
default <M,R> CompletableFuture<R> sendAndReceive(M message, MessageSubject subject, Function<M,byte[]> encoder, Function<byte[],R> decoder, NodeId toNodeId)
Sends a message and expects a reply.- Type Parameters:
M
- request typeR
- reply type- Parameters:
message
- message to sendsubject
- message subjectencoder
- function for encoding request to byte[]decoder
- function for decoding response from byte[]toNodeId
- recipient node identifier- Returns:
- reply future
-
sendAndReceive
<M,R> CompletableFuture<R> sendAndReceive(M message, MessageSubject subject, Function<M,byte[]> encoder, Function<byte[],R> decoder, NodeId toNodeId, Duration timeout)
Sends a message and expects a reply.- Type Parameters:
M
- request typeR
- reply type- Parameters:
message
- message to sendsubject
- message subjectencoder
- function for encoding request to byte[]decoder
- function for decoding response from byte[]toNodeId
- recipient node identifiertimeout
- the message timeout- Returns:
- reply future
-
addSubscriber
<M,R> void addSubscriber(MessageSubject subject, Function<byte[],M> decoder, Function<M,R> handler, Function<R,byte[]> encoder, Executor executor)
Adds a new subscriber for the specified message subject.- Type Parameters:
M
- incoming message typeR
- reply message type- Parameters:
subject
- message subjectdecoder
- 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
-
addSubscriber
<M,R> void addSubscriber(MessageSubject subject, Function<byte[],M> decoder, Function<M,CompletableFuture<R>> handler, Function<R,byte[]> encoder)
Adds a new subscriber for the specified message subject.- Type Parameters:
M
- incoming message typeR
- reply message type- Parameters:
subject
- message subjectdecoder
- decoder for resurrecting incoming messagehandler
- handler function that processes the incoming message and produces a replyencoder
- encoder for serializing reply
-
addSubscriber
<M> void addSubscriber(MessageSubject subject, Function<byte[],M> decoder, Consumer<M> handler, Executor executor)
Adds a new subscriber for the specified message subject.- Type Parameters:
M
- incoming message type- Parameters:
subject
- message subjectdecoder
- decoder to resurrecting incoming messagehandler
- handler for handling messageexecutor
- executor to run this handler on
-
removeSubscriber
void removeSubscriber(MessageSubject subject)
Removes a subscriber for the specified message subject.- Parameters:
subject
- message subject
-
-