You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by dc...@apache.org on 2020/10/22 20:26:25 UTC

[cassandra] branch cassandra-3.0 updated (3cba8d8 -> d547f0d)

This is an automated email from the ASF dual-hosted git repository.

dcapwell pushed a change to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git.


    from 3cba8d8  Decomissioned nodes are picked for gossip when unreachable nodes are considered for gossiping
     new db58321  In-JVM dtest - modify schema with stopped nodes and use yaml fragments for config
     new d547f0d  Merge branch 'cassandra-2.2' into cassandra-3.0

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../cassandra/config/ParameterizedClass.java       |  5 ++
 .../cassandra/config/YamlConfigurationLoader.java  | 31 +++++++-
 .../distributed/impl/AbstractCluster.java          | 44 +++++++++--
 .../cassandra/distributed/impl/Instance.java       | 19 +++--
 .../cassandra/distributed/impl/InstanceConfig.java | 49 +++---------
 .../cassandra/distributed/test/JVMDTestTest.java   | 90 +++++++++++++++++++++-
 .../config/YamlConfigurationLoaderTest.java        | 54 +++++++++++++
 7 files changed, 232 insertions(+), 60 deletions(-)
 create mode 100644 test/unit/org/apache/cassandra/config/YamlConfigurationLoaderTest.java


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


[cassandra] 01/01: Merge branch 'cassandra-2.2' into cassandra-3.0

Posted by dc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dcapwell pushed a commit to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit d547f0de740d3e324839c3d8b42673c841ec1fde
Merge: 3cba8d8 db58321
Author: David Capwell <dc...@apache.org>
AuthorDate: Thu Oct 22 13:20:23 2020 -0700

    Merge branch 'cassandra-2.2' into cassandra-3.0

 .../cassandra/config/ParameterizedClass.java       |  5 ++
 .../cassandra/config/YamlConfigurationLoader.java  | 31 +++++++-
 .../distributed/impl/AbstractCluster.java          | 44 +++++++++--
 .../cassandra/distributed/impl/Instance.java       | 19 +++--
 .../cassandra/distributed/impl/InstanceConfig.java | 49 +++---------
 .../cassandra/distributed/test/JVMDTestTest.java   | 90 +++++++++++++++++++++-
 .../config/YamlConfigurationLoaderTest.java        | 54 +++++++++++++
 7 files changed, 232 insertions(+), 60 deletions(-)

diff --cc src/java/org/apache/cassandra/config/YamlConfigurationLoader.java
index 435377c,07b149c..bd602df
--- a/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java
+++ b/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java
@@@ -125,11 -127,30 +128,35 @@@ public class YamlConfigurationLoader im
          }
      }
  
-     static class CustomConstructor extends Constructor
+     @SuppressWarnings("unchecked") //getSingleData returns Object, not T
+     public static <T> T fromMap(Map<String,Object> map, Class<T> klass)
+     {
+         Constructor constructor = new YamlConfigurationLoader.CustomConstructor(klass, klass.getClassLoader());
+         YamlConfigurationLoader.MissingPropertiesChecker propertiesChecker = new YamlConfigurationLoader.MissingPropertiesChecker();
+         constructor.setPropertyUtils(propertiesChecker);
+         Yaml yaml = new Yaml(constructor);
+         Node node = yaml.represent(map);
+         constructor.setComposer(new Composer(null, null)
+         {
+             @Override
+             public Node getSingleNode()
+             {
+                 return node;
+             }
+         });
+         return (T) constructor.getSingleData(klass);
+     }
+ 
+     static class CustomConstructor extends CustomClassLoaderConstructor
      {
 +        CustomConstructor(Class<?> theRoot)
 +        {
-             super(theRoot);
++            this(theRoot, Yaml.class.getClassLoader());
++        }
++
+         CustomConstructor(Class<?> theRoot, ClassLoader classLoader)
+         {
+             super(theRoot, classLoader);
  
              TypeDescription seedDesc = new TypeDescription(ParameterizedClass.class);
              seedDesc.putMapPropertyType("parameters", String.class, String.class);
diff --cc test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java
index ea8d0f8,861e2ea..60b54fb
--- a/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java
+++ b/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java
@@@ -33,6 -33,7 +33,7 @@@ import java.util.function.Function
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
++import org.apache.cassandra.config.YamlConfigurationLoader;
  import org.apache.cassandra.distributed.api.Feature;
  import org.apache.cassandra.distributed.api.IInstanceConfig;
  import org.apache.cassandra.distributed.shared.NetworkTopology;
diff --cc test/distributed/org/apache/cassandra/distributed/test/JVMDTestTest.java
index 3a1a0a8,7e5d99a..13b314a
--- a/test/distributed/org/apache/cassandra/distributed/test/JVMDTestTest.java
+++ b/test/distributed/org/apache/cassandra/distributed/test/JVMDTestTest.java
@@@ -19,8 -19,12 +19,11 @@@
  package org.apache.cassandra.distributed.test;
  
  import java.io.IOException;
+ import java.util.Collections;
  import java.util.List;
+ import java.util.Map;
+ import java.util.concurrent.TimeUnit;
  import java.util.concurrent.TimeoutException;
 -import java.util.concurrent.TimeUnit;
  import java.util.logging.Logger;
  
  import org.junit.Assert;
@@@ -75,7 -86,83 +85,83 @@@ public class JVMDTestTest extends TestB
                  LoggerFactory.getLogger(CassandraDaemon.class).error("Error", new RuntimeException("fail without fail"));
              });
              List<String> errors = logs.watchFor(mark, "^ERROR").getResult();
