org.apache.cassandra.streaming
Class StreamOut

java.lang.Object
  extended by org.apache.cassandra.streaming.StreamOut

public class StreamOut
extends java.lang.Object

This class handles streaming data from one node to another. The source node [the Out side] is always in charge of the streaming session. Streams may be initiated either directly by the source via the methods in this class, or on demand from the target (via StreamRequest). Files to stream are grouped into sessions, which can have callbacks associated with them so that (for instance) we can mark a new node a full member of the cluster after all the data it needs has been streamed. The source begins a session by sending a Message with the stream bit flag in the Header turned on. Part of that Message will include a StreamHeader that includes the files that will be streamed as part of that session, as well as the first file-to-be-streamed. (Combining session list and first file like this is inconvenient, but not as inconvenient as the old three-part send-file-list, wait-for-ack, start-first-file dance.) This is done over a separate TCP connection to avoid blocking ordinary intra-node traffic during the stream. So there is no Handler for the main stream of data -- when a connection sets the Stream bit, IncomingTcpConnection knows what to expect without any further Messages. After each file, the target node [the In side] will send a StreamReply indicating success (FILE_FINISHED) or failure (FILE_RETRY). When all files have been successfully transferred and integrated the target will send an additional SESSION_FINISHED reply and the session is complete. For Stream requests (for bootstrap), one subtlety is that we always have to create at least one stream reply, even if the list of files is empty, otherwise the target has no way to know that it can stop waiting for an answer.


Constructor Summary
StreamOut()
           
 
Method Summary
static void transferRanges(java.net.InetAddress target, Table table, java.util.Collection<Range> ranges, java.lang.Runnable callback, OperationType type)
          Stream the given ranges to the target endpoint from each CF in the given keyspace.
static void transferRanges(StreamOutSession session, java.lang.Iterable<ColumnFamilyStore> cfses, java.util.Collection<Range> ranges, OperationType type)
          Stream the given ranges to the target endpoint from each of the given CFs.
static void transferSSTables(StreamOutSession session, java.lang.Iterable<SSTableReader> sstables, java.util.Collection<Range> ranges, OperationType type)
          Low-level transfer of matching portions of a group of sstables from a single table to the target endpoint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamOut

public StreamOut()
Method Detail

transferRanges

public static void transferRanges(java.net.InetAddress target,
                                  Table table,
                                  java.util.Collection<Range> ranges,
                                  java.lang.Runnable callback,
                                  OperationType type)
Stream the given ranges to the target endpoint from each CF in the given keyspace.


transferRanges

public static void transferRanges(StreamOutSession session,
                                  java.lang.Iterable<ColumnFamilyStore> cfses,
                                  java.util.Collection<Range> ranges,
                                  OperationType type)
Stream the given ranges to the target endpoint from each of the given CFs.


transferSSTables

public static void transferSSTables(StreamOutSession session,
                                    java.lang.Iterable<SSTableReader> sstables,
                                    java.util.Collection<Range> ranges,
                                    OperationType type)
                             throws java.io.IOException
Low-level transfer of matching portions of a group of sstables from a single table to the target endpoint. You should probably call transferRanges instead. This moreover assumes that references have been acquired on the sstables.

Throws:
java.io.IOException


Copyright © 2011 The Apache Software Foundation