Interface ClusterCommunicationService
-
public interface ClusterCommunicationService
Service for assisting communications between controller cluster nodes.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description <M> void
addSubscriber(MessageSubject subject, java.util.function.Function<byte[],M> decoder, java.util.function.Consumer<M> handler, java.util.concurrent.Executor executor)
Adds a new subscriber for the specified message subject.<M,R>
voidaddSubscriber(MessageSubject subject, java.util.function.Function<byte[],M> decoder, java.util.function.Function<M,java.util.concurrent.CompletableFuture<R>> handler, java.util.function.Function<R,byte[]> encoder)
Adds a new subscriber for the specified message subject.<M,R>
voidaddSubscriber(MessageSubject subject, java.util.function.Function<byte[],M> decoder, java.util.function.Function<M,R> handler, java.util.function.Function<R,byte[]> encoder, java.util.concurrent.Executor executor)
Adds a new subscriber for the specified message subject.void
addSubscriber(MessageSubject subject, ClusterMessageHandler subscriber, java.util.concurrent.ExecutorService executor)
Deprecated.in Cardinal Release<M> void
broadcast(M message, MessageSubject subject, java.util.function.Function<M,byte[]> encoder)
Broadcasts a message to all controller nodes.<M> void
broadcastIncludeSelf(M message, MessageSubject subject, java.util.function.Function<M,byte[]> encoder)
Broadcasts a message to all controller nodes including self.<M> void
multicast(M message, MessageSubject subject, java.util.function.Function<M,byte[]> encoder, java.util.Set<NodeId> nodeIds)
Multicasts a message to a set of controller nodes.void
removeSubscriber(MessageSubject subject)
Removes a subscriber for the specified message subject.<M,R>
java.util.concurrent.CompletableFuture<R>sendAndReceive(M message, MessageSubject subject, java.util.function.Function<M,byte[]> encoder, java.util.function.Function<byte[],R> decoder, NodeId toNodeId)
Sends a message and expects a reply.<M> java.util.concurrent.CompletableFuture<java.lang.Void>
unicast(M message, MessageSubject subject, java.util.function.Function<M,byte[]> encoder, NodeId toNodeId)
Sends a message to the specified controller node.
-
-
-
Method Detail
-
addSubscriber
@Deprecated void addSubscriber(MessageSubject subject, ClusterMessageHandler subscriber, java.util.concurrent.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, java.util.function.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, java.util.function.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> java.util.concurrent.CompletableFuture<java.lang.Void> unicast(M message, MessageSubject subject, java.util.function.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, java.util.function.Function<M,byte[]> encoder, java.util.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
<M,R> java.util.concurrent.CompletableFuture<R> sendAndReceive(M message, MessageSubject subject, java.util.function.Function<M,byte[]> encoder, java.util.function.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
-
addSubscriber
<M,R> void addSubscriber(MessageSubject subject, java.util.function.Function<byte[],M> decoder, java.util.function.Function<M,R> handler, java.util.function.Function<R,byte[]> encoder, java.util.concurrent.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, java.util.function.Function<byte[],M> decoder, java.util.function.Function<M,java.util.concurrent.CompletableFuture<R>> handler, java.util.function.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, java.util.function.Function<byte[],M> decoder, java.util.function.Consumer<M> handler, java.util.concurrent.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
-
-