use of org.apache.cassandra.streaming.StreamingChannel in project cassandra by apache.
the class StreamingMultiplexedChannel method createChannel.
private StreamingChannel createChannel(StreamingChannel.Kind kind) throws IOException {
logger.debug("Creating stream session to {} as {}", to, session.isFollower() ? "follower" : "initiator");
StreamingChannel channel = factory.create(to, messagingVersion, kind);
if (kind == StreamingChannel.Kind.CONTROL) {
executorFactory().startThread(String.format("Stream-Deserializer-%s-%s", to.toString(), channel.id()), new StreamDeserializingTask(session, channel, messagingVersion));
session.attachInbound(channel);
}
session.attachOutbound(channel);
logger.debug("Creating {}", channel.description());
return channel;
}
use of org.apache.cassandra.streaming.StreamingChannel in project cassandra by apache.
the class NettyStreamingConnectionFactory method connect.
public static NettyStreamingChannel connect(OutboundConnectionSettings template, int messagingVersion, StreamingChannel.Kind kind) throws IOException {
EventLoop eventLoop = MessagingService.instance().socketFactory.outboundStreamingGroup().next();
int attempts = 0;
while (true) {
Future<Result<StreamingSuccess>> result = initiateStreaming(eventLoop, template.withDefaults(ConnectionCategory.STREAMING), messagingVersion);
// initiate has its own timeout, so this is "guaranteed" to return relatively promptly
result.awaitUninterruptibly();
if (result.isSuccess()) {
Channel channel = result.getNow().success().channel;
NettyStreamingChannel streamingChannel = new NettyStreamingChannel(messagingVersion, channel, kind);
if (kind == StreamingChannel.Kind.CONTROL) {
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast("stream", streamingChannel);
}
return streamingChannel;
}
if (++attempts == MAX_CONNECT_ATTEMPTS)
throw new IOException("failed to connect to " + template.to + " for streaming data", result.cause());
}
}
Aggregations