cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bened...@apache.org
Subject [3/5] cassandra git commit: cassandra-stress simultaneous inserts over same seed
Date Fri, 12 Dec 2014 14:10:24 GMT
http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaInsert.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaInsert.java
b/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaInsert.java
index 8e20ab3..61237f1 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaInsert.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaInsert.java
@@ -30,11 +30,7 @@ import com.datastax.driver.core.BoundStatement;
 import com.datastax.driver.core.PreparedStatement;
 import com.datastax.driver.core.Statement;
 import org.apache.cassandra.db.ConsistencyLevel;
-import org.apache.cassandra.stress.generate.Distribution;
-import org.apache.cassandra.stress.generate.Partition;
-import org.apache.cassandra.stress.generate.PartitionGenerator;
-import org.apache.cassandra.stress.generate.RatioDistribution;
-import org.apache.cassandra.stress.generate.Row;
+import org.apache.cassandra.stress.generate.*;
 import org.apache.cassandra.stress.settings.StressSettings;
 import org.apache.cassandra.stress.settings.ValidationType;
 import org.apache.cassandra.stress.util.JavaDriverClient;
@@ -45,13 +41,16 @@ public class SchemaInsert extends SchemaStatement
 {
 
     private final BatchStatement.Type batchType;
-    private final RatioDistribution selectChance;
 
-    public SchemaInsert(Timer timer, PartitionGenerator generator, StressSettings settings,
Distribution batchSize, RatioDistribution selectChance, Integer thriftId, PreparedStatement
statement, ConsistencyLevel cl, BatchStatement.Type batchType)
+    public SchemaInsert(Timer timer, StressSettings settings, PartitionGenerator generator,
SeedManager seedManager, Distribution batchSize, RatioDistribution useRatio, Integer thriftId,
PreparedStatement statement, ConsistencyLevel cl, BatchStatement.Type batchType)
     {
-        super(timer, generator, settings, batchSize, statement, thriftId, cl, ValidationType.NOT_FAIL);
+        super(timer, settings, spec(generator, seedManager, batchSize, useRatio), statement,
thriftId, cl, ValidationType.NOT_FAIL);
         this.batchType = batchType;
-        this.selectChance = selectChance;
+    }
+
+    private static DataSpec spec(PartitionGenerator generator, SeedManager seedManager, Distribution
partitionCount, RatioDistribution useRatio)
+    {
+        return new DataSpec(generator, seedManager, partitionCount, useRatio);
     }
 
     private class JavaDriverRun extends Runner
@@ -65,20 +64,13 @@ public class SchemaInsert extends SchemaStatement
 
         public boolean run() throws Exception
         {
-            Partition.RowIterator[] iterators = new Partition.RowIterator[partitions.size()];
-            for (int i = 0 ; i < iterators.length ; i++)
-                iterators[i] = partitions.get(i).iterator(selectChance.next(), true);
             List<BoundStatement> stmts = new ArrayList<>();
             partitionCount = partitions.size();
 
-            for (Partition.RowIterator iterator : iterators)
-            {
-                if (iterator.done())
-                    continue;
+            for (PartitionIterator iterator : partitions)
+                while (iterator.hasNext())
+                    stmts.add(bindRow(iterator.next()));
 
-                for (Row row : iterator.next())
-                    stmts.add(bindRow(row));
-            }
             rowCount += stmts.size();
 
             // 65535 is max number of stmts per batch, so if we have more, we need to manually
batch them
@@ -107,10 +99,6 @@ public class SchemaInsert extends SchemaStatement
                     e.printStackTrace();
                 }
             }
-
-            for (Partition.RowIterator iterator : iterators)
-                iterator.markWriteFinished();
-
             return true;
         }
     }
