You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by if...@apache.org on 2019/12/18 17:12:11 UTC
[cassandra] branch cassandra-2.2 updated: Pass correct seed node
through to InstanceConfig so it can set it properly when starting clusters
on non-0 subnets.
This is an automated email from the ASF dual-hosted git repository.
ifesdjeen pushed a commit to branch cassandra-2.2
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-2.2 by this push:
new 5635928 Pass correct seed node through to InstanceConfig so it can set it properly when starting clusters on non-0 subnets.
5635928 is described below
commit 563592801aad00e002f0a162d5e2625a4b0e8723
Author: Doug Rohrer <do...@therohrers.org>
AuthorDate: Wed Dec 11 21:33:24 2019 -0500
Pass correct seed node through to InstanceConfig so it can set it properly when starting clusters on non-0 subnets.
Patch by Doug Rohrer, reviewed by Yifan Cai and David Capwell for CASSANDRA-15447.
---
.../distributed/impl/AbstractCluster.java | 3 +-
.../cassandra/distributed/impl/InstanceConfig.java | 6 ++--
.../distributed/test/GossipSettlesTest.java | 42 ++++++++++++++++++++++
3 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/test/distributed/org/apache/cassandra/distributed/impl/AbstractCluster.java b/test/distributed/org/apache/cassandra/distributed/impl/AbstractCluster.java
index cc01ad6..45e9919 100644
--- a/test/distributed/org/apache/cassandra/distributed/impl/AbstractCluster.java
+++ b/test/distributed/org/apache/cassandra/distributed/impl/AbstractCluster.java
@@ -630,6 +630,7 @@ public abstract class AbstractCluster<I extends IInstance> implements ICluster,
long token = Long.MIN_VALUE + 1, increment = 2 * (Long.MAX_VALUE / nodeCount);
String ipPrefix = "127.0." + subnet + ".";
+ String seedIp = ipPrefix + "1";
NetworkTopology networkTopology = NetworkTopology.build(ipPrefix, 7012, nodeIdTopology);
@@ -637,7 +638,7 @@ public abstract class AbstractCluster<I extends IInstance> implements ICluster,
{
int nodeNum = i + 1;
String ipAddress = ipPrefix + nodeNum;
- InstanceConfig config = InstanceConfig.generate(i + 1, ipAddress, networkTopology, root, String.valueOf(token));
+ InstanceConfig config = InstanceConfig.generate(i + 1, ipAddress, networkTopology, root, String.valueOf(token), seedIp);
if (configUpdater != null)
configUpdater.accept(config);
configs.add(config);
diff --git a/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java b/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java
index 97e1a18..c53012b 100644
--- a/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java
+++ b/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java
@@ -81,6 +81,7 @@ public class InstanceConfig implements IInstanceConfig
String listen_address,
String broadcast_rpc_address,
String rpc_address,
+ String seedIp,
String saved_caches_directory,
String[] data_file_directories,
String commitlog_directory,
@@ -114,7 +115,7 @@ public class InstanceConfig implements IInstanceConfig
.set("storage_port", 7012)
.set("endpoint_snitch", DistributedTestSnitch.class.getName())
.set("seed_provider", new ParameterizedClass(SimpleSeedProvider.class.getName(),
- Collections.singletonMap("seeds", "127.0.0.1")))
+ Collections.singletonMap("seeds", seedIp)))
.set("auto_bootstrap", false)
// capacities that are based on `totalMemory` that should be fixed size
.set("index_summary_capacity_in_mb", 50l)
@@ -237,7 +238,7 @@ public class InstanceConfig implements IInstanceConfig
return (String)params.get(name);
}
- public static InstanceConfig generate(int nodeNum, String ipAddress, NetworkTopology networkTopology, File root, String token)
+ public static InstanceConfig generate(int nodeNum, String ipAddress, NetworkTopology networkTopology, File root, String token, String seedIp)
{
return new InstanceConfig(nodeNum,
networkTopology,
@@ -245,6 +246,7 @@ public class InstanceConfig implements IInstanceConfig
ipAddress,
ipAddress,
ipAddress,
+ seedIp,
String.format("%s/node%d/saved_caches", root, nodeNum),
new String[] { String.format("%s/node%d/data", root, nodeNum) },
String.format("%s/node%d/commitlog", root, nodeNum),
diff --git a/test/distributed/org/apache/cassandra/distributed/test/GossipSettlesTest.java b/test/distributed/org/apache/cassandra/distributed/test/GossipSettlesTest.java
new file mode 100644
index 0000000..5f1263a
--- /dev/null
+++ b/test/distributed/org/apache/cassandra/distributed/test/GossipSettlesTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.distributed.test;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+import org.apache.cassandra.distributed.Cluster;
+
+import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
+import static org.apache.cassandra.distributed.api.Feature.NETWORK;
+
+public class GossipSettlesTest extends DistributedTestBase
+{
+
+ @Test
+ public void testGossipSettles() throws IOException
+ {
+ // Use withSubnet(1) to prove seed provider is set correctly - without the fix to pass a seed provider, this test fails
+ try (Cluster cluster = Cluster.build(3).withConfig(config -> config.with(GOSSIP).with(NETWORK)).withSubnet(1).start())
+ {
+ }
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org