Class NodeCloudMessenger

java.lang.Object
eu.cloudnetservice.driver.impl.channel.BaseCloudMessenger
eu.cloudnetservice.node.impl.provider.NodeCloudMessenger
All Implemented Interfaces:
eu.cloudnetservice.driver.provider.CloudMessenger

@Singleton @Provides(eu.cloudnetservice.driver.provider.CloudMessenger.class) public class NodeCloudMessenger extends eu.cloudnetservice.driver.impl.channel.BaseCloudMessenger
Messenger implementation that relays channel messages to various targets within the cluster.
Since:
4.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final Type
     
    protected final eu.cloudnetservice.node.service.CloudServiceManager
     
    private static final org.slf4j.Logger
     
    protected final eu.cloudnetservice.node.cluster.NodeServerProvider
     

    Fields inherited from interface eu.cloudnetservice.driver.provider.CloudMessenger

    SYNC_CHANNEL_MESSAGE_QUERY_TIMEOUT_MS
  • Constructor Summary

    Constructors
    Constructor
    Description
    NodeCloudMessenger(@NonNull eu.cloudnetservice.node.cluster.NodeServerProvider nodeServerProvider, @NonNull eu.cloudnetservice.node.service.CloudServiceManager cloudServiceManager)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected @NonNull Collection<eu.cloudnetservice.driver.network.NetworkChannel>
    findTargetChannels(@NonNull eu.cloudnetservice.driver.channel.ChannelMessageTarget target, boolean allowClusterRedirect)
    Finds the corresponding network channels for the given channel message target.
    protected @NonNull Collection<eu.cloudnetservice.driver.network.NetworkChannel>
    findTargetChannels(@NonNull Collection<eu.cloudnetservice.driver.channel.ChannelMessageTarget> targets, boolean allowClusterRedirect)
    Finds the corresponding channels for the given channel message targets.
    void
    sendChannelMessage(@NonNull eu.cloudnetservice.driver.channel.ChannelMessage channelMessage)
    void
    sendChannelMessage(@NonNull eu.cloudnetservice.driver.channel.ChannelMessage message, boolean allowClusterRedirect)
    Sends the given channel message to all provided targets, without waiting for any response.
    @NonNull CompletableFuture<Collection<eu.cloudnetservice.driver.channel.ChannelMessage>>
    sendChannelMessageQueryAsync(@NonNull eu.cloudnetservice.driver.channel.ChannelMessage message)
    @NonNull CompletableFuture<Collection<eu.cloudnetservice.driver.channel.ChannelMessage>>
    sendChannelMessageQueryAsync(@NonNull eu.cloudnetservice.driver.channel.ChannelMessage message, boolean allowClusterRedirect)
    Sends the given channel message, waiting for a result of each sent message.

    Methods inherited from class eu.cloudnetservice.driver.impl.channel.BaseCloudMessenger

    sendChannelMessageAsync, sendChannelMessageQuery, sendSingleChannelMessageQuery, sendSingleChannelMessageQueryAsync

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CHANNEL_MESSAGE_LIST_TYPE

      protected static final Type CHANNEL_MESSAGE_LIST_TYPE
    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • nodeServerProvider

      protected final eu.cloudnetservice.node.cluster.NodeServerProvider nodeServerProvider
    • cloudServiceManager

      protected final eu.cloudnetservice.node.service.CloudServiceManager cloudServiceManager
  • Constructor Details

    • NodeCloudMessenger

      @Inject public NodeCloudMessenger(@NonNull @NonNull eu.cloudnetservice.node.cluster.NodeServerProvider nodeServerProvider, @NonNull @NonNull eu.cloudnetservice.node.service.CloudServiceManager cloudServiceManager)
  • Method Details

    • sendChannelMessage

      public void sendChannelMessage(@NonNull @NonNull eu.cloudnetservice.driver.channel.ChannelMessage channelMessage)
    • sendChannelMessageQueryAsync

      @NonNull public @NonNull CompletableFuture<Collection<eu.cloudnetservice.driver.channel.ChannelMessage>> sendChannelMessageQueryAsync(@NonNull @NonNull eu.cloudnetservice.driver.channel.ChannelMessage message)
    • sendChannelMessage

      public void sendChannelMessage(@NonNull @NonNull eu.cloudnetservice.driver.channel.ChannelMessage message, boolean allowClusterRedirect)
      Sends the given channel message to all provided targets, without waiting for any response.
      Parameters:
      message - the channel message to send.
      allowClusterRedirect - if other nodes in the cluster are to be considered as targets.
      Throws:
      NullPointerException - if the given channel message is null.
    • sendChannelMessageQueryAsync

      @NonNull public @NonNull CompletableFuture<Collection<eu.cloudnetservice.driver.channel.ChannelMessage>> sendChannelMessageQueryAsync(@NonNull @NonNull eu.cloudnetservice.driver.channel.ChannelMessage message, boolean allowClusterRedirect)
      Sends the given channel message, waiting for a result of each sent message. If one receiver does not respond, the returned future only completes after the configured query timeout of the target channel. Therefore, a timout is advisable.
      Parameters:
      message - the channel message to send.
      allowClusterRedirect - if other nodes in the cluster are to be considered as targets.
      Throws:
      NullPointerException - if the given channel message is null.
    • findTargetChannels

      @NonNull protected @NonNull Collection<eu.cloudnetservice.driver.network.NetworkChannel> findTargetChannels(@NonNull @NonNull Collection<eu.cloudnetservice.driver.channel.ChannelMessageTarget> targets, boolean allowClusterRedirect)
      Finds the corresponding channels for the given channel message targets.
      Parameters:
      targets - the targets to find the channels for.
      allowClusterRedirect - if other nodes in the cluster are to be considered as targets.
      Returns:
      the resolvable network channels for the given channel message targets.
      Throws:
      NullPointerException - if the given targets collection is null.
    • findTargetChannels

      @NonNull protected @NonNull Collection<eu.cloudnetservice.driver.network.NetworkChannel> findTargetChannels(@NonNull @NonNull eu.cloudnetservice.driver.channel.ChannelMessageTarget target, boolean allowClusterRedirect)
      Finds the corresponding network channels for the given channel message target.
      Parameters:
      target - the channel message target to find the channels for.
      allowClusterRedirect - if other nodes in the cluster are to be considered as targets.
      Returns:
      the resolvable network channels for the given channel message target.
      Throws:
      NullPointerException - if the given channel message target is null.