cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r832269 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra: dht/BootStrapper.java net/Header.java net/MessageDeliveryTask.java service/StorageService.java
Date Tue, 03 Nov 2009 02:24:19 GMT
Author: jbellis
Date: Tue Nov  3 02:24:19 2009
New Revision: 832269

URL: http://svn.apache.org/viewvc?rev=832269&view=rev
Log:
add logging, assert
patch by jbellis

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/dht/BootStrapper.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/net/Header.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/net/MessageDeliveryTask.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/dht/BootStrapper.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/dht/BootStrapper.java?rev=832269&r1=832268&r2=832269&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/dht/BootStrapper.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/dht/BootStrapper.java Tue Nov
 3 02:24:19 2009
@@ -28,6 +28,7 @@
  import org.apache.log4j.Logger;
 
  import org.apache.commons.lang.ArrayUtils;
+ import org.apache.commons.lang.StringUtils;
 
  import org.apache.cassandra.locator.TokenMetadata;
  import org.apache.cassandra.locator.AbstractReplicationStrategy;
@@ -94,15 +95,15 @@
             {
                 Multimap<Range, InetAddress> rangesWithSourceTarget = getRangesWithSources();
                 if (logger.isDebugEnabled())
-                        logger.debug("Beginning bootstrap process for " + address + " ...");
+                    logger.debug("Beginning bootstrap process");
                 /* Send messages to respective folks to stream data over to me */
                 for (Map.Entry<InetAddress, Collection<Range>> entry : getWorkMap(rangesWithSourceTarget).asMap().entrySet())
                 {
                     InetAddress source = entry.getKey();
+                    if (logger.isDebugEnabled())
+                        logger.debug("Sending BootstrapMetadataMessage to " + source + "
for " + StringUtils.join(entry.getValue(), ", "));
                     BootstrapMetadata bsMetadata = new BootstrapMetadata(address, entry.getValue());
                     Message message = BootstrapMetadataMessage.makeBootstrapMetadataMessage(new
BootstrapMetadataMessage(bsMetadata));
-                    if (logger.isDebugEnabled())
-                        logger.debug("Sending the BootstrapMetadataMessage to " + source);
                     MessagingService.instance().sendOneWay(message, source);
                     StorageService.instance().addBootstrapSource(source);
                 }
@@ -116,6 +117,7 @@
         StorageLoadBalancer slb = StorageLoadBalancer.instance();
 
         slb.waitForLoadInfo();
+        logger.debug("... got load info");
 
         // if initialtoken was specified, use that.  otherwise, pick a token to assume half
the load of the most-loaded node.
         if (DatabaseDescriptor.getInitialToken() == null)
@@ -124,6 +126,7 @@
             InetAddress maxEndpoint = null;
             for (Map.Entry<InetAddress, Double> entry : slb.getLoadInfo().entrySet())
             {
+                logger.debug("considering " + entry.getKey() + " with load of " + entry.getValue());
                 if (!metadata.isMember(entry.getKey()))
                     continue;
                 if (maxEndpoint == null || entry.getValue() > maxLoad)
@@ -137,12 +140,11 @@
                 throw new RuntimeException("No bootstrap sources found");
             }
 
-            if (!maxEndpoint.equals(FBUtilities.getLocalAddress()))
-            {
-                Token<?> t = getBootstrapTokenFrom(maxEndpoint);
-                logger.info("New token will be " + t + " to assume load from " + maxEndpoint);
-                ss.setToken(t);
-            }
+            assert !maxEndpoint.equals(FBUtilities.getLocalAddress());
+            logger.debug("asking " + maxEndpoint + " for token");
+            Token<?> t = getBootstrapTokenFrom(maxEndpoint);
+            logger.info("New token will be " + t + " to assume load from " + maxEndpoint);
+            ss.setToken(t);
         }
     }
 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/net/Header.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/net/Header.java?rev=832269&r1=832268&r2=832269&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/net/Header.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/net/Header.java Tue Nov  3 02:24:19
2009
@@ -52,6 +52,11 @@
     
     Header(String id, InetAddress from, String messageType, String verb)
     {
+        assert id != null;
+        assert from != null;
+        assert messageType != null;
+        assert verb != null;
+
         messageId_ = id;
         from_ = from;
         type_ = messageType;
@@ -66,10 +71,7 @@
 
     Header(InetAddress from, String messageType, String verb)
     {
-        messageId_ = Integer.toString(idGen_.incrementAndGet());
-        from_ = from;
-        type_ = messageType;
-        verb_ = verb;
+        this(Integer.toString(idGen_.incrementAndGet()), from, messageType, verb);
     }        
 
     InetAddress getFrom()

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/net/MessageDeliveryTask.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/net/MessageDeliveryTask.java?rev=832269&r1=832268&r2=832269&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/net/MessageDeliveryTask.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/net/MessageDeliveryTask.java Tue
Nov  3 02:24:19 2009
@@ -34,9 +34,7 @@
     { 
         String verb = message_.getVerb();
         IVerbHandler verbHandler = MessagingService.instance().getVerbHandler(verb);
-        if ( verbHandler != null )
-        {
-            verbHandler.doVerb(message_);
-        }
+        assert verbHandler != null : "unknown verb " + verb;
+        verbHandler.doVerb(message_);
     }
 }

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=832269&r1=832268&r2=832269&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 Tue
Nov  3 02:24:19 2009
@@ -368,7 +368,20 @@
             tokenMetadata_.setBootstrapping(endpoint,  bootstrapState);
         }
 
-        if (nodeIdState != null)
+        if (nodeIdState == null)
+        {
+            /*
+             * If we are here and if this node is UP and already has an entry
+             * in the token map. It means that the node was behind a network partition.
+            */
+            if (epState.isAlive() && tokenMetadata_.isMember(endpoint))
+            {
+                if (logger_.isDebugEnabled())
+                    logger_.debug("InetAddress " + endpoint + " just recovered from a partition.
Sending hinted data.");
+                deliverHints(endpoint);
+            }
+        }
+        else
         {
             Token newToken = getPartitioner().getTokenFactory().fromString(nodeIdState.getState());
             if (logger_.isDebugEnabled())
@@ -409,19 +422,6 @@
                 updateForeignToken(newToken, endpoint);
             }
         }
-        else
-        {
-            /*
-             * If we are here and if this node is UP and already has an entry
-             * in the token map. It means that the node was behind a network partition.
-            */
-            if (epState.isAlive() && tokenMetadata_.isMember(endpoint))
-            {
-                if (logger_.isDebugEnabled())
-                    logger_.debug("InetAddress " + endpoint + " just recovered from a partition.
Sending hinted data.");
-                deliverHints(endpoint);
-            }
-        }
     }
 
     /** raw load value */



Mime
View raw message