Tuesday, September 18, 2012

Apache Cassandra - Moving a node to a different token range


Moving nodes


nodetool move: move the target node to a given Token. Moving is both a convenience over and more efficient than decommission + bootstrap. After moving a node, nodetool cleanup should be run to remove any unnecessary data.
As with bootstrap, see Streaming for how to monitor progress.


Streaming :

Transfer


The following steps occur for Stream Transfers.
  1. Source has a list of ranges it must transfer to another node.
  2. Source copies the data in those ranges to sstable files in preparation for streaming. This is called anti-compaction (because compaction merges multiple sstable files into one, and this does the opposite).
  3. Source builds a list of PendingFile's which contains information on each sstable to be transfered.
  4. Source starts streaming the first file from the list, followed by the log "Waiting for transfer to $some_node to complete". The header for the stream contains information on the streamed file for the Destination to interpret what to do with the incoming stream.
  5. Destination receives the file writes it to disk and sends a FileStatus.
  6. On successful transfer the Source streams the next file until its done, on error it re-streams the same file.

Request


  1. Destination compiles a list of ranges it needs from another node.
  2. Destination sends a StreamRequestMessage to the Source node with the list of ranges.
  3. Source prepares the SSTables for those ranges and creates the PendingFile's.
  4. Source starts streaming the first file in the list. The header for the first stream contains info of the current stream and a list of the remaining PendingFile's that fall in the requested ranges.
  5. Destination receives the stream and writes it to disk, followed by the log message "Streaming added org.apache.cassandra.io.sstable.SSTableReader(path='/var/lib/cassandra/data/Keyspace1/Standard1-e-1-Data.db')".
  6. Destination then takes the lead and requests the remaining files one at a time. If an error occurs it re-requests the same file, if not continues with the next file until done.
  7. Source streams each of the requested files. The files are already anti-compacted, so it just streams them to the Destination.

1 comment: