You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by st...@apache.org on 2016/10/24 03:13:16 UTC
[2/3] cassandra git commit: Add sequence distribution type to
cassandra stress: fix problem with setSeed()
Add sequence distribution type to cassandra stress: fix problem with setSeed()
Patch by Ben Slater; reviewed by Stefania Alborghetti for CASSANDRA-12490
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7c759e2c
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7c759e2c
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7c759e2c
Branch: refs/heads/trunk
Commit: 7c759e2c326357a241e63c19cd4cd329f7920ea3
Parents: d4a914d
Author: Ben Slater <be...@instaclustr.com>
Authored: Fri Oct 21 13:55:37 2016 +0800
Committer: Stefania Alborghetti <st...@datastax.com>
Committed: Mon Oct 24 11:09:04 2016 +0800
----------------------------------------------------------------------
tools/cqlstress-counter-example.yaml | 3 +-
tools/cqlstress-example.yaml | 2 +-
tools/cqlstress-insanity-example.yaml | 2 +-
.../stress/generate/DistributionSequence.java | 5 +++-
.../stress/settings/OptionDistribution.java | 2 +-
.../generate/DistributionSequenceTest.java | 31 ++++++++++++++++++++
6 files changed, 39 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7c759e2c/tools/cqlstress-counter-example.yaml
----------------------------------------------------------------------
diff --git a/tools/cqlstress-counter-example.yaml b/tools/cqlstress-counter-example.yaml
index 9084e84..2430e50 100644
--- a/tools/cqlstress-counter-example.yaml
+++ b/tools/cqlstress-counter-example.yaml
@@ -48,11 +48,10 @@ table_definition: |
# GAUSSIAN(min..max,mean,stdev) A gaussian/normal distribution, with explicitly defined mean and stdev
# UNIFORM(min..max) A uniform distribution over the range [min, max]
# FIXED(val) A fixed distribution, always returning the same value
-# SEQ(min..max) A fixed sequence, returning values from min to max sequentially, wrapping if necessary.
+# SEQ(min..max) A fixed sequence, returning values in the range min to max sequentially (starting based on seed), wrapping if necessary.
# Aliases: extr, gauss, normal, norm, weibull
#
# If preceded by ~, the distribution is inverted
-#
# Defaults for all columns are size: uniform(4..8), population: uniform(1..100B), cluster: fixed(1)
#
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7c759e2c/tools/cqlstress-example.yaml
----------------------------------------------------------------------
diff --git a/tools/cqlstress-example.yaml b/tools/cqlstress-example.yaml
index b2b915d..cde345a 100644
--- a/tools/cqlstress-example.yaml
+++ b/tools/cqlstress-example.yaml
@@ -59,7 +59,7 @@ table_definition: |
# GAUSSIAN(min..max,mean,stdev) A gaussian/normal distribution, with explicitly defined mean and stdev
# UNIFORM(min..max) A uniform distribution over the range [min, max]
# FIXED(val) A fixed distribution, always returning the same value
-# SEQ(min..max) A fixed sequence, returning values from min to max sequentially, wrapping if necessary.
+# SEQ(min..max) A fixed sequence, returning values in the range min to max sequentially (starting based on seed), wrapping if necessary.
# Aliases: extr, gauss, normal, norm, weibull
#
# If preceded by ~, the distribution is inverted
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7c759e2c/tools/cqlstress-insanity-example.yaml
----------------------------------------------------------------------
diff --git a/tools/cqlstress-insanity-example.yaml b/tools/cqlstress-insanity-example.yaml
index 35bcd4a..5eb4fec 100644
--- a/tools/cqlstress-insanity-example.yaml
+++ b/tools/cqlstress-insanity-example.yaml
@@ -58,7 +58,7 @@ table_definition: |
# GAUSSIAN(min..max,mean,stdev) A gaussian/normal distribution, with explicitly defined mean and stdev
# UNIFORM(min..max) A uniform distribution over the range [min, max]
# FIXED(val) A fixed distribution, always returning the same value
-# SEQ(min..max) A fixed sequence, returning values from min to max sequentially, wrapping if necessary.
+# SEQ(min..max) A fixed sequence, returning values in the range min to max sequentially (starting based on seed), wrapping if necessary.
# Aliases: extr, gauss, normal, norm, weibull
#
# If preceded by ~, the distribution is inverted
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7c759e2c/tools/stress/src/org/apache/cassandra/stress/generate/DistributionSequence.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/generate/DistributionSequence.java b/tools/stress/src/org/apache/cassandra/stress/generate/DistributionSequence.java
index 424c661..0546897 100644
--- a/tools/stress/src/org/apache/cassandra/stress/generate/DistributionSequence.java
+++ b/tools/stress/src/org/apache/cassandra/stress/generate/DistributionSequence.java
@@ -63,7 +63,10 @@ public class DistributionSequence extends Distribution
}
@Override
- public void setSeed(long seed){}
+ public void setSeed(long seed)
+ {
+ next.set(seed);
+ }
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7c759e2c/tools/stress/src/org/apache/cassandra/stress/settings/OptionDistribution.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/OptionDistribution.java b/tools/stress/src/org/apache/cassandra/stress/settings/OptionDistribution.java
index 8784158..cc93323 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/OptionDistribution.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/OptionDistribution.java
@@ -124,7 +124,7 @@ public class OptionDistribution extends Option
GroupedOptions.formatMultiLine("GAUSSIAN(min..max,mean,stdev)", "A gaussian/normal distribution, with explicitly defined mean and stdev"),
GroupedOptions.formatMultiLine("UNIFORM(min..max)", "A uniform distribution over the range [min, max]"),
GroupedOptions.formatMultiLine("FIXED(val)", "A fixed distribution, always returning the same value"),
- GroupedOptions.formatMultiLine("SEQ(min..max)", "A fixed sequence, returning values from min to max sequentially, wrapping if necessary."),
+ GroupedOptions.formatMultiLine("SEQ(min..max)", "A fixed sequence, returning values in the range min to max sequentially (starting based on seed), wrapping if necessary."),
"Preceding the name with ~ will invert the distribution, e.g. ~exp(1..10) will yield 10 most, instead of least, often",
"Aliases: extr, qextr, gauss, normal, norm, weibull"
);
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7c759e2c/tools/stress/test/unit/org/apache/cassandra/stress/generate/DistributionSequenceTest.java
----------------------------------------------------------------------
diff --git a/tools/stress/test/unit/org/apache/cassandra/stress/generate/DistributionSequenceTest.java b/tools/stress/test/unit/org/apache/cassandra/stress/generate/DistributionSequenceTest.java
index 6f184d7..591833c 100644
--- a/tools/stress/test/unit/org/apache/cassandra/stress/generate/DistributionSequenceTest.java
+++ b/tools/stress/test/unit/org/apache/cassandra/stress/generate/DistributionSequenceTest.java
@@ -96,4 +96,35 @@ public class DistributionSequenceTest
assertEquals(Long.MAX_VALUE, dist.inverseCumProb(1d));
}
+
+ @Test
+ public void setSeed() throws Exception
+ {
+ Distribution dist = OptionDistribution.get("seq(1..10)").get();
+ assertTrue(dist instanceof DistributionSequence);
+
+ for (int seed=1; seed<500; seed+=seed)
+ {
+ dist.setSeed(seed);
+ assertEquals(1, dist.minValue());
+ assertEquals(10, dist.maxValue());
+ assertEquals(5, dist.average());
+
+ assertEquals(1, dist.inverseCumProb(0d));
+ assertEquals(10, dist.inverseCumProb(1d));
+
+ long last = dist.next();
+ for (int i = 0; i < 9; i++)
+ {
+ long next = dist.next();
+ if (next>1)
+ {
+ assertEquals(next, last + 1); //increase by one each step
+ }else{
+ assertEquals(last, 10); //wrap after the end
+ }
+ last = next;
+ }
+ }
+ }
}