Class NettyStreamingMessageSender
- java.lang.Object
-
- org.apache.cassandra.streaming.async.NettyStreamingMessageSender
-
- All Implemented Interfaces:
StreamingMessageSender
public class NettyStreamingMessageSender extends java.lang.Object implements StreamingMessageSender
Responsible for sendingStreamMessage
s to a given peer. We manage an array of nettyChannel
s for sendingOutgoingStreamMessage
instances; all otherStreamMessage
types are sent via a special control channel. The reason for this is to treat those messages carefully and not let them get stuck behind a stream transfer. One of the challenges when sending streams is we might need to delay shipping the stream if: - we've exceeded our network I/O use due to rate limiting (at the cassandra level) - the receiver isn't keeping up, which causes the local TCP socket buffer to not empty, which causes epoll writes to not move any bytes to the socket, which causes buffers to stick around in user-land (a/k/a cassandra) memory. When those conditions occur, it's easy enough to reschedule processing the stream once the resources pick up (we acquire the permits from the rate limiter, or the socket drains). However, we need to ensure that no other messages are submitted to the same channel while the current stream is still being processed.
-
-
Constructor Summary
Constructors Constructor Description NettyStreamingMessageSender(StreamSession session, OutboundConnectionSettings template, StreamConnectionFactory factory, int streamingVersion, boolean isPreview)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
connected()
boolean
hasControlChannel()
void
initialize()
void
injectControlMessageChannel(io.netty.channel.Channel channel)
Used by follower to setup control message channel created by initiatorvoid
sendMessage(StreamMessage message)
void
setClosed()
For testing purposes only.
-
-
-
Constructor Detail
-
NettyStreamingMessageSender
public NettyStreamingMessageSender(StreamSession session, OutboundConnectionSettings template, StreamConnectionFactory factory, int streamingVersion, boolean isPreview)
-
-
Method Detail
-
initialize
public void initialize()
- Specified by:
initialize
in interfaceStreamingMessageSender
-
hasControlChannel
public boolean hasControlChannel()
-
injectControlMessageChannel
public void injectControlMessageChannel(io.netty.channel.Channel channel)
Used by follower to setup control message channel created by initiator
-
sendMessage
public void sendMessage(StreamMessage message)
- Specified by:
sendMessage
in interfaceStreamingMessageSender
-
setClosed
public void setClosed()
For testing purposes only.
-
connected
public boolean connected()
- Specified by:
connected
in interfaceStreamingMessageSender
-
close
public void close()
- Specified by:
close
in interfaceStreamingMessageSender
-
-