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>
      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.
      <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.
      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 Release
        Adds a new subscriber for the specified message subject.
        Parameters:
        subject - message subject
        subscriber - message subscriber
        executor - 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 send
        subject - message subject
        encoder - 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 send
        subject - message subject
        encoder - 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 send
        subject - message subject
        encoder - 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 send
        subject - message subject
        encoder - 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 type
        R - reply type
        Parameters:
        message - message to send
        subject - message subject
        encoder - 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 type
        R - reply message type
        Parameters:
        subject - message subject
        decoder - decoder for resurrecting incoming message
        handler - handler function that processes the incoming message and produces a reply
        encoder - encoder for serializing reply
        executor - 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 type
        R - reply message type
        Parameters:
        subject - message subject
        decoder - decoder for resurrecting incoming message
        handler - handler function that processes the incoming message and produces a reply
        encoder - 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 subject
        decoder - decoder to resurrecting incoming message
        handler - handler for handling message
        executor - executor to run this handler on
      • removeSubscriber

        void removeSubscriber​(MessageSubject subject)
        Removes a subscriber for the specified message subject.
        Parameters:
        subject - message subject