cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bened...@apache.org
Subject git commit: Permit configurable timestamps with cassandra-stress (CASSANDRA-7416)
Date Mon, 23 Jun 2014 20:42:27 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk fdb35512d -> 2a3e2021f


Permit configurable timestamps with cassandra-stress (CASSANDRA-7416)

patch by Matt Kennedy; reviewed by Benedict Elliott Smith for CASSANDRA-7416


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

Branch: refs/heads/trunk
Commit: 2a3e2021f134ad51de0f025b253907ee5f391a86
Parents: fdb3551
Author: stinkymatt <stinkymatt@gmail.com>
Authored: Mon Jun 23 21:41:19 2014 +0100
Committer: Benedict Elliott Smith <benedict@apache.org>
Committed: Mon Jun 23 21:41:19 2014 +0100

----------------------------------------------------------------------
 CHANGES.txt                                                   | 1 +
 .../org/apache/cassandra/stress/operations/CqlInserter.java   | 2 ++
 .../apache/cassandra/stress/operations/ThriftInserter.java    | 4 +++-
 .../org/apache/cassandra/stress/settings/SettingsColumn.java  | 7 +++++--
 4 files changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2a3e2021/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 7124ec4..3b14fbe 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0
+ * Permit configurable timestamps with cassandra-stress (CASSANDRA-7416)
  * Move sstable RandomAccessReader to nio2, which allows using the
    FILE_SHARE_DELETE flag on Windows (CASSANDRA-4050)
  * Remove CQL2 (CASSANDRA-5918)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2a3e2021/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
index 45e375b..b459e04 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
@@ -41,6 +41,8 @@ public class CqlInserter extends CqlOperation<Integer>
     protected String buildQuery()
     {
         StringBuilder query = new StringBuilder("UPDATE ").append(wrapInQuotes(state.type.table));
+        if (state.settings.columns.timestamp != null)
+            query.append(" USING TIMESTAMP ").append(state.settings.columns.timestamp);
 
         query.append(" SET ");
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2a3e2021/tools/stress/src/org/apache/cassandra/stress/operations/ThriftInserter.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/ThriftInserter.java b/tools/stress/src/org/apache/cassandra/stress/operations/ThriftInserter.java
index 7077a95..73515ae 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/ThriftInserter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/ThriftInserter.java
@@ -109,7 +109,9 @@ public final class ThriftInserter extends Operation
         for (int i = 0 ; i < values.size() ; i++)
             columns.get(i)
                     .setValue(values.get(i))
-                    .setTimestamp(FBUtilities.timestampMicros());
+                    .setTimestamp(state.settings.columns.timestamp != null
+                                  ? Long.parseLong(state.settings.columns.timestamp)
+                                  : FBUtilities.timestampMicros());
 
         return columns;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2a3e2021/tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java
index 7e20ec6..4fac5d0 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java
@@ -42,6 +42,7 @@ public class SettingsColumn implements Serializable
     public final List<ByteBuffer> names;
     public final List<String> namestrs;
     public final String comparator;
+    public final String timestamp;
     public final boolean useTimeUUIDComparator;
     public final int superColumns;
     public final boolean useSuperColumns;
@@ -66,6 +67,7 @@ public class SettingsColumn implements Serializable
         dataGenFactory = options.generator.get();
         useSuperColumns = superColumns > 0;
         {
+            timestamp = options.timestamp.value();
             comparator = options.comparator.value();
             AbstractType parsed = null;
 
@@ -149,6 +151,7 @@ public class SettingsColumn implements Serializable
         final OptionSimple superColumns = new OptionSimple("super=", "[0-9]+", "0", "Number
of super columns to use (no super columns used if not specified)", false);
         final OptionSimple comparator = new OptionSimple("comparator=", "TimeUUIDType|AsciiType|UTF8Type",
"AsciiType", "Column Comparator to use", false);
         final OptionSimple slice = new OptionSimple("slice", "", null, "If set, range slices
will be used for reads, otherwise a names query will be", false);
+        final OptionSimple timestamp = new OptionSimple("timestamp=", "[0-9]+", null, "If
set, all columns will be written with the given timestamp", false);
         final OptionDistribution size = new OptionDistribution("size=", "FIXED(34)", "Cell
size distribution");
         final OptionDataGen generator = new OptionDataGen("data=", "REPEAT(50)");
     }
@@ -160,7 +163,7 @@ public class SettingsColumn implements Serializable
         @Override
         public List<? extends Option> options()
         {
-            return Arrays.asList(name, slice, superColumns, comparator, size, generator);
+            return Arrays.asList(name, slice, superColumns, comparator, timestamp, size,
generator);
         }
     }
 
@@ -171,7 +174,7 @@ public class SettingsColumn implements Serializable
         @Override
         public List<? extends Option> options()
         {
-            return Arrays.asList(count, slice, superColumns, comparator, size, generator);
+            return Arrays.asList(count, slice, superColumns, comparator, timestamp, size,
generator);
         }
     }
 


Mime
View raw message