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
FieldsModifier and TypeFieldDescriptionprotected static final Typeprotected final eu.cloudnetservice.node.service.CloudServiceManagerprivate static final org.slf4j.Loggerprotected final eu.cloudnetservice.node.cluster.NodeServerProviderFields inherited from interface eu.cloudnetservice.driver.provider.CloudMessenger
SYNC_CHANNEL_MESSAGE_QUERY_TIMEOUT_MS -
Constructor Summary
ConstructorsConstructorDescriptionNodeCloudMessenger(@NonNull eu.cloudnetservice.node.cluster.NodeServerProvider nodeServerProvider, @NonNull eu.cloudnetservice.node.service.CloudServiceManager cloudServiceManager) -
Method Summary
Modifier and TypeMethodDescriptionprotected @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.voidsendChannelMessage(@NonNull eu.cloudnetservice.driver.channel.ChannelMessage channelMessage) voidsendChannelMessage(@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
-
Field Details
-
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
-
-
Method Details
-
sendChannelMessage
-
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.
-