Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 12103653f -> a586f6c88


Improve config validation and documentation on overflow and NPE

patch by Zhao Yang; reviewed by Kurt Greaves for CASSANDRA-13622


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

Branch: refs/heads/cassandra-3.0
Commit: a586f6c88dab173663b765261d084ed8410efe81
Parents: 1210365
Author: Zhao Yang <zhaoyangsingap...@gmail.com>
Authored: Tue Sep 12 14:31:07 2017 +0100
Committer: Andrés de la Peña <a.penya.gar...@gmail.com>
Committed: Tue Sep 12 15:06:23 2017 +0100

----------------------------------------------------------------------
 CHANGES.txt                                          |  1 +
 conf/cassandra.yaml                                  |  5 +++--
 .../apache/cassandra/config/DatabaseDescriptor.java  | 15 +++++++++++++++
 src/java/org/apache/cassandra/utils/FBUtilities.java |  7 +++++--
 4 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a586f6c8/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 26b1794..6053117 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,6 @@
 3.0.15
  * Fix pending view mutations handling and cleanup batchlog when there are 
local and remote paired mutations (CASSANDRA-13069)
+ * Improve config validation and documentation on overflow and NPE 
(CASSANDRA-13622)
  * Range deletes in a CAS batch are ignored (CASSANDRA-13655)
  * Change repair midpoint logging for tiny ranges (CASSANDRA-13603)
  * Better handle corrupt final commitlog segment (CASSANDRA-11995)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a586f6c8/conf/cassandra.yaml
----------------------------------------------------------------------
diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml
index 22491c6..d77d27a 100644
--- a/conf/cassandra.yaml
+++ b/conf/cassandra.yaml
@@ -315,6 +315,7 @@ commitlog_sync_period_in_ms: 10000
 # is reasonable.
 # Max mutation size is also configurable via max_mutation_size_in_kb setting in
 # cassandra.yaml. The default is half the size commitlog_segment_size_in_mb * 
1024.
+# This should be positive and less than 2048.
 #
 # NOTE: If max_mutation_size_in_kb is set explicitly then 
commitlog_segment_size_in_mb must
 # be set to at least twice the size of max_mutation_size_in_kb / 1024
@@ -517,7 +518,7 @@ native_transport_port: 9042
 #
 # The maximum size of allowed frame. Frame (requests) larger than this will
 # be rejected as invalid. The default is 256MB. If you're changing this 
parameter,
-# you may want to adjust max_value_size_in_mb accordingly.
+# you may want to adjust max_value_size_in_mb accordingly. This should be 
positive and less than 2048.
 # native_transport_max_frame_size_in_mb: 256
 
 # The maximum number of concurrent client connections.
@@ -960,7 +961,7 @@ windows_timer_interval: 1
 
 # Maximum size of any value in SSTables. Safety measure to detect SSTable 
corruption
 # early. Any value size larger than this threshold will result into marking an 
SSTable
-# as corrupted.
+# as corrupted. This should be positive and less than 2048.
 # max_value_size_in_mb: 256
 
 # Coalescing Strategies #

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a586f6c8/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java 
b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index aba7617..029db89 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -442,6 +442,9 @@ public class DatabaseDescriptor
 
         if (conf.native_transport_max_frame_size_in_mb <= 0)
             throw new 
ConfigurationException("native_transport_max_frame_size_in_mb must be positive, 
but was " + conf.native_transport_max_frame_size_in_mb, false);
+        else if (conf.native_transport_max_frame_size_in_mb >= 2048)
+            throw new 
ConfigurationException("native_transport_max_frame_size_in_mb must be smaller 
than 2048, but was "
+                    + conf.native_transport_max_frame_size_in_mb, false);
 
         // fail early instead of OOMing (see CASSANDRA-8116)
         if (ThriftServer.HSHA.equals(conf.rpc_server_type) && 
conf.rpc_max_threads == Integer.MAX_VALUE)
@@ -576,6 +579,8 @@ public class DatabaseDescriptor
         /* data file and commit log directories. they get created later, when 
they're needed. */
         for (String datadir : conf.data_file_directories)
         {
+            if (datadir == null)
+                throw new ConfigurationException("data_file_directories must 
not contain empty entry", false);
             if (datadir.equals(conf.commitlog_directory))
                 throw new ConfigurationException("commitlog_directory must not 
be the same as any data_file_directories", false);
             if (datadir.equals(conf.hints_directory))
@@ -718,6 +723,13 @@ public class DatabaseDescriptor
         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);
 
+        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 (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)
@@ -733,6 +745,9 @@ public class DatabaseDescriptor
 
         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);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a586f6c8/src/java/org/apache/cassandra/utils/FBUtilities.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/FBUtilities.java 
b/src/java/org/apache/cassandra/utils/FBUtilities.java
index ca2775f..5562f5e 100644
--- a/src/java/org/apache/cassandra/utils/FBUtilities.java
+++ b/src/java/org/apache/cassandra/utils/FBUtilities.java
@@ -34,6 +34,8 @@ import javax.annotation.Nullable;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Joiner;
+import com.google.common.base.Strings;
+
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -82,8 +84,9 @@ public class FBUtilities
 
     public static int getAvailableProcessors()
     {
-        if (System.getProperty("cassandra.available_processors") != null)
-            return 
Integer.parseInt(System.getProperty("cassandra.available_processors"));
+        String availableProcessors = 
System.getProperty("cassandra.available_processors");
+        if (!Strings.isNullOrEmpty(availableProcessors))
+            return Integer.parseInt(availableProcessors);
         else
             return Runtime.getRuntime().availableProcessors();
     }


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

Reply via email to