cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r832531 - in /incubator/cassandra/branches/cassandra-0.4: src/java/org/apache/cassandra/dht/ src/java/org/apache/cassandra/locator/ src/java/org/apache/cassandra/service/ test/unit/org/apache/cassandra/dht/
Date Tue, 03 Nov 2009 20:03:32 GMT
Author: jbellis
Date: Tue Nov  3 20:03:32 2009
New Revision: 832531

URL: http://svn.apache.org/viewvc?rev=832531&view=rev
Log:
Fixes null token getting passed to Bootstapper; Correctly includes new nodes in src-target
calculation.  patch by Sandeep Tata; reviewed by jbellis for CASSANDRA-501

Modified:
    incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/dht/BootStrapper.java
    incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/locator/TokenMetadata.java
    incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageService.java
    incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/dht/BootStrapperTest.java

Modified: incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/dht/BootStrapper.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/dht/BootStrapper.java?rev=832531&r1=832530&r2=832531&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/dht/BootStrapper.java
(original)
+++ incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/dht/BootStrapper.java
Tue Nov  3 20:03:32 2009
@@ -137,7 +137,8 @@
         if (logger_.isDebugEnabled())
           logger_.debug("Total number of new ranges " + newRanges.length);
         /* Calculate the list of nodes that handle the new ranges */
-        Map<Range, List<EndPoint>> newRangeToEndPointMap = StorageService.instance().constructRangeToEndPointMap(newRanges);
+        Map<Range, List<EndPoint>> newRangeToEndPointMap = 
+            StorageService.instance().constructRangeToEndPointMap(newRanges, tokenMetadata_.cloneTokenEndPointMapIncludingBootstrapNodes());
         /* Calculate ranges that need to be sent and from whom to where */
         Map<Range, List<BootstrapSourceTarget>> rangesWithSourceTarget = LeaveJoinProtocolHelper.getRangeSourceTargetInfo(oldRangeToEndPointMap,
newRangeToEndPointMap);
         return rangesWithSourceTarget;

Modified: incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/locator/TokenMetadata.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/locator/TokenMetadata.java?rev=832531&r1=832530&r2=832531&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/locator/TokenMetadata.java
(original)
+++ incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/locator/TokenMetadata.java
Tue Nov  3 20:03:32 2009
@@ -213,6 +213,24 @@
         }
     }
     
+    public Map<Token, EndPoint> cloneTokenEndPointMapIncludingBootstrapNodes()
+    {
+        lock_.readLock().lock();
+        try
+        {            
+            Map h1 = new HashMap<Token, EndPoint>( tokenToEndPointMap_ );
+            for (Map.Entry<Token, EndPoint> e: bootstrapNodes.entrySet())
+            {
+                h1.put(e.getKey(), e.getValue());
+            }
+            return h1;
+        }
+        finally
+        {
+            lock_.readLock().unlock();
+        }
+    }
+    
     /*
      * Returns a safe clone of endPointTokenMap_.
     */

Modified: incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageService.java?rev=832531&r1=832530&r2=832531&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageService.java
(original)
+++ incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageService.java
Tue Nov  3 20:03:32 2009
@@ -301,7 +301,7 @@
         if (isBootstrapMode)
         {
             logger_.info("Starting in bootstrap mode");
-            doBootstrap(StorageService.getLocalStorageEndPoint());
+            bootStrapper_.submit(new BootStrapper(new EndPoint[]{StorageService.getLocalStorageEndPoint()},
storageMetadata_.getToken()));
             Gossiper.instance().addApplicationState(BOOTSTRAP_MODE, new ApplicationState(""));
         }
     }
@@ -317,9 +317,9 @@
     }
 
     /* TODO: used for testing */
-    public void updateTokenMetadata(Token token, EndPoint endpoint)
+    public void updateTokenMetadata(Token token, EndPoint endpoint, boolean bs)
     {
-        tokenMetadata_.update(token, endpoint);
+        tokenMetadata_.update(token, endpoint, bs);
     }
 
     public IEndPointSnitch getEndPointSnitch()
@@ -593,9 +593,8 @@
      * Starts the bootstrap operations for the specified endpoint.
      * @param endpoint
      */
-    public final void doBootstrap(EndPoint endpoint)
+    public final void doBootstrap(EndPoint endpoint, Token token)
     {
-        Token token = tokenMetadata_.getToken(endpoint);
         bootStrapper_.submit(new BootStrapper(new EndPoint[]{endpoint}, token));
     }
     

Modified: incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/dht/BootStrapperTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/dht/BootStrapperTest.java?rev=832531&r1=832530&r2=832531&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/dht/BootStrapperTest.java
(original)
+++ incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/dht/BootStrapperTest.java
Tue Nov  3 20:03:32 2009
@@ -41,7 +41,7 @@
         /* New token needs to be part of the map for the algorithm
          * to calculate the ranges correctly
          */
-        StorageService.instance().updateTokenMetadata(newToken, newEndPoint);
+        StorageService.instance().updateTokenMetadata(newToken, newEndPoint, true);
 
         BootStrapper b = new BootStrapper(new EndPoint[]{newEndPoint}, newToken );
         Map<Range,List<BootstrapSourceTarget>> res = b.getRangesWithSourceTarget();
@@ -74,7 +74,7 @@
         {
             EndPoint e  = new EndPoint("127.0.0."+i, 100);
             Token t = p.getDefaultToken();
-            StorageService.instance().updateTokenMetadata(t, e);
+            StorageService.instance().updateTokenMetadata(t, e, false);
         }
         return p;
     }



Mime
View raw message