Make it clear what timestamp_resolution is used for

Patch by marcuse; reviewed by Jeff Jirsa for CASSANDRA-11041


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

Branch: refs/heads/trunk
Commit: b8408f068bf2fc73f632d09239ba892a9835416f
Parents: 6fe70c6
Author: Marcus Eriksson <marc...@apache.org>
Authored: Wed Jan 20 08:58:05 2016 +0100
Committer: Marcus Eriksson <marc...@apache.org>
Committed: Tue Feb 9 07:08:22 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                                                    | 1 +
 doc/cql3/CQL.textile                                           | 2 +-
 pylib/cqlshlib/cql3handling.py                                 | 1 -
 .../db/compaction/DateTieredCompactionStrategyOptions.java     | 6 ++++++
 4 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b8408f06/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 806e6d5..e5d6ff1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.14
+ * Make it clear what DTCS timestamp_resolution is used for (CASSANDRA-11041)
  * Gossiper#isEnabled is not thread safe (CASSANDRA-11116)
 
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b8408f06/doc/cql3/CQL.textile
----------------------------------------------------------------------
diff --git a/doc/cql3/CQL.textile b/doc/cql3/CQL.textile
index 3b69fcc..812a75e 100644
--- a/doc/cql3/CQL.textile
+++ b/doc/cql3/CQL.textile
@@ -347,7 +347,7 @@ The @compaction@ property must at least define the 
@'class'@ sub-option, that de
 | @bucket_low@                     | SizeTieredCompactionStrategy    | 0.5     
     | Size tiered consider sstables to be within the same bucket if their size 
is within [average_size * @bucket_low@, average_size * @bucket_high@ ] (i.e the 
default groups sstable whose sizes diverges by at most 50%)|
 | @bucket_high@                    | SizeTieredCompactionStrategy    | 1.5     
     | Size tiered consider sstables to be within the same bucket if their size 
is within [average_size * @bucket_low@, average_size * @bucket_high@ ] (i.e the 
default groups sstable whose sizes diverges by at most 50%).|
 | @sstable_size_in_mb@             | LeveledCompactionStrategy       | 5MB     
     | The target size (in MB) for sstables in the leveled strategy. Note that 
while sstable sizes should stay less or equal to @sstable_size_in_mb@, it is 
possible to exceptionally have a larger sstable as during compaction, data for 
a given partition key are never split into 2 sstables|
-| @timestamp_resolution@           | DateTieredCompactionStrategy    | 
MICROSECONDS | The timestamp resolution used when inserting data, could be 
MILLISECONDS, MICROSECONDS etc (should be understandable by Java TimeUnit)|
+| @timestamp_resolution@           | DateTieredCompactionStrategy    | 
MICROSECONDS | The timestamp resolution used when inserting data, could be 
MILLISECONDS, MICROSECONDS etc (should be understandable by Java TimeUnit) - 
don't change this unless you do mutations with USING TIMESTAMP 
<non_microsecond_timestamps> (or equivalent directly in the client)|
 | @base_time_seconds@              | DateTieredCompactionStrategy    | 60      
     | The base size of the time windows. |
 | @max_sstable_age_days@           | DateTieredCompactionStrategy    | 365     
     | SSTables only containing data that is older than this will never be 
compacted. |
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b8408f06/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py
index 38f118f..029e0c7 100644
--- a/pylib/cqlshlib/cql3handling.py
+++ b/pylib/cqlshlib/cql3handling.py
@@ -470,7 +470,6 @@ def cf_prop_val_mapkey_completer(ctxt, cass):
         elif csc == 'DateTieredCompactionStrategy':
             opts.add('base_time_seconds')
             opts.add('max_sstable_age_days')
-            opts.add('timestamp_resolution')
             opts.add('min_threshold')
             opts.add('max_window_size_seconds')
         return map(escape_value, opts)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b8408f06/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategyOptions.java
----------------------------------------------------------------------
diff --git 
a/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategyOptions.java
 
b/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategyOptions.java
index 5803115..78a0cab 100644
--- 
a/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategyOptions.java
+++ 
b/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategyOptions.java
@@ -20,10 +20,14 @@ package org.apache.cassandra.db.compaction;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.cassandra.exceptions.ConfigurationException;
 
 public final class DateTieredCompactionStrategyOptions
 {
+    private static final Logger logger = 
LoggerFactory.getLogger(DateTieredCompactionStrategy.class);
     protected static final TimeUnit DEFAULT_TIMESTAMP_RESOLUTION = 
TimeUnit.MICROSECONDS;
     @Deprecated
     protected static final double DEFAULT_MAX_SSTABLE_AGE_DAYS = 365*1000;
@@ -48,6 +52,8 @@ public final class DateTieredCompactionStrategyOptions
     {
         String optionValue = options.get(TIMESTAMP_RESOLUTION_KEY);
         TimeUnit timestampResolution = optionValue == null ? 
DEFAULT_TIMESTAMP_RESOLUTION : TimeUnit.valueOf(optionValue);
+        if (timestampResolution != DEFAULT_TIMESTAMP_RESOLUTION)
+            logger.warn("Using a non-default timestamp_resolution {} - are you 
really doing inserts with USING TIMESTAMP <non_microsecond_timestamp> (or 
driver equivalent)?", timestampResolution.toString());
         optionValue = options.get(MAX_SSTABLE_AGE_KEY);
         double fractionalDays = optionValue == null ? 
DEFAULT_MAX_SSTABLE_AGE_DAYS : Double.parseDouble(optionValue);
         maxSSTableAge = Math.round(fractionalDays * 
timestampResolution.convert(1, TimeUnit.DAYS));

Reply via email to