## org.apache.cassandra.service
Class AntiEntropyService.Validator

    java.lang.Object
      org.apache.cassandra.service.AntiEntropyService.Validator

All Implemented Interfaces:
  java.lang.Runnable

Enclosing class:
  AntiEntropyService

    public static class AntiEntropyService.Validator

extends java.lang.Object
implements java.lang.Runnable

A Strategy to handle building and validating a merkle tree for a column family. Lifecycle: 1. prepare() - Initialize tree with samples. 2. add() - 0 or more times, to add hashes to the tree. 3. complete() - Enqueues any operations that were blocked waiting for a valid tree.

Field Summary
`static MerkleTree.RowHash` `EMPTY_ROW`
`AntiEntropyService.TreeRequest` `request`
`MerkleTree` `tree`

Method Summary
`void` `add(AbstractCompactedRow row)` Called (in order) for every row present in the CF.
`void` `complete()` Registers the newly created tree for rendezvous in Stage.ANTIENTROPY.
`void` `prepare(ColumnFamilyStore cfs)`
`void` `run()` Called after the validation lifecycle to respond with the now valid tree.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### request

    public final AntiEntropyService.TreeRequest request

### tree

    public final MerkleTree tree

### EMPTY_ROW

    public static final MerkleTree.RowHash EMPTY_ROW

Method Detail

### prepare

    public void prepare(ColumnFamilyStore cfs)

### add

    public void add(AbstractCompactedRow row)

  Called (in order) for every row present in the CF. Hashes the row, and adds it to the tree being built. There are four possible cases: 1. Token is greater than range.right (we haven't generated a range for it yet), 2. Token is less than/equal to range.left (the range was valid), 3. Token is contained in the range (the range is in progress), 4. No more invalid ranges exist. TODO: Because we only validate completely empty trees at the moment, we do not bother dealing with case 2 and case 4 should result in an error. Additionally, there is a special case for the minimum token, because although it sorts first, it is contained in the last possible range.

  Parameters:
    `row` - The row.

### complete

    public void complete()

  Registers the newly created tree for rendezvous in Stage.ANTIENTROPY.

### run

    public void run()

  Called after the validation lifecycle to respond with the now valid tree. Runs in Stage.ANTIENTROPY.

  Specified by:
    `run` in interface `java.lang.Runnable`

Copyright © 2012 The Apache Software Foundation