-             Assert.assertFalse(errors.isEmpty());
+             assertFalse(errors.isEmpty());
+         }
+     }
+ 
+     @Test
+     public void nonSharedConfigClassTest() throws IOException
+     {
+         Map<String,Object> commitLogCompression = ImmutableMap.of("class_name", "org.apache.cassandra.io.compress.LZ4Compressor",
+                                                                   "parameters", Collections.<String,Object>emptyMap());
+         Map<String,Object> encryptionOptions = ImmutableMap.of("cipher_suites", Collections.singletonList("FakeCipher"),
+                                                                "optional", false,
+                                                                "enabled", false);
+ 
+         try (Cluster cluster = Cluster.build(1)
+                                       .withConfig(c -> {
+                                           c.set("concurrent_reads", 321);
+                                           c.set("internode_compression", Config.InternodeCompression.dc);
+                                           c.set("client_encryption_options", encryptionOptions);
+                                           c.set("commitlog_compression", commitLogCompression);
+                                       }).start())
+         {
+             cluster.get(1).runOnInstance(() -> {
+                 assertEquals(321, DatabaseDescriptor.getConcurrentReaders());
+                 assertEquals(Config.InternodeCompression.dc, DatabaseDescriptor.internodeCompression());
+                 assertEquals("org.apache.cassandra.io.compress.LZ4Compressor", DatabaseDescriptor.getCommitLogCompression().class_name);
+                 assertTrue(DatabaseDescriptor.getCommitLogCompression().parameters.isEmpty());
+             });
+         }
+     }
+ 
+     @Test
+     public void modifySchemaWithStoppedNode() throws Throwable
+     {
+         try (Cluster cluster = init(Cluster.build().withNodes(2).withConfig(c -> c.with(Feature.GOSSIP).with(Feature.NETWORK)).start()))
+         {
+             assertFalse(cluster.get(1).isShutdown());
+             assertFalse(cluster.get(2).isShutdown());
+             cluster.schemaChangeIgnoringStoppedInstances("CREATE TABLE "+KEYSPACE+".tbl1 (id int primary key, i int)");
+ 
+             cluster.get(2).shutdown(true).get(1, TimeUnit.MINUTES);
+             assertFalse(cluster.get(1).isShutdown());
+             assertTrue(cluster.get(2).isShutdown());
+             cluster.schemaChangeIgnoringStoppedInstances("CREATE TABLE "+KEYSPACE+".tbl2 (id int primary key, i int)");
+ 
+             cluster.get(1).shutdown(true).get(1, TimeUnit.MINUTES);
+             assertTrue(cluster.get(1).isShutdown());
+             assertTrue(cluster.get(2).isShutdown());
+ 
+             // both nodes down, nothing to record a schema change so should get an exception
+             Throwable thrown = null;
+             try
+             {
+                 cluster.schemaChangeIgnoringStoppedInstances("CREATE TABLE " + KEYSPACE + ".tblX (id int primary key, i int)");
+             }
+             catch (Throwable tr)
+             {
+                 thrown = tr;
+             }
+             assertNotNull("Expected to fail with all nodes down", thrown);
+ 
+             // Have to restart instance1 before instance2 as it is hard-coded as the seed in in-JVM configuration.
+             cluster.get(1).startup();
+             cluster.get(2).startup();
+             assertFalse(cluster.get(1).isShutdown());
+             assertFalse(cluster.get(2).isShutdown());
+             cluster.schemaChangeIgnoringStoppedInstances("CREATE TABLE "+KEYSPACE+".tbl3 (id int primary key, i int)");
+ 
 -            assertRows(cluster.get(1).executeInternal("SELECT columnfamily_name FROM system.schema_columnfamilies WHERE keyspace_name = ?", KEYSPACE),
++            assertRows(cluster.get(1).executeInternal("SELECT table_name FROM system_schema.tables WHERE keyspace_name = ?", KEYSPACE),
+                        row("tbl1"), row("tbl2"), row("tbl3"));
 -            assertRows(cluster.get(2).executeInternal("SELECT columnfamily_name FROM system.schema_columnfamilies WHERE keyspace_name = ?", KEYSPACE),
++            assertRows(cluster.get(2).executeInternal("SELECT table_name FROM system_schema.tables WHERE keyspace_name = ?", KEYSPACE),
+                        row("tbl1"), row("tbl2"), row("tbl3"));
+ 
+             // Finally test schema can be changed with the first node down
 -            cluster.get(1).shutdown(true).get(2, TimeUnit.MINUTES);
++            cluster.get(1).shutdown(true).get(1, TimeUnit.MINUTES);
+             cluster.schemaChangeIgnoringStoppedInstances("CREATE TABLE "+KEYSPACE+".tbl4 (id int primary key, i int)");
 -            assertRows(cluster.get(2).executeInternal("SELECT columnfamily_name FROM system.schema_columnfamilies WHERE keyspace_name = ?", KEYSPACE),
++            assertRows(cluster.get(2).executeInternal("SELECT table_name FROM system_schema.tables WHERE keyspace_name = ?", KEYSPACE),
+                        row("tbl1"), row("tbl2"), row("tbl3"), row("tbl4"));
          }
      }
  }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org