org.apache.cassandra.service
Class AntiEntropyService
java.lang.Object
org.apache.cassandra.service.AntiEntropyService
public class AntiEntropyService
- extends java.lang.Object
AntiEntropyService encapsulates "validating" (hashing) individual column families,
exchanging MerkleTrees with remote nodes via a TreeRequest/Response conversation,
and then triggering repairs for disagreeing ranges.
Every Tree conversation has an 'initiator', where valid trees are sent after generation
and where the local and remote tree will rendezvous in rendezvous(cf, endpoint, tree).
Once the trees rendezvous, a Differencer is executed and the service can trigger repairs
for disagreeing ranges.
Tree comparison and repair triggering occur in the single threaded Stage.ANTIENTROPY.
The steps taken to enact a repair are as follows:
1. A major compaction is triggered via nodeprobe:
* Nodeprobe sends TreeRequest messages to all neighbors of the target node: when a node
receives a TreeRequest, it will perform a readonly compaction to immediately validate
the column family.
2. The compaction process validates the column family by:
* Calling Validator.prepare(), which samples the column family to determine key distribution,
* Calling Validator.add() in order for every row in the column family,
* Calling Validator.complete() to indicate that all rows have been added.
* Calling complete() indicates that a valid MerkleTree has been created for the column family.
* The valid tree is returned to the requesting node via a TreeResponse.
3. When a node receives a TreeResponse, it passes the tree to rendezvous(), which checks for trees to
rendezvous with / compare to:
* If the tree is local, it is cached, and compared to any trees that were received from neighbors.
* If the tree is remote, it is immediately compared to a local tree if one is cached. Otherwise,
the remote tree is stored until a local tree can be generated.
* A Differencer object is enqueued for each comparison.
4. Differencers are executed in Stage.ANTIENTROPY, to compare the two trees, and perform repair via the
streaming api.
Method Summary |
org.apache.cassandra.service.AntiEntropyService.RepairSession |
getRepairSession(Range range,
java.lang.String tablename,
java.lang.String... cfnames)
Requests repairs for the given table and column families, and blocks until all repairs have been completed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
instance
public static final AntiEntropyService instance
REQUEST_TIMEOUT
public static final long REQUEST_TIMEOUT
- See Also:
- Constant Field Values
AntiEntropyService
protected AntiEntropyService()
- Protected constructor. Use AntiEntropyService.instance.
getRepairSession
public org.apache.cassandra.service.AntiEntropyService.RepairSession getRepairSession(Range range,
java.lang.String tablename,
java.lang.String... cfnames)
- Requests repairs for the given table and column families, and blocks until all repairs have been completed.
TODO: Should add retries: if nodes go offline before they respond to the requests, this could block forever.
Copyright © 2011 The Apache Software Foundation