cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jun...@apache.org
Subject svn commit: r891043 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra: service/AntiEntropyService.java utils/MerkleTree.java
Date Tue, 15 Dec 2009 22:32:31 GMT
Author: junrao
Date: Tue Dec 15 22:32:30 2009
New Revision: 891043

URL: http://svn.apache.org/viewvc?rev=891043&view=rev
Log:
notify neighbors and fix comments; patched by Stu Hood, reviewed by junrao for CASSANDRA-629

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/MerkleTree.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java?rev=891043&r1=891042&r2=891043&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java
Tue Dec 15 22:32:30 2009
@@ -388,7 +388,7 @@
          *  4. No more invalid ranges exist.
          *
          * TODO: Because we only validate completely empty trees at the moment, we
-         * do not both dealing with case 2 and case 4 should result in an error.
+         * 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.
@@ -474,15 +474,9 @@
             Collection<InetAddress> neighbors = Collections2.filter(ss.getNaturalEndpoints(ss.getLocalToken()),
                                                                     Predicates.not(Predicates.equalTo(local)));
 
-            // cache the local tree
+            // cache the local tree and then broadcast it to our neighbors
             aes.register(cf, local, tree);
-
-            if (!local.equals(initiator))
-            {
-                // one of our neighbors initiated: broadcast the tree to all of them
-                aes.notifyNeighbors(this, local, neighbors);
-            }
-            // else: we initiated this validation session: wait for responses
+            aes.notifyNeighbors(this, local, neighbors);
 
             // return any old object
             return AntiEntropyService.class;
@@ -791,6 +785,7 @@
 
     /**
      * A tuple of table and cf.
+     * TODO: Use utils.Pair once it implements hashCode/equals.
      */
     static final class CFTuple
     {

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/MerkleTree.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/MerkleTree.java?rev=891043&r1=891042&r2=891043&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/MerkleTree.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/MerkleTree.java Tue Dec
15 22:32:30 2009
@@ -30,16 +30,19 @@
 /**
  * A MerkleTree implemented as a binary tree.
  *
- * A MerkleTree is a full binary that represents a perfect binary tree of
+ * A MerkleTree is a full binary tree that represents a perfect binary tree of
  * depth 'hashdepth'. In a perfect binary tree, each leaf contains a
  * sequentially hashed range, and each inner node contains the binary hash of
  * its two children. In the MerkleTree, many ranges will not be split to the
  * full depth of the perfect binary tree: the leaves of this tree are Leaf objects,
  * which contain the computed values of the nodes that would be below them if
  * the tree were perfect.
+ * 
+ * The hash values of the inner nodes of the MerkleTree are calculated lazily based
+ * on their children when the hash of a range is requested with hash(range).
  *
  * Inputs passed to TreeRange.validate should be calculated using a very secure hash,
- * because all hashing internal to the tree is accomplished using XOR.
+ * because all hashing internal to the tree is accomplished using XOR. 
  *
  * If two MerkleTrees have the same hashdepth, they represent a perfect tree
  * of the same depth, and can always be compared, regardless of size or splits.



Mime
View raw message