Class DefaultClusterCommunicationService

java.lang.Object
io.atomix.cluster.messaging.impl.DefaultClusterCommunicationService
All Implemented Interfaces:
ClusterCommunicationService, ManagedClusterCommunicationService, Managed<ClusterCommunicationService>

public class DefaultClusterCommunicationService extends Object implements ManagedClusterCommunicationService
Cluster communication service implementation.
  • Field Details

  • Constructor Details

  • Method Details

    • broadcast

      public <M> void broadcast(String subject, M message, Function<M,byte[]> encoder, boolean reliable)
      Description copied from interface: ClusterCommunicationService
      Broadcasts a message to all members.
      Specified by:
      broadcast in interface ClusterCommunicationService
      Type Parameters:
      M - message type
      Parameters:
      subject - message subject
      message - message to send
      encoder - function for encoding message to byte[]
      reliable - whether to perform a reliable (TCP) unicast
    • multicast

      public <M> void multicast(String subject, M message, Function<M,byte[]> encoder, Set<MemberId> nodes, boolean reliable)
      Description copied from interface: ClusterCommunicationService
      Multicasts a message to a set of members.
      Specified by:
      multicast in interface ClusterCommunicationService
      Type Parameters:
      M - message type
      Parameters:
      subject - message subject
      message - message to send
      encoder - function for encoding message to byte[]
      nodes - recipient node identifiers
      reliable - whether to perform a reliable (TCP) unicast
    • unicast

      public <M> void unicast(String subject, M message, Function<M,byte[]> encoder, MemberId memberId, boolean reliable)
      Description copied from interface: ClusterCommunicationService
      Sends a message to a member.
      Specified by:
      unicast in interface ClusterCommunicationService
      Type Parameters:
      M - message type
      Parameters:
      subject - message subject
      message - message to send
      encoder - function for encoding message to byte[]
      memberId - recipient node identifier
      reliable - whether to perform a reliable (TCP) unicast
    • send

      public <M, R> CompletableFuture<R> send(String subject, M message, Function<M,byte[]> encoder, Function<byte[],R> decoder, MemberId toMemberId, Duration timeout)
      Description copied from interface: ClusterCommunicationService
      Sends a message and expects a reply.
      Specified by:
      send in interface ClusterCommunicationService
      Type Parameters:
      M - request type
      R - reply type
      Parameters:
      subject - message subject
      message - message to send
      encoder - function for encoding request to byte[]
      decoder - function for decoding response from byte[]
      toMemberId - recipient node identifier
      timeout - response timeout
      Returns:
      reply future
    • subscribe

      public <M, R> void subscribe(String subject, Function<byte[],M> decoder, Function<M,R> handler, Function<R,byte[]> encoder, Executor executor)
      Description copied from interface: ClusterCommunicationService
      Adds a new subscriber for the specified message subject.
      Specified by:
      subscribe in interface ClusterCommunicationService
      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
    • subscribe

      public <M, R> void subscribe(String subject, Function<byte[],M> decoder, Function<M,CompletableFuture<R>> handler, Function<R,byte[]> encoder)
      Description copied from interface: ClusterCommunicationService
      Adds a new subscriber for the specified message subject.
      Specified by:
      subscribe in interface ClusterCommunicationService
      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
    • subscribe

      public <M> void subscribe(String subject, Function<byte[],M> decoder, Consumer<M> handler, Executor executor)
      Description copied from interface: ClusterCommunicationService
      Adds a new subscriber for the specified message subject.
      Specified by:
      subscribe in interface ClusterCommunicationService
      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
    • subscribe

      public <M> void subscribe(String subject, Function<byte[],M> decoder, BiConsumer<MemberId,M> handler, Executor executor)
      Description copied from interface: ClusterCommunicationService
      Adds a new subscriber for the specified message subject.
      Specified by:
      subscribe in interface ClusterCommunicationService
      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
    • unsubscribe

      public void unsubscribe(String subject)
      Description copied from interface: ClusterCommunicationService
      Removes a subscriber for the specified message subject.
      Specified by:
      unsubscribe in interface ClusterCommunicationService
      Parameters:
      subject - message subject
    • start

      Specified by:
      start in interface Managed<ClusterCommunicationService>
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface Managed<ClusterCommunicationService>
    • stop

      public CompletableFuture<Void> stop()
      Specified by:
      stop in interface Managed<ClusterCommunicationService>