cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bened...@apache.org
Subject [1/3] git commit: cassandra-stress: merge 7468 into 2.1, and ninja-fix duration setting for user command
Date Thu, 11 Sep 2014 04:29:03 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 5fb32ba0c -> 530c9f52c
  refs/heads/trunk e7752549d -> 51a6f0f7f


cassandra-stress: merge 7468 into 2.1, and ninja-fix duration setting for user command


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

Branch: refs/heads/cassandra-2.1
Commit: 530c9f52c341fccfc8744307c359566697e54a0a
Parents: 5fb32ba
Author: Benedict Elliott Smith <benedict@apache.org>
Authored: Thu Sep 11 11:27:34 2014 +0700
Committer: Benedict Elliott Smith <benedict@apache.org>
Committed: Thu Sep 11 11:27:34 2014 +0700

----------------------------------------------------------------------
 .../apache/cassandra/stress/StressAction.java   | 22 ++++--
 .../apache/cassandra/stress/StressProfile.java  |  2 +-
 .../operations/predefined/ThriftInserter.java   |  4 +-
 .../stress/settings/SettingsColumn.java         |  7 +-
 .../stress/settings/SettingsCommand.java        | 76 +++++++++++++++++++-
 .../settings/SettingsCommandPreDefined.java     |  6 +-
 .../SettingsCommandPreDefinedMixed.java         |  6 +-
 .../stress/settings/SettingsCommandUser.java    |  5 +-
 8 files changed, 109 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/530c9f52/tools/stress/src/org/apache/cassandra/stress/StressAction.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/StressAction.java b/tools/stress/src/org/apache/cassandra/stress/StressAction.java
index e58bfa1..f697dd9 100644
--- a/tools/stress/src/org/apache/cassandra/stress/StressAction.java
+++ b/tools/stress/src/org/apache/cassandra/stress/StressAction.java
@@ -67,7 +67,8 @@ public class StressAction implements Runnable
         if (settings.rate.auto)
             success = runAuto();
         else
-            success = null != run(settings.command.getFactory(settings), settings.rate.threadCount,
settings.command.count, output);
+            success = null != run(settings.command.getFactory(settings), settings.rate.threadCount,
settings.command.count,
+                                  settings.command.duration, settings.command.durationUnits,
output);
 
         if (success)
             output.println("END");
@@ -88,7 +89,7 @@ public class StressAction implements Runnable
             // we need to warm up all the nodes in the cluster ideally, but we may not be
the only stress instance;
             // so warm up all the nodes we're speaking to only.
             output.println(String.format("Warming up %s with %d iterations...", single.desc(),
iterations));
-            run(single, 20, iterations, warmupOutput);
+            run(single, 20, iterations, 0, null, warmupOutput);
         }
     }
 
@@ -104,7 +105,8 @@ public class StressAction implements Runnable
         {
             output.println(String.format("Running with %d threadCount", threadCount));
 
-            StressMetrics result = run(settings.command.getFactory(settings), threadCount,
settings.command.count, output);
+            StressMetrics result = run(settings.command.getFactory(settings), threadCount,
settings.command.count,
+                                       settings.command.duration, settings.command.durationUnits,
output);
             if (result == null)
                 return false;
             results.add(result);
@@ -161,13 +163,14 @@ public class StressAction implements Runnable
         return improvement / count;
     }
 
-    private StressMetrics run(OpDistributionFactory operations, int threadCount, long opCount,
PrintStream output)
+    private StressMetrics run(OpDistributionFactory operations, int threadCount, long opCount,
long duration, TimeUnit durationUnits, PrintStream output)
     {
-
         output.println(String.format("Running %s with %d threads %s",
                                      operations.desc(),
                                      threadCount,
-                                     opCount > 0 ? " for " + opCount + " iterations" :
"until stderr of mean < " + settings.command.targetUncertainty));
+                                     durationUnits != null ? duration + " " + durationUnits.toString().toLowerCase()
+                                        : opCount > 0      ? "for " + opCount + " iteration"
+                                                           : "until stderr of mean < "
+ settings.command.targetUncertainty));
         final WorkManager workManager;
         if (opCount < 0)
             workManager = new ContinuousWorkManager();