@@ -126,26 +114,14 @@ public class SchemaInsert extends SchemaStatement
 
         public boolean run() throws Exception
         {
-            Partition.RowIterator[] iterators = new Partition.RowIterator[partitions.size()];
-            for (int i = 0 ; i < iterators.length ; i++)
-                iterators[i] = partitions.get(i).iterator(selectChance.next(), true);
-            partitionCount = partitions.size();
-
-            for (Partition.RowIterator iterator : iterators)
+            for (PartitionIterator iterator : partitions)
             {
-                if (iterator.done())
-                    continue;
-
-                for (Row row : iterator.next())
+                while (iterator.hasNext())
                 {
-                    validate(client.execute_prepared_cql3_query(thriftId, iterator.partition().getToken(),
thriftRowArgs(row), settings.command.consistencyLevel));
+                    validate(client.execute_prepared_cql3_query(thriftId, iterator.getToken(),
thriftRowArgs(iterator.next()), settings.command.consistencyLevel));
                     rowCount += 1;
                 }
             }
-
-            for (Partition.RowIterator iterator : iterators)
-                iterator.markWriteFinished();
-
             return true;
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaQuery.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaQuery.java
b/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaQuery.java
index 866f6ab..72db2f7 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaQuery.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaQuery.java
@@ -31,10 +31,7 @@ import com.datastax.driver.core.BoundStatement;
 import com.datastax.driver.core.PreparedStatement;
 import com.datastax.driver.core.ResultSet;
 import org.apache.cassandra.db.ConsistencyLevel;
-import org.apache.cassandra.stress.generate.Partition;
-import org.apache.cassandra.stress.generate.PartitionGenerator;
-import org.apache.cassandra.stress.generate.Row;
-import org.apache.cassandra.stress.settings.OptionDistribution;
+import org.apache.cassandra.stress.generate.*;
 import org.apache.cassandra.stress.settings.StressSettings;
 import org.apache.cassandra.stress.settings.ValidationType;
 import org.apache.cassandra.stress.util.JavaDriverClient;
@@ -45,7 +42,6 @@ import org.apache.cassandra.thrift.ThriftConversion;
 
 public class SchemaQuery extends SchemaStatement
 {
-
     public static enum ArgSelect
     {
         MULTIROW, SAMEROW;
@@ -56,13 +52,18 @@ public class SchemaQuery extends SchemaStatement
     final Object[][] randomBuffer;
     final Random random = new Random();
 
-    public SchemaQuery(Timer timer, PartitionGenerator generator, StressSettings settings,
Integer thriftId, PreparedStatement statement, ConsistencyLevel cl, ValidationType validationType,
ArgSelect argSelect)
+    public SchemaQuery(Timer timer, StressSettings settings, PartitionGenerator generator,
SeedManager seedManager, Integer thriftId, PreparedStatement statement, ConsistencyLevel cl,
ValidationType validationType, ArgSelect argSelect)
     {
-        super(timer, generator, settings, OptionDistribution.get("fixed(1)").get(), statement,
thriftId, cl, validationType);
+        super(timer, settings, spec(generator, seedManager, statement.getVariables().size(),
argSelect), statement, thriftId, cl, validationType);
         this.argSelect = argSelect;
         randomBuffer = new Object[argumentIndex.length][argumentIndex.length];
     }
 
+    static DataSpec spec(PartitionGenerator generator, SeedManager seedManager, int argCount,
ArgSelect argSelect)
+    {
+        return new DataSpec(generator, seedManager, new DistributionFixed(1), argSelect ==
ArgSelect.MULTIROW ? argCount : 1);
+    }
+
     private class JavaDriverRun extends Runner
     {
         final JavaDriverClient client;
@@ -74,7 +75,7 @@ public class SchemaQuery extends SchemaStatement
 
         public boolean run() throws Exception
         {
-            ResultSet rs = client.getSession().execute(bindArgs(partitions.get(0)));
+            ResultSet rs = client.getSession().execute(bindArgs());
             validate(rs);
             rowCount = rs.all().size();
             partitionCount = Math.min(1, rowCount);
@@ -93,7 +94,7 @@ public class SchemaQuery extends SchemaStatement
 
         public boolean run() throws Exception
         {
-            CqlResult rs = client.execute_prepared_cql3_query(thriftId, partitions.get(0).getToken(),
thriftArgs(partitions.get(0)), ThriftConversion.toThrift(cl));
+            CqlResult rs = client.execute_prepared_cql3_query(thriftId, partitions.get(0).getToken(),
thriftArgs(), ThriftConversion.toThrift(cl));
             validate(rs);
             rowCount = rs.getRowsSize();
             partitionCount = Math.min(1, rowCount);
@@ -101,29 +102,29 @@ public class SchemaQuery extends SchemaStatement
         }
     }
 
-    private int fillRandom(Partition partition)
+    private int fillRandom()
     {
         int c = 0;
-        while (c == 0)
+        PartitionIterator iterator = partitions.get(0);
+        while (iterator.hasNext())
         {
-            for (Row row : partition.iterator(randomBuffer.length, false).next())
-            {
-                Object[] randomRow = randomBuffer[c++];
-                for (int i = 0 ; i < argumentIndex.length ; i++)
-                    randomRow[i] = row.get(argumentIndex[i]);
-                if (c >= randomBuffer.length)
-                    break;
-            }
+            Row row = iterator.next();
+            Object[] randomBufferRow = randomBuffer[c++];
+            for (int i = 0 ; i < argumentIndex.length ; i++)
+                randomBufferRow[i] = row.get(argumentIndex[i]);
+            if (c >= randomBuffer.length)
+                break;
         }
+        assert c > 0;
         return c;
     }
 
-    BoundStatement bindArgs(Partition partition)
+    BoundStatement bindArgs()
     {
         switch (argSelect)
         {
             case MULTIROW:
-                int c = fillRandom(partition);
+                int c = fillRandom();
                 for (int i = 0 ; i < argumentIndex.length ; i++)
                 {
                     int argIndex = argumentIndex[i];
@@ -131,29 +132,27 @@ public class SchemaQuery extends SchemaStatement
                 }
                 return statement.bind(bindBuffer);
             case SAMEROW:
-                for (Row row : partition.iterator(1, false).next())
-                    return bindRow(row);
+                return bindRow(partitions.get(0).next());
             default:
                 throw new IllegalStateException();
         }
     }
 
-    List<ByteBuffer> thriftArgs(Partition partition)
+    List<ByteBuffer> thriftArgs()
     {
         switch (argSelect)
         {
             case MULTIROW:
                 List<ByteBuffer> args = new ArrayList<>();
-                int c = fillRandom(partition);
+                int c = fillRandom();
                 for (int i = 0 ; i < argumentIndex.length ; i++)
                 {
                     int argIndex = argumentIndex[i];
-                    args.add(generator.convert(argIndex, randomBuffer[argIndex < 0 ? 0
: random.nextInt(c)][i]));
+                    args.add(spec.partitionGenerator.convert(argIndex, randomBuffer[argIndex
< 0 ? 0 : random.nextInt(c)][i]));
                 }
                 return args;
             case SAMEROW:
-                for (Row row : partition.iterator(1, false).next())
-                    return thriftRowArgs(row);
+                return thriftRowArgs(partitions.get(0).next());
             default:
                 throw new IllegalStateException();
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaStatement.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaStatement.java
b/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaStatement.java
index 1f7ed80..75e49b4 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaStatement.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/SchemaStatement.java
@@ -25,7 +25,6 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Random;
 
 import com.datastax.driver.core.BoundStatement;
 import com.datastax.driver.core.ColumnDefinitions;
@@ -33,9 +32,6 @@ import com.datastax.driver.core.PreparedStatement;
 import com.datastax.driver.core.ResultSet;
 import org.apache.cassandra.db.ConsistencyLevel;
 import org.apache.cassandra.stress.Operation;
-import org.apache.cassandra.stress.generate.Distribution;
-import org.apache.cassandra.stress.generate.Partition;
-import org.apache.cassandra.stress.generate.PartitionGenerator;
 import org.apache.cassandra.stress.generate.Row;
 import org.apache.cassandra.stress.settings.StressSettings;
 import org.apache.cassandra.stress.settings.ValidationType;
@@ -46,7 +42,6 @@ import org.apache.cassandra.transport.SimpleClient;
 public abstract class SchemaStatement extends Operation
 {
 
-    final PartitionGenerator generator;
     final PreparedStatement statement;
     final Integer thriftId;
     final ConsistencyLevel cl;
@@ -54,11 +49,10 @@ public abstract class SchemaStatement extends Operation
     final int[] argumentIndex;
     final Object[] bindBuffer;
 
-    public SchemaStatement(Timer timer, PartitionGenerator generator, StressSettings settings,
Distribution partitionCount,
+    public SchemaStatement(Timer timer, StressSettings settings, DataSpec spec,
                            PreparedStatement statement, Integer thriftId, ConsistencyLevel
cl, ValidationType validationType)
     {
-        super(timer, generator, settings, partitionCount);
-        this.generator = generator;
+        super(timer, settings, spec);
         this.statement = statement;
         this.thriftId = thriftId;
         this.cl = cl;
@@ -67,7 +61,7 @@ public abstract class SchemaStatement extends Operation
         bindBuffer = new Object[argumentIndex.length];
         int i = 0;
         for (ColumnDefinitions.Definition definition : statement.getVariables())
-            argumentIndex[i++] = generator.indexOf(definition.getName());
+            argumentIndex[i++] = spec.partitionGenerator.indexOf(definition.getName());
     }
 
     BoundStatement bindRow(Row row)
@@ -75,7 +69,7 @@ public abstract class SchemaStatement extends Operation
         for (int i = 0 ; i < argumentIndex.length ; i++)
         {
             bindBuffer[i] = row.get(argumentIndex[i]);
-            if (bindBuffer[i] == null && !generator.permitNulls(argumentIndex[i]))
+            if (bindBuffer[i] == null && !spec.partitionGenerator.permitNulls(argumentIndex[i]))
                 throw new IllegalStateException();
         }
         return statement.bind(bindBuffer);
@@ -85,7 +79,7 @@ public abstract class SchemaStatement extends Operation
     {
         List<ByteBuffer> args = new ArrayList<>();
         for (int i : argumentIndex)
-            args.add(generator.convert(i, row.get(i)));
+            args.add(spec.partitionGenerator.convert(i, row.get(i)));
         return args;
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/settings/Command.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/Command.java b/tools/stress/src/org/apache/cassandra/stress/settings/Command.java
index 7138cbb..1572946 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/Command.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/Command.java
@@ -21,7 +21,10 @@ package org.apache.cassandra.stress.settings;
  */
 
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 import com.google.common.collect.ImmutableList;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/settings/OptionAnyProbabilities.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/OptionAnyProbabilities.java
b/tools/stress/src/org/apache/cassandra/stress/settings/OptionAnyProbabilities.java
index b685294..9c2f367 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/OptionAnyProbabilities.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/OptionAnyProbabilities.java
@@ -21,13 +21,7 @@ package org.apache.cassandra.stress.settings;
  */
 
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
+import java.util.*;
 
 
 public final class OptionAnyProbabilities extends OptionMulti

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/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 ef3dbb1..45e832a 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/OptionDistribution.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/OptionDistribution.java
@@ -26,14 +26,14 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import com.google.common.base.Function;
-
-import org.apache.cassandra.stress.generate.*;
 import org.apache.commons.math3.distribution.ExponentialDistribution;
 import org.apache.commons.math3.distribution.NormalDistribution;
 import org.apache.commons.math3.distribution.UniformRealDistribution;
 import org.apache.commons.math3.distribution.WeibullDistribution;
 import org.apache.commons.math3.random.JDKRandomGenerator;
 
+import org.apache.cassandra.stress.generate.*;
+
 /**
  * For selecting a mathematical distribution
  */

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/settings/OptionEnumProbabilities.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/OptionEnumProbabilities.java
b/tools/stress/src/org/apache/cassandra/stress/settings/OptionEnumProbabilities.java
index 71d7a8d..c218176 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/OptionEnumProbabilities.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/OptionEnumProbabilities.java
@@ -22,9 +22,9 @@ package org.apache.cassandra.stress.settings;
 
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.HashMap;
 
 
 public final class OptionEnumProbabilities<T> extends OptionMulti

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/settings/OptionMulti.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/OptionMulti.java b/tools/stress/src/org/apache/cassandra/stress/settings/OptionMulti.java
index 32bfc65..6d11012 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/OptionMulti.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/OptionMulti.java
@@ -21,12 +21,7 @@ package org.apache.cassandra.stress.settings;
  */
 
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/settings/OptionRatioDistribution.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/OptionRatioDistribution.java
b/tools/stress/src/org/apache/cassandra/stress/settings/OptionRatioDistribution.java
index 756536f..416f045 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/OptionRatioDistribution.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/OptionRatioDistribution.java
@@ -21,27 +21,14 @@ package org.apache.cassandra.stress.settings;
  */
 
 
-import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import com.google.common.base.Function;
-import org.apache.commons.math3.distribution.ExponentialDistribution;
-import org.apache.commons.math3.distribution.NormalDistribution;
-import org.apache.commons.math3.distribution.UniformRealDistribution;
-import org.apache.commons.math3.distribution.WeibullDistribution;
-import org.apache.commons.math3.random.JDKRandomGenerator;
-
-import org.apache.cassandra.stress.generate.Distribution;
-import org.apache.cassandra.stress.generate.DistributionBoundApache;
+
 import org.apache.cassandra.stress.generate.DistributionFactory;
-import org.apache.cassandra.stress.generate.DistributionFixed;
-import org.apache.cassandra.stress.generate.DistributionInverted;
-import org.apache.cassandra.stress.generate.DistributionOffsetApache;
 import org.apache.cassandra.stress.generate.RatioDistribution;
 import org.apache.cassandra.stress.generate.RatioDistributionFactory;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/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 ecdef29..bf78bf9 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java
@@ -22,19 +22,17 @@ package org.apache.cassandra.stress.settings;
 
 
 import java.io.IOException;
-import java.io.Serializable;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.nio.ByteBuffer;
 import java.nio.charset.CharacterCodingException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import org.apache.cassandra.db.marshal.*;
-import org.apache.cassandra.stress.generate.*;
+import org.apache.cassandra.stress.generate.Distribution;
+import org.apache.cassandra.stress.generate.DistributionFactory;
+import org.apache.cassandra.stress.generate.DistributionFixed;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/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 8850544..8751dbf 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommand.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommand.java
@@ -27,7 +27,6 @@ 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;
 import org.apache.cassandra.thrift.ConsistencyLevel;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/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 8583e90..ee1958b 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefined.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefined.java
@@ -37,7 +37,6 @@ 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
@@ -54,7 +53,7 @@ public class SettingsCommandPreDefined extends SettingsCommand
         {
             public OpDistribution get(Timer timer)
             {
-                return new FixedOpDistribution(PredefinedOperation.operation(type, timer,
newGenerator(settings, seeds), settings, add));
+                return new FixedOpDistribution(PredefinedOperation.operation(type, timer,
newGenerator(settings), seeds, settings, add));
             }
 
             public String desc()
@@ -69,7 +68,7 @@ public class SettingsCommandPreDefined extends SettingsCommand
         };
     }
 
-    PartitionGenerator newGenerator(StressSettings settings, SeedManager seeds)
+    PartitionGenerator newGenerator(StressSettings settings)
     {
         List<String> names = settings.columns.namestrs;
         List<Generator> partitionKey = Collections.<Generator>singletonList(new
HexBytes("key",
@@ -79,7 +78,7 @@ public class SettingsCommandPreDefined extends SettingsCommand
         List<Generator> columns = new ArrayList<>();
         for (int i = 0 ; i < settings.columns.maxColumnsPerKey ; i++)
             columns.add(new Bytes(names.get(i), new GeneratorConfig("randomstr" + names.get(i),
null, settings.columns.sizeDistribution, null)));
-        return new PartitionGenerator(partitionKey, Collections.<Generator>emptyList(),
columns, PartitionGenerator.Order.ARBITRARY, seeds);
+        return new PartitionGenerator(partitionKey, Collections.<Generator>emptyList(),
columns, PartitionGenerator.Order.ARBITRARY);
     }
 
     public SettingsCommandPreDefined(Command type, Options options)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/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 6beb55f..3a1d552 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefinedMixed.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefinedMixed.java
@@ -35,8 +35,6 @@ import org.apache.cassandra.stress.operations.SampledOpDistributionFactory;
 import org.apache.cassandra.stress.operations.predefined.PredefinedOperation;
 import org.apache.cassandra.stress.util.Timer;
 
-import org.apache.commons.math3.util.Pair;
-
 // Settings unique to the mixed command type
 public class SettingsCommandPreDefinedMixed extends SettingsCommandPreDefined
 {
@@ -62,12 +60,12 @@ public class SettingsCommandPreDefinedMixed extends SettingsCommandPreDefined
         {
             protected Operation get(Timer timer, PartitionGenerator generator, Command key)
             {
-                return PredefinedOperation.operation(key, timer, generator, settings, add);
+                return PredefinedOperation.operation(key, timer, generator, seeds, settings,
add);
             }
 
             protected PartitionGenerator newGenerator()
             {
-                return SettingsCommandPreDefinedMixed.this.newGenerator(settings, seeds);
+                return SettingsCommandPreDefinedMixed.this.newGenerator(settings);
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/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 4e2997f..9841433 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java
@@ -23,16 +23,10 @@ package org.apache.cassandra.stress.settings;
 
 import java.io.File;
 import java.net.URI;
-import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 
-import com.google.common.collect.ImmutableList;
-
-import com.datastax.driver.core.BatchStatement;
 import org.apache.cassandra.stress.Operation;
 import org.apache.cassandra.stress.StressProfile;
 import org.apache.cassandra.stress.generate.DistributionFactory;
@@ -42,8 +36,6 @@ import org.apache.cassandra.stress.operations.OpDistributionFactory;
 import org.apache.cassandra.stress.operations.SampledOpDistributionFactory;
 import org.apache.cassandra.stress.util.Timer;
 
-import org.apache.commons.math3.util.Pair;
-
 // Settings unique to the mixed command type
 public class SettingsCommandUser extends SettingsCommand
 {
@@ -81,13 +73,13 @@ public class SettingsCommandUser extends SettingsCommand
             protected Operation get(Timer timer, PartitionGenerator generator, String key)
             {
                 if (key.equalsIgnoreCase("insert"))
-                    return profile.getInsert(timer, generator, settings);
-                return profile.getQuery(key, timer, generator, settings);
+                    return profile.getInsert(timer, generator, seeds, settings);
+                return profile.getQuery(key, timer, generator, seeds, settings);
             }
 
             protected PartitionGenerator newGenerator()
             {
-                return profile.newGenerator(settings, seeds);
+                return profile.newGenerator(settings);
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/settings/SettingsErrors.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsErrors.java b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsErrors.java
index 625f803..66daac4 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsErrors.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsErrors.java
@@ -21,9 +21,6 @@ package org.apache.cassandra.stress.settings;
  */
 
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintStream;
 import java.io.Serializable;
 import java.util.Arrays;
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/settings/SettingsNode.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsNode.java b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsNode.java
index 5297da8..ba1fcb5 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsNode.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsNode.java
@@ -25,12 +25,7 @@ import java.io.*;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 import com.datastax.driver.core.Host;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/settings/SettingsSchema.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsSchema.java b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsSchema.java
index 6e3a02e..342dd0b 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsSchema.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsSchema.java
@@ -25,7 +25,6 @@ import java.nio.ByteBuffer;
 import java.util.*;
 
 import org.apache.cassandra.thrift.*;
-import org.apache.cassandra.thrift.ConsistencyLevel;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 public class SettingsSchema implements Serializable

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/settings/StressSettings.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/StressSettings.java b/tools/stress/src/org/apache/cassandra/stress/settings/StressSettings.java
index 815fe9b..219e7cd 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/StressSettings.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/StressSettings.java
@@ -25,9 +25,6 @@ import java.io.Serializable;
 import java.util.*;
 
 import com.datastax.driver.core.Metadata;
-import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;
-import com.datastax.driver.core.policies.RoundRobinPolicy;
-import com.datastax.driver.core.policies.WhiteListPolicy;
 import org.apache.cassandra.config.EncryptionOptions;
 import org.apache.cassandra.stress.util.JavaDriverClient;
 import org.apache.cassandra.stress.util.SimpleThriftClient;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/util/DynamicList.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/util/DynamicList.java b/tools/stress/src/org/apache/cassandra/stress/util/DynamicList.java
index e5aaf44..e9d43a3 100644
--- a/tools/stress/src/org/apache/cassandra/stress/util/DynamicList.java
+++ b/tools/stress/src/org/apache/cassandra/stress/util/DynamicList.java
@@ -41,7 +41,7 @@ public class DynamicList<E>
         private final int[] size;
         // TODO: alternate links to save space
         private final Node<E>[] links;
-        private final E value;
+        private E value;
 
         private Node(int height, E value)
         {
@@ -96,7 +96,7 @@ public class DynamicList<E>
 
     public DynamicList(int maxExpectedSize)
     {
-        this.maxHeight = 3 + (int) Math.ceil(Math.log(maxExpectedSize) / Math.log(2));
+        this.maxHeight = 3 + Math.max(0, (int) Math.ceil(Math.log(maxExpectedSize) / Math.log(2)));
         head = new Node<>(maxHeight, null);
     }
 
@@ -105,15 +105,22 @@ public class DynamicList<E>
         return 1 + Integer.bitCount(ThreadLocalRandom.current().nextInt() & ((1 <<
(maxHeight - 1)) - 1));
     }
 
+    public Node<E> append(E value)
+    {
+        return append(value, Integer.MAX_VALUE);
+    }
+
     // add the value to the end of the list, and return the associated Node that permits
efficient removal
     // regardless of its future position in the list from other modifications
-    public Node<E> append(E value)
+    public Node<E> append(E value, int maxSize)
     {
         Node<E> newTail = new Node<>(randomLevel(), value);
 
         lock.writeLock().lock();
         try
         {
+            if (size >= maxSize)
+                return null;
             size++;
 
             Node<E> tail = head;
@@ -146,6 +153,8 @@ public class DynamicList<E>
     public void remove(Node<E> node)
     {
         lock.writeLock().lock();
+        assert node.value != null;
+        node.value = null;
         try
         {
             size--;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java b/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java
index 2105179..295ed25 100644
--- a/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java
+++ b/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java
@@ -25,10 +25,10 @@ import javax.net.ssl.SSLContext;
 import com.datastax.driver.core.*;
 import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;
 import com.datastax.driver.core.policies.WhiteListPolicy;
-import org.apache.cassandra.config.EncryptionOptions;
-import org.apache.cassandra.security.SSLFactory;
 import io.netty.util.internal.logging.InternalLoggerFactory;
 import io.netty.util.internal.logging.Slf4JLoggerFactory;
+import org.apache.cassandra.config.EncryptionOptions;
+import org.apache.cassandra.security.SSLFactory;
 import org.apache.cassandra.stress.settings.StressSettings;
 
 public class JavaDriverClient

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/util/SmartThriftClient.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/util/SmartThriftClient.java b/tools/stress/src/org/apache/cassandra/stress/util/SmartThriftClient.java
index 6367936..178da64 100644
--- a/tools/stress/src/org/apache/cassandra/stress/util/SmartThriftClient.java
+++ b/tools/stress/src/org/apache/cassandra/stress/util/SmartThriftClient.java
@@ -29,9 +29,10 @@ import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import com.google.common.collect.Iterators;
+
 import com.datastax.driver.core.Host;
 import com.datastax.driver.core.Metadata;
-import com.google.common.collect.Iterators;
 import org.apache.cassandra.stress.settings.StressSettings;
 import org.apache.cassandra.thrift.*;
 import org.apache.cassandra.utils.ByteBufferUtil;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/util/Timer.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/util/Timer.java b/tools/stress/src/org/apache/cassandra/stress/util/Timer.java
index 7449a00..ff625a8 100644
--- a/tools/stress/src/org/apache/cassandra/stress/util/Timer.java
+++ b/tools/stress/src/org/apache/cassandra/stress/util/Timer.java
@@ -23,7 +23,6 @@ package org.apache.cassandra.stress.util;
 
 import java.util.Arrays;
 import java.util.List;
-import java.util.Random;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ThreadLocalRandom;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/util/Timing.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/util/Timing.java b/tools/stress/src/org/apache/cassandra/stress/util/Timing.java
index f48ce35..9464b19 100644
--- a/tools/stress/src/org/apache/cassandra/stress/util/Timing.java
+++ b/tools/stress/src/org/apache/cassandra/stress/util/Timing.java
@@ -24,7 +24,6 @@ package org.apache.cassandra.stress.util;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Random;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CountDownLatch;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c579a01/tools/stress/src/org/apache/cassandra/stress/util/TimingInterval.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/util/TimingInterval.java b/tools/stress/src/org/apache/cassandra/stress/util/TimingInterval.java
index 11d313f..065ea52 100644
--- a/tools/stress/src/org/apache/cassandra/stress/util/TimingInterval.java
+++ b/tools/stress/src/org/apache/cassandra/stress/util/TimingInterval.java
@@ -24,7 +24,6 @@ package org.apache.cassandra.stress.util;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Random;
 import java.util.concurrent.ThreadLocalRandom;
 
 // represents measurements taken over an interval of time


Mime
View raw message