This is an automated email from the ASF dual-hosted git repository. mck pushed a commit to branch cassandra-3.11 in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit e8c1af26c5d07c12109d51c2d89bc3967141dc55 Merge: d9e1af8 bfd5d20 Author: Mick Semb Wever <m...@apache.org> AuthorDate: Wed Nov 18 12:57:14 2020 +0100 Merge branch 'cassandra-3.0' into cassandra-3.11 NEWS.txt | 2 +- .../cassandra/config/DatabaseDescriptor.java | 5 ++++- .../cassandra/config/DatabaseDescriptorTest.java | 25 ++++++++++++++++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --cc NEWS.txt index d16bcce,7034c2c..99d589d --- a/NEWS.txt +++ b/NEWS.txt @@@ -42,11 -42,12 +42,11 @@@ restore snapshots created with the prev 'sstableloader' tool. You can upgrade the file format of your snapshots using the provided 'sstableupgrade' tool. -3.0.24 -====== - +3.11.10 +===== Upgrading --------- - - In cassandra.yaml, num_tokens must be defined if initial_token is defined. + - In cassandra.yaml, when using vnodes num_tokens must be defined if initial_token is defined. If it is not defined, or not equal to the numbers of tokens defined in initial_tokens, the node will not start. See CASSANDRA-14477 for details. diff --cc src/java/org/apache/cassandra/config/DatabaseDescriptor.java index cbf42b9,3f9aa96..c88a0e7 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@@ -940,126 -756,60 +940,129 @@@ public class DatabaseDescripto } if (seedProvider.getSeeds().size() == 0) throw new ConfigurationException("The seed provider lists no seeds.", false); + } - if (conf.user_defined_function_fail_timeout < 0) - throw new ConfigurationException("user_defined_function_fail_timeout must not be negative", false); - if (conf.user_defined_function_warn_timeout < 0) - throw new ConfigurationException("user_defined_function_warn_timeout must not be negative", false); + public static void applyTokensConfig() + { + applyTokensConfig(conf); + } - if (conf.user_defined_function_fail_timeout < conf.user_defined_function_warn_timeout) - throw new ConfigurationException("user_defined_function_warn_timeout must less than user_defined_function_fail_timeout", false); + static void applyTokensConfig(Config conf) + { + if (conf.initial_token != null) + { + Collection<String> tokens = tokensFromString(conf.initial_token); + if (conf.num_tokens == null) + { - throw new ConfigurationException("initial_token was set but num_tokens is not!", false); ++ if (tokens.size() == 1) ++ conf.num_tokens = 1; ++ else ++ throw new ConfigurationException("initial_token was set but num_tokens is not!", false); + } - if (conf.commitlog_segment_size_in_mb <= 0) - throw new ConfigurationException("commitlog_segment_size_in_mb must be positive, but was " - + conf.commitlog_segment_size_in_mb, false); - else if (conf.commitlog_segment_size_in_mb >= 2048) - throw new ConfigurationException("commitlog_segment_size_in_mb must be smaller than 2048, but was " - + conf.commitlog_segment_size_in_mb, false); + if (tokens.size() != conf.num_tokens) + { + throw new ConfigurationException(String.format("The number of initial tokens (by initial_token) specified (%s) is different from num_tokens value (%s)", + tokens.size(), + conf.num_tokens), + false); + } + + for (String token : tokens) + partitioner.getTokenFactory().validate(token); + } + else if (conf.num_tokens == null) + { + conf.num_tokens = 1; + } + } + + // Maybe safe for clients + tools + public static void applyRequestScheduler() + { + /* Request Scheduler setup */ + requestSchedulerOptions = conf.request_scheduler_options; + if (conf.request_scheduler != null) + { + try + { + if (requestSchedulerOptions == null) + { + requestSchedulerOptions = new RequestSchedulerOptions(); + } + Class<?> cls = Class.forName(conf.request_scheduler); + requestScheduler = (IRequestScheduler) cls.getConstructor(RequestSchedulerOptions.class).newInstance(requestSchedulerOptions); + } + catch (ClassNotFoundException e) + { + throw new ConfigurationException("Invalid Request Scheduler class " + conf.request_scheduler, false); + } + catch (Exception e) + { + throw new ConfigurationException("Unable to instantiate request scheduler", e); + } + } + else + { + requestScheduler = new NoScheduler(); + } - if (conf.max_mutation_size_in_kb == null) - conf.max_mutation_size_in_kb = conf.commitlog_segment_size_in_mb * 1024 / 2; - else if (conf.commitlog_segment_size_in_mb * 1024 < 2 * conf.max_mutation_size_in_kb) - throw new ConfigurationException("commitlog_segment_size_in_mb must be at least twice the size of max_mutation_size_in_kb / 1024", false); + if (conf.request_scheduler_id == RequestSchedulerId.keyspace) + { + requestSchedulerId = conf.request_scheduler_id; + } + else + { + // Default to Keyspace + requestSchedulerId = RequestSchedulerId.keyspace; + } + } - // native transport encryption options - if (conf.native_transport_port_ssl != null - && conf.native_transport_port_ssl.intValue() != conf.native_transport_port.intValue() - && !conf.client_encryption_options.enabled) + // definitely not safe for tools + clients - implicitly instantiates StorageService + public static void applySnitch() + { + /* end point snitch */ + if (conf.endpoint_snitch == null) { - throw new ConfigurationException("Encryption must be enabled in client_encryption_options for native_transport_port_ssl", false); + throw new ConfigurationException("Missing endpoint_snitch directive", false); } + snitch = createEndpointSnitch(conf.dynamic_snitch, conf.endpoint_snitch); + EndpointSnitchInfo.create(); - // If max protocol version has been set, just validate it's within an acceptable range - if (conf.native_transport_max_negotiable_protocol_version != Integer.MIN_VALUE) + localDC = snitch.getDatacenter(FBUtilities.getBroadcastAddress()); + localComparator = new Comparator<InetAddress>() { - if (conf.native_transport_max_negotiable_protocol_version < Server.MIN_SUPPORTED_VERSION - || conf.native_transport_max_negotiable_protocol_version > Server.CURRENT_VERSION) + public int compare(InetAddress endpoint1, InetAddress endpoint2) { - throw new ConfigurationException(String.format("Invalid setting for native_transport_max_negotiable_version (%d); " + - "Values between %s and %s are supported", - conf.native_transport_max_negotiable_protocol_version, - Server.MIN_SUPPORTED_VERSION, - Server.CURRENT_VERSION)); + boolean local1 = localDC.equals(snitch.getDatacenter(endpoint1)); + boolean local2 = localDC.equals(snitch.getDatacenter(endpoint2)); + if (local1 && !local2) + return -1; + if (local2 && !local1) + return 1; + return 0; } - } - - if (conf.max_value_size_in_mb == null || conf.max_value_size_in_mb <= 0) - throw new ConfigurationException("max_value_size_in_mb must be positive", false); - else if (conf.max_value_size_in_mb >= 2048) - throw new ConfigurationException("max_value_size_in_mb must be smaller than 2048, but was " - + conf.max_value_size_in_mb, false); + }; + } - if (conf.otc_coalescing_enough_coalesced_messages > 128) - throw new ConfigurationException("otc_coalescing_enough_coalesced_messages must be smaller than 128", false); + // definitely not safe for tools + clients - implicitly instantiates schema + public static void applyPartitioner() + { + /* Hashing strategy */ + if (conf.partitioner == null) + { + throw new ConfigurationException("Missing directive: partitioner", false); + } + try + { + partitioner = FBUtilities.newPartitioner(System.getProperty(Config.PROPERTY_PREFIX + "partitioner", conf.partitioner)); + } + catch (Exception e) + { + throw new ConfigurationException("Invalid partitioner class " + conf.partitioner, false); + } - if (conf.otc_coalescing_enough_coalesced_messages <= 0) - throw new ConfigurationException("otc_coalescing_enough_coalesced_messages must be positive", false); + paritionerName = partitioner.getClass().getCanonicalName(); } /** diff --cc test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java index 4c6b3d7,0dcc7f7..912d838 --- a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java +++ b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java @@@ -323,7 -315,7 +323,7 @@@ public class DatabaseDescriptorTes } @Test - public void testApplyInitialTokensInitialTokensSetNumTokensSetAndDoesMatch() - public void testApplyTokensConfigInitialTokensSetNumTokensSetAndDoesMatch() throws Exception ++ public void testApplyTokensConfigInitialTokensSetNumTokensSetAndDoesMatch() { Config config = DatabaseDescriptor.loadConfig(); config.initial_token = "0,256,1024"; @@@ -342,7 -337,7 +342,7 @@@ } @Test - public void testApplyInitialTokensInitialTokensSetNumTokensSetAndDoesntMatch() - public void testApplyTokensConfigInitialTokensSetNumTokensSetAndDoesntMatch() throws Exception ++ public void testApplyTokensConfigInitialTokensSetNumTokensSetAndDoesntMatch() { Config config = DatabaseDescriptor.loadConfig(); config.initial_token = "0,256,1024"; @@@ -362,10 -359,15 +362,10 @@@ } @Test - public void testApplyInitialTokensInitialTokensSetNumTokensNotSet() - public void testApplyTokensConfigInitialTokensSetNumTokensNotSet() throws Exception ++ public void testApplyTokensConfigInitialTokensSetNumTokensNotSet() { Config config = DatabaseDescriptor.loadConfig(); - - unregisterSnitchesForTokenConfigTest(); + config.initial_token = "0,256,1024"; try { @@@ -379,7 -383,11 +379,7 @@@ } @Test - public void testApplyInitialTokensInitialTokensNotSetNumTokensSet() - public void testApplyTokensConfigInitialTokensNotSetNumTokensSet() throws Exception ++ public void testApplyTokensConfigInitialTokensNotSetNumTokensSet() { Config config = DatabaseDescriptor.loadConfig(); config.num_tokens = 3; @@@ -391,12 -408,58 +391,25 @@@ } @Test - public void testApplyInitialTokensInitialTokensNotSetNumTokensNotSet() - public void testApplyTokensConfigInitialTokensNotSetNumTokensNotSet() throws Exception ++ public void testApplyTokensConfigInitialTokensNotSetNumTokensNotSet() { Config config = DatabaseDescriptor.loadConfig(); - - unregisterSnitchesForTokenConfigTest(); - - try - { - DatabaseDescriptor.applyTokensConfig(config); - } - finally - { - unregisterSnitchesForTokenConfigTest(); - } + DatabaseDescriptor.applyTokensConfig(config); Assert.assertEquals(Integer.valueOf(1), config.num_tokens); Assert.assertTrue(DatabaseDescriptor.tokensFromString(config.initial_token).isEmpty()); } + + @Test - public void testApplyTokensConfigInitialTokensOneNumTokensNotSet() throws Exception ++ public void testApplyTokensConfigInitialTokensOneNumTokensNotSet() + { + Config config = DatabaseDescriptor.loadConfig(); + config.initial_token = "123"; + config.num_tokens = null; + - unregisterSnitchesForTokenConfigTest(); - - try - { - DatabaseDescriptor.applyTokensConfig(config); - } - finally - { - unregisterSnitchesForTokenConfigTest(); - } ++ DatabaseDescriptor.applyTokensConfig(config); + + Assert.assertEquals(Integer.valueOf(1), config.num_tokens); + Assert.assertEquals(1, DatabaseDescriptor.tokensFromString(config.initial_token).size()); + } - - private void unregisterSnitchesForTokenConfigTest() throws Exception - { - try - { - MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); - mbs.unregisterMBean(new ObjectName("org.apache.cassandra.db:type=DynamicEndpointSnitch")); - mbs.unregisterMBean(new ObjectName("org.apache.cassandra.db:type=EndpointSnitchInfo")); - } - catch (InstanceNotFoundException ex) - { - // ok - } - } -} +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org