Updated Branches: refs/heads/trunk c0547983d -> 36ef643e4
more pre create-table property validation checks (compression, speculative retry) patch by dbrosius reviewed by jbellis for cassandra 5693 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/36ef643e Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/36ef643e Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/36ef643e Branch: refs/heads/trunk Commit: 36ef643e423e3683fd8cef339cdd95357140af4f Parents: c054798 Author: Dave Brosius <[email protected]> Authored: Mon Jun 24 01:38:00 2013 -0400 Committer: Dave Brosius <[email protected]> Committed: Mon Jun 24 01:38:00 2013 -0400 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../org/apache/cassandra/cql3/CFPropDefs.java | 21 ++++++++++++++++++++ .../io/compress/CompressionParameters.java | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/36ef643e/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 3a242ac..ebcdd4e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -62,6 +62,7 @@ (CASSANDRA-5149) * Streaming 2.0 (CASSANDRA-5286) * Conditional create/drop ks/table/index statements in CQL3 (CASSANDRA-2737) + * more pre-table creation property validation (CASSANDRA-5693) 1.2.7 http://git-wip-us.apache.org/repos/asf/cassandra/blob/36ef643e/src/java/org/apache/cassandra/cql3/CFPropDefs.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/CFPropDefs.java b/src/java/org/apache/cassandra/cql3/CFPropDefs.java index 7bd8fa3..2416df9 100644 --- a/src/java/org/apache/cassandra/cql3/CFPropDefs.java +++ b/src/java/org/apache/cassandra/cql3/CFPropDefs.java @@ -23,6 +23,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.cassandra.config.CFMetaData; +import org.apache.cassandra.config.CFMetaData.SpeculativeRetry; import org.apache.cassandra.db.compaction.AbstractCompactionStrategy; import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.cassandra.exceptions.SyntaxException; @@ -98,9 +99,29 @@ public class CFPropDefs extends PropertyDefinitions CFMetaData.validateCompactionOptions(compactionStrategyClass, compactionOptions); } + + Map<String, String> compressionOptions = getCompressionOptions(); + if (!compressionOptions.isEmpty()) + { + String sstableCompressionClass = compressionOptions.get(CompressionParameters.SSTABLE_COMPRESSION); + if (sstableCompressionClass == null) + throw new ConfigurationException("Missing sub-option '" + CompressionParameters.SSTABLE_COMPRESSION + "' for the '" + KW_COMPRESSION + "' option."); + + String chunkLength = compressionOptions.get(CompressionParameters.CHUNK_LENGTH_KB); + if (chunkLength == null) + throw new ConfigurationException("Missing sub-option '" + CompressionParameters.CHUNK_LENGTH_KB + "' for the '" + KW_COMPRESSION + "' option."); + + Map<String, String> remainingOptions = new HashMap<String, String>(compressionOptions); + remainingOptions.remove(CompressionParameters.SSTABLE_COMPRESSION); + remainingOptions.remove(CompressionParameters.CHUNK_LENGTH_KB); + CompressionParameters cp = new CompressionParameters(sstableCompressionClass, CompressionParameters.parseChunkLength(chunkLength), remainingOptions); + cp.validate(); + } validateMinimumInt(KW_DEFAULT_TIME_TO_LIVE, 0, CFMetaData.DEFAULT_DEFAULT_TIME_TO_LIVE); validateMinimumInt(KW_INDEX_INTERVAL, 1, CFMetaData.DEFAULT_INDEX_INTERVAL); + + SpeculativeRetry.fromString(getString(KW_SPECULATIVE_RETRY, SpeculativeRetry.RetryType.NONE.name())); } public Class<? extends AbstractCompactionStrategy> getCompactionStrategy() http://git-wip-us.apache.org/repos/asf/cassandra/blob/36ef643e/src/java/org/apache/cassandra/io/compress/CompressionParameters.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/io/compress/CompressionParameters.java b/src/java/org/apache/cassandra/io/compress/CompressionParameters.java index 6448d84..0850185 100644 --- a/src/java/org/apache/cassandra/io/compress/CompressionParameters.java +++ b/src/java/org/apache/cassandra/io/compress/CompressionParameters.java @@ -203,7 +203,7 @@ public class CompressionParameters /** * Parse the chunk length (in KB) and returns it as bytes. */ - private static Integer parseChunkLength(String chLengthKB) throws ConfigurationException + public static Integer parseChunkLength(String chLengthKB) throws ConfigurationException { if (chLengthKB == null) return null; @@ -224,7 +224,7 @@ public class CompressionParameters // chunkLength must be a power of 2 because we assume so when // computing the chunk number from an uncompressed file offset (see // CompressedRandomAccessReader.decompresseChunk()) - private void validate() throws ConfigurationException + public void validate() throws ConfigurationException { // if chunk length was not set (chunkLength == null), this is fine, default will be used if (chunkLength != null)
