cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject git commit: Fix bootstrap, move, remove and other hostid-related tests.
Date Wed, 20 Jun 2012 17:22:42 GMT
Updated Branches:
  refs/heads/trunk b4e47bca8 -> 877a8cacc


Fix bootstrap, move, remove and other hostid-related tests.


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/877a8cac
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/877a8cac
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/877a8cac

Branch: refs/heads/trunk
Commit: 877a8cacc1de7740d4e0e422ecf2b409b7f193f6
Parents: b4e47bc
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Wed Jun 20 12:17:25 2012 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Wed Jun 20 12:18:05 2012 -0500

----------------------------------------------------------------------
 src/java/org/apache/cassandra/gms/Gossiper.java    |    2 ++
 .../apache/cassandra/service/StorageService.java   |    6 ++----
 test/unit/org/apache/cassandra/Util.java           |    2 ++
 .../org/apache/cassandra/dht/BootStrapperTest.java |    2 ++
 .../cassandra/service/LeaveAndBootstrapTest.java   |    2 ++
 .../org/apache/cassandra/service/MoveTest.java     |    4 ++++
 6 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/877a8cac/src/java/org/apache/cassandra/gms/Gossiper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/gms/Gossiper.java b/src/java/org/apache/cassandra/gms/Gossiper.java
index 57c3c49..4208c07 100644
--- a/src/java/org/apache/cassandra/gms/Gossiper.java
+++ b/src/java/org/apache/cassandra/gms/Gossiper.java
@@ -1084,6 +1084,8 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
             localState.markAlive();
             endpointStateMap.put(addr, localState);
         }
+        // always add the version state
+        localState.addApplicationState(ApplicationState.NET_VERSION, StorageService.instance.valueFactory.networkVersion());
     }
 
     public long getEndpointDowntime(String address) throws UnknownHostException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/877a8cac/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index d7dba7d..bc7a7e6 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -1017,11 +1017,8 @@ public class StorageService implements IEndpointStateChangeSubscriber,
StorageSe
     {
         if (MessagingService.instance().knowsVersion(endpoint) && MessagingService.instance().getVersion(endpoint)
>= MessagingService.VERSION_12)
             return true;
-        else if (Gossiper.instance.getEndpointStateForEndpoint(endpoint) != null) // simply
to pass the bootstrap test
-        {
-            if (Gossiper.instance.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.NET_VERSION)
!= null && Integer.valueOf(Gossiper.instance.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.NET_VERSION).value)
>= MessagingService.VERSION_12)
+        else  if (Gossiper.instance.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.NET_VERSION)
!= null && Integer.valueOf(Gossiper.instance.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.NET_VERSION).value)
>= MessagingService.VERSION_12)
                 return true;
-        }
         return false;
     }
 
@@ -1095,6 +1092,7 @@ public class StorageService implements IEndpointStateChangeSubscriber,
StorageSe
         }
         else
             tokensPos = 1;
+        logger.debug("Using token position {} for {}", tokensPos, endpoint);
 
         Token token = getPartitioner().getTokenFactory().fromString(pieces[tokensPos]);
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/877a8cac/test/unit/org/apache/cassandra/Util.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/Util.java b/test/unit/org/apache/cassandra/Util.java
index d53c1b2..7f8c227 100644
--- a/test/unit/org/apache/cassandra/Util.java
+++ b/test/unit/org/apache/cassandra/Util.java
@@ -40,6 +40,7 @@ import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.dht.*;
 import org.apache.cassandra.gms.ApplicationState;
+import org.apache.cassandra.gms.Gossiper;
 import org.apache.cassandra.gms.VersionedValue;
 import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.io.sstable.SSTableReader;
@@ -228,6 +229,7 @@ public class Util
         for (int i=0; i<endpointTokens.size(); i++)
         {
             InetAddress ep = InetAddress.getByName("127.0.0." + String.valueOf(i + 1));
+            Gossiper.instance.initializeNodeUnsafe(ep, 1);
             ss.onChange(ep, ApplicationState.STATUS, new VersionedValue.VersionedValueFactory(partitioner).normal(endpointTokens.get(i),
hostIds.get(i)));
             hosts.add(ep);
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/877a8cac/test/unit/org/apache/cassandra/dht/BootStrapperTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/dht/BootStrapperTest.java b/test/unit/org/apache/cassandra/dht/BootStrapperTest.java
index 6e9236f..3c8cd3b 100644
--- a/test/unit/org/apache/cassandra/dht/BootStrapperTest.java
+++ b/test/unit/org/apache/cassandra/dht/BootStrapperTest.java
@@ -88,6 +88,8 @@ public class BootStrapperTest extends SchemaLoader
         {
             Gossiper.instance.initializeNodeUnsafe(addrs[i], 1);
             load.put(addrs[i], (double)i+2);
+            // also make bootstrapping nodes present in gossip
+            Gossiper.instance.initializeNodeUnsafe(bootstrapAddrs[i], 1);
         }
 
         // give every node a bootstrap source.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/877a8cac/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java b/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java
index be53b53..24df493 100644
--- a/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java
+++ b/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java
@@ -162,9 +162,11 @@ public class LeaveAndBootstrapTest
 
         // boot two new nodes with keyTokens.get(5) and keyTokens.get(7)
         InetAddress boot1 = InetAddress.getByName("127.0.1.1");
+        Gossiper.instance.initializeNodeUnsafe(boot1, 1);
         UUID boot1Id = UUID.randomUUID();
         ss.onChange(boot1, ApplicationState.STATUS, valueFactory.bootstrapping(keyTokens.get(5),
boot1Id));
         InetAddress boot2 = InetAddress.getByName("127.0.1.2");
+        Gossiper.instance.initializeNodeUnsafe(boot2, 1);
         ss.onChange(boot2, ApplicationState.STATUS, valueFactory.bootstrapping(keyTokens.get(7),
UUID.randomUUID()));
 
         Collection<InetAddress> endpoints = null;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/877a8cac/test/unit/org/apache/cassandra/service/MoveTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/service/MoveTest.java b/test/unit/org/apache/cassandra/service/MoveTest.java
index b44fa32..38dc42a 100644
--- a/test/unit/org/apache/cassandra/service/MoveTest.java
+++ b/test/unit/org/apache/cassandra/service/MoveTest.java
@@ -27,6 +27,8 @@ import java.util.*;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
 import static org.junit.Assert.*;
+
+import org.apache.cassandra.gms.Gossiper;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -179,8 +181,10 @@ public class MoveTest
 
         // boot two new nodes with keyTokens.get(5) and keyTokens.get(7)
         InetAddress boot1 = InetAddress.getByName("127.0.1.1");
+        Gossiper.instance.initializeNodeUnsafe(boot1, 1);
         ss.onChange(boot1, ApplicationState.STATUS, valueFactory.bootstrapping(keyTokens.get(5),
UUID.randomUUID()));
         InetAddress boot2 = InetAddress.getByName("127.0.1.2");
+        Gossiper.instance.initializeNodeUnsafe(boot2, 1);
         ss.onChange(boot2, ApplicationState.STATUS, valueFactory.bootstrapping(keyTokens.get(7),
UUID.randomUUID()));
 
         // don't require test update every time a new keyspace is added to test/conf/cassandra.yaml


Mime
View raw message