cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r835213 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra: io/SSTable.java io/Streaming.java service/StorageService.java
Date Thu, 12 Nov 2009 03:37:18 GMT
Author: jbellis
Date: Thu Nov 12 03:37:15 2009
New Revision: 835213

URL: http://svn.apache.org/viewvc?rev=835213&view=rev
Log:
avoid making local node part of the token ring until bootstrap completes; fix other buglets
patch by jbellis; reviewed by Jaakko Laine for CASSANDRA-536

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/Streaming.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java?rev=835213&r1=835212&r2=835213&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java Thu Nov 12 03:37:15
2009
@@ -132,7 +132,8 @@
     /** @return full paths to all the files associated w/ this SSTable */
     public List<String> getAllFilenames()
     {
-        return Arrays.asList(getFilename(), indexFilename(), filterFilename());
+        // TODO streaming relies on the -Data (getFilename) file to be last, this is clunky
+        return Arrays.asList(indexFilename(), filterFilename(), getFilename());
     }
 
     public String getColumnFamilyName()

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/Streaming.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/Streaming.java?rev=835213&r1=835212&r2=835213&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/Streaming.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/Streaming.java Thu Nov 12 03:37:15
2009
@@ -83,9 +83,9 @@
         {
             File file = new File(filename);
             streamContexts[i++] = new StreamContextManager.StreamContext(file.getAbsolutePath(),
file.length(), table);
-            if (logger.isDebugEnabled())
-              logger.debug("Stream context metadata " + streamContexts[i]);
         }
+        if (logger.isDebugEnabled())
+          logger.debug("Stream context metadata " + StringUtils.join(streamContexts, ", "));
 
         StreamManager.instance(target).addFilesToStream(streamContexts);
         StreamInitiateMessage biMessage = new StreamInitiateMessage(streamContexts);

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=835213&r1=835212&r2=835213&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Thu
Nov 12 03:37:15 2009
@@ -169,13 +169,19 @@
 
         if (bootstrapSet.isEmpty())
         {
-            isBootstrapMode = false;
-            SystemTable.setBootstrapped();
-            Gossiper.instance().addApplicationState(StorageService.STATE_NORMAL, new ApplicationState(partitioner_.getTokenFactory().toString(getLocalToken())));
-            logger_.info("Bootstrap completed! Now serving reads.");
+            finishBootstrapping();
         }
     }
 
+    private void finishBootstrapping()
+    {
+        isBootstrapMode = false;
+        SystemTable.setBootstrapped();
+        setToken(getLocalToken());
+        Gossiper.instance().addApplicationState(StorageService.STATE_NORMAL, new ApplicationState(partitioner_.getTokenFactory().toString(getLocalToken())));
+        logger_.info("Bootstrap completed! Now serving reads.");
+    }
+
     private void updateForeignToken(Token token, InetAddress endpoint)
     {
         tokenMetadata_.update(token, endpoint);
@@ -276,9 +282,22 @@
             logger_.info("Starting in bootstrap mode (first, sleeping to get load information)");
             StorageLoadBalancer.instance().waitForLoadInfo();
             logger_.info("... got load info");
-            setToken(BootStrapper.getBootstrapToken(tokenMetadata_, StorageLoadBalancer.instance().getLoadInfo()));
+            Token token = BootStrapper.getBootstrapToken(tokenMetadata_, StorageLoadBalancer.instance().getLoadInfo());
+            SystemTable.updateToken(token); // DON'T use setToken, that makes us part of
the ring locally which is incorrect until we are done bootstrapping
             Gossiper.instance().addApplicationState(StorageService.STATE_BOOTSTRAPPING, new
ApplicationState(partitioner_.getTokenFactory().toString(getLocalToken())));
             new BootStrapper(replicationStrategy_, FBUtilities.getLocalAddress(), getLocalToken(),
tokenMetadata_).startBootstrap(); // handles token update
+            // don't finish startup (enabling thrift) until after bootstrap is done
+            while (isBootstrapMode)
+            {
+                try
+                {
+                    Thread.sleep(100);
+                }
+                catch (InterruptedException e)
+                {
+                    throw new AssertionError(e);
+                }
+            }
         }
         else
         {
@@ -517,7 +536,7 @@
 
     public Token getLocalToken()
     {
-        return tokenMetadata_.getToken(FBUtilities.getLocalAddress());
+        return storageMetadata_.getToken();
     }
 
     /* This methods belong to the MBean interface */



Mime
View raw message