@@ -192,7 +195,12 @@ public class StressAction implements Runnable
 
         metrics.start();
 
-        if (opCount <= 0)
+        if (durationUnits != null)
+        {
+            Uninterruptibles.sleepUninterruptibly(duration, durationUnits);
+            workManager.stop();
+        }
+        else if (opCount <= 0)
         {
             try
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/530c9f52/tools/stress/src/org/apache/cassandra/stress/StressProfile.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/StressProfile.java b/tools/stress/src/org/apache/cassandra/stress/StressProfile.java
index de561f3..bd873e8 100644
--- a/tools/stress/src/org/apache/cassandra/stress/StressProfile.java
+++ b/tools/stress/src/org/apache/cassandra/stress/StressProfile.java
@@ -535,7 +535,7 @@ public class StressProfile implements Serializable
         while (iter.hasNext())
         {
             Map.Entry<String, V> e = iter.next();
-            if (!e.getKey().toLowerCase().equalsIgnoreCase(e.getKey()))
+            if (!e.getKey().equalsIgnoreCase(e.getKey()))
             {
                 reinsert.add(e);
                 iter.remove();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/530c9f52/tools/stress/src/org/apache/cassandra/stress/operations/predefined/ThriftInserter.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/predefined/ThriftInserter.java
b/tools/stress/src/org/apache/cassandra/stress/operations/predefined/ThriftInserter.java
index 2500c2e..d6adbf9 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/predefined/ThriftInserter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/predefined/ThriftInserter.java
@@ -94,7 +94,9 @@ public final class ThriftInserter extends PredefinedOperation
         for (int i = 0 ; i < values.size() ; i++)
             columns.add(new Column(names.get(i))
                         .setValue(values.get(i))
-                        .setTimestamp(FBUtilities.timestampMicros()));
+                        .setTimestamp(settings.columns.timestamp != null
+                                      ? Long.parseLong(settings.columns.timestamp)
+                                      : FBUtilities.timestampMicros()));
         return columns;
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/530c9f52/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 4b4e0b0..ecdef29 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java
@@ -47,6 +47,7 @@ public class SettingsColumn implements Serializable
     public transient List<ByteBuffer> names;
     public final List<String> namestrs;
     public final String comparator;
+    public final String timestamp;
     public final boolean variableColumnCount;
     public final boolean slice;
     public final DistributionFactory sizeDistribution;
@@ -64,6 +65,7 @@ public class SettingsColumn implements Serializable
     {
         sizeDistribution = options.size.get();
         {
+            timestamp = options.timestamp.value();
             comparator = options.comparator.value();
             AbstractType parsed = null;
 
@@ -148,6 +150,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");
     }
 
@@ -158,7 +161,7 @@ public class SettingsColumn implements Serializable
         @Override
         public List<? extends Option> options()
         {
-            return Arrays.asList(name, slice, superColumns, comparator, size);
+            return Arrays.asList(name, slice, superColumns, comparator, timestamp, size);
         }
     }
 
@@ -169,7 +172,7 @@ public class SettingsColumn implements Serializable
         @Override
         public List<? extends Option> options()
         {
-            return Arrays.asList(count, slice, superColumns, comparator, size);
+            return Arrays.asList(count, slice, superColumns, comparator, timestamp, size);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/530c9f52/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommand.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommand.java b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommand.java
index 59accb9..a1c89e1 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommand.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommand.java
@@ -25,6 +25,7 @@ import java.io.Serializable;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.cassandra.stress.generate.SeedManager;
 import org.apache.cassandra.stress.operations.OpDistributionFactory;
@@ -36,6 +37,8 @@ public abstract class SettingsCommand implements Serializable
 
     public final Command type;
     public final long count;
+    public final long duration;
+    public final TimeUnit durationUnits;
     public final boolean noWarmup;
     public final ConsistencyLevel consistencyLevel;
     public final double targetUncertainty;
@@ -48,11 +51,12 @@ public abstract class SettingsCommand implements Serializable
     {
         this(type, (Options) options,
                 options instanceof Count ? (Count) options : null,
+                options instanceof Duration ? (Duration) options : null,
                 options instanceof Uncertainty ? (Uncertainty) options : null
         );
     }
 
-    public SettingsCommand(Command type, Options options, Count count, Uncertainty uncertainty)
+    public SettingsCommand(Command type, Options options, Count count, Duration duration,
Uncertainty uncertainty)
     {
         this.type = type;
         this.consistencyLevel = ConsistencyLevel.valueOf(options.consistencyLevel.value().toUpperCase());
@@ -60,6 +64,30 @@ public abstract class SettingsCommand implements Serializable
         if (count != null)
         {
             this.count = Long.parseLong(count.count.value());
+            this.duration = 0;
+            this.durationUnits = null;
+            this.targetUncertainty = -1;
+            this.minimumUncertaintyMeasurements = -1;
+            this.maximumUncertaintyMeasurements = -1;
+        }
+        else if (duration != null)
+        {
+            this.count = -1;
+            this.duration = Long.parseLong(duration.duration.value().substring(0, duration.duration.value().length()
- 1));
+            switch (duration.duration.value().toLowerCase().charAt(duration.duration.value().length()
- 1))
+            {
+                case 's':
+                    this.durationUnits = TimeUnit.SECONDS;
+                    break;
+                case 'm':
+                    this.durationUnits = TimeUnit.MINUTES;
+                    break;
+                case 'h':
+                    this.durationUnits = TimeUnit.HOURS;
+                    break;
+                default:
+                    throw new IllegalStateException();
+            }
             this.targetUncertainty = -1;
             this.minimumUncertaintyMeasurements = -1;
             this.maximumUncertaintyMeasurements = -1;
@@ -67,6 +95,8 @@ public abstract class SettingsCommand implements Serializable
         else
         {
             this.count = -1;
+            this.duration = 0;
+            this.durationUnits = null;
             this.targetUncertainty = Double.parseDouble(uncertainty.uncertainty.value());
             this.minimumUncertaintyMeasurements = Integer.parseInt(uncertainty.minMeasurements.value());
             this.maximumUncertaintyMeasurements = Integer.parseInt(uncertainty.maxMeasurements.value());
@@ -91,6 +121,16 @@ public abstract class SettingsCommand implements Serializable
         }
     }
 
+    static class Duration extends Options
+    {
+        final OptionSimple duration = new OptionSimple("duration=", "[0-9]+[smh]", null,
"Time to run in (in seconds, minutes or hours)", true);
+        @Override
+        public List<? extends Option> options()
+        {
+            return Arrays.asList(duration, noWarmup, consistencyLevel);
+        }
+    }
+
     static class Uncertainty extends Options
     {
         final OptionSimple uncertainty = new OptionSimple("err<", "0\\.[0-9]+", "0.02",
"Run until the standard error of the mean is below this fraction", false);
@@ -132,5 +172,37 @@ public abstract class SettingsCommand implements Serializable
         return null;
     }
 
-}
+/*    static SettingsCommand build(Command type, String[] params)
+    {
+        GroupedOptions options = GroupedOptions.select(params, new Count(), new Duration(),
new Uncertainty());
+        if (options == null)
+        {
+            printHelp(type);
+            System.out.println("Invalid " + type + " options provided, see output for valid
options");
+            System.exit(1);
+        }
+        return new SettingsCommand(type, options);
+    }*/
+
+    static void printHelp(Command type)
+    {
+        printHelp(type.toString().toLowerCase());
+    }
 
+    static void printHelp(String type)
+    {
+        GroupedOptions.printOptions(System.out, type.toLowerCase(), new Uncertainty(), new
Count(), new Duration());
+    }
+
+    static Runnable helpPrinter(final Command type)
+    {
+        return new Runnable()
+        {
+            @Override
+            public void run()
+            {
+                printHelp(type);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/530c9f52/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefined.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefined.java
b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefined.java
index 5a8b604..ab60dd1 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefined.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefined.java
@@ -36,6 +36,7 @@ import org.apache.cassandra.stress.operations.FixedOpDistribution;
 import org.apache.cassandra.stress.operations.OpDistribution;
 import org.apache.cassandra.stress.operations.OpDistributionFactory;
 import org.apache.cassandra.stress.operations.predefined.PredefinedOperation;
+import org.apache.cassandra.stress.settings.SettingsCommandPreDefinedMixed.Options;
 import org.apache.cassandra.stress.util.Timer;
 
 // Settings unique to the mixed command type
@@ -116,7 +117,8 @@ public class SettingsCommandPreDefined extends SettingsCommand
     {
         GroupedOptions options = GroupedOptions.select(params,
                 new Options(new Uncertainty()),
-                new Options(new Count()));
+                new Options(new Count()),
+                new Options(new Duration()));
         if (options == null)
         {
             printHelp(type);
@@ -133,7 +135,7 @@ public class SettingsCommandPreDefined extends SettingsCommand
 
     static void printHelp(String type)
     {
-        GroupedOptions.printOptions(System.out, type.toLowerCase(), new Uncertainty(), new
Count());
+        GroupedOptions.printOptions(System.out, type.toLowerCase(), new Uncertainty(), new
Count(), new Duration());
     }
 
     static Runnable helpPrinter(final Command type)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/530c9f52/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefinedMixed.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefinedMixed.java
b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefinedMixed.java
index f383ed9..dc45b89 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefinedMixed.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefinedMixed.java
@@ -123,7 +123,8 @@ public class SettingsCommandPreDefinedMixed extends SettingsCommandPreDefined
     {
         GroupedOptions options = GroupedOptions.select(params,
                 new Options(new SettingsCommand.Uncertainty()),
-                new Options(new SettingsCommand.Count()));
+                new Options(new SettingsCommand.Count()),
+                new Options(new SettingsCommand.Duration()));
         if (options == null)
         {
             printHelp();
@@ -137,7 +138,8 @@ public class SettingsCommandPreDefinedMixed extends SettingsCommandPreDefined
     {
         GroupedOptions.printOptions(System.out, "mixed",
                                     new Options(new SettingsCommand.Uncertainty()),
-                                    new Options(new SettingsCommand.Count()));
+                                    new Options(new SettingsCommand.Count()),
+                                    new Options(new SettingsCommand.Duration()));
     }
 
     public static Runnable helpPrinter()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/530c9f52/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java
b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java
index d0e32b2..2e30d62 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java
@@ -96,7 +96,6 @@ public class SettingsCommandUser extends SettingsCommand
         {
             return ImmutableList.<Option>builder().add(ops, clustering, profile).addAll(parent.options()).build();
         }
-
     }
 
     // CLI utility methods
@@ -105,6 +104,7 @@ public class SettingsCommandUser extends SettingsCommand
     {
         GroupedOptions options = GroupedOptions.select(params,
                 new Options(new Uncertainty()),
+                new Options(new Duration()),
                 new Options(new Count()));
         if (options == null)
         {
@@ -119,7 +119,8 @@ public class SettingsCommandUser extends SettingsCommand
     {
         GroupedOptions.printOptions(System.out, "user",
                                     new Options(new Uncertainty()),
-                                    new Options(new Count()));
+                                    new Options(new Count()),
+                                    new Options(new Duration()));
     }
 
     public static Runnable helpPrinter()


Mime
View raw message