cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xe...@apache.org
Subject svn commit: r1170700 - in /cassandra/branches/cassandra-1.0.0: CHANGES.txt src/java/org/apache/cassandra/config/CFMetaData.java tools/stress/src/org/apache/cassandra/stress/Session.java
Date Wed, 14 Sep 2011 16:02:18 GMT
Author: xedin
Date: Wed Sep 14 16:02:18 2011
New Revision: 1170700

URL: http://svn.apache.org/viewvc?rev=1170700&view=rev
Log:
Support of compaction strategy option for stress.java
patch by Pavel Yaskevich; reviewed by Brandon Williams for CASSANDRA-3204

Modified:
    cassandra/branches/cassandra-1.0.0/CHANGES.txt
    cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/config/CFMetaData.java
    cassandra/branches/cassandra-1.0.0/tools/stress/src/org/apache/cassandra/stress/Session.java

Modified: cassandra/branches/cassandra-1.0.0/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0.0/CHANGES.txt?rev=1170700&r1=1170699&r2=1170700&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0.0/CHANGES.txt (original)
+++ cassandra/branches/cassandra-1.0.0/CHANGES.txt Wed Sep 14 16:02:18 2011
@@ -74,7 +74,7 @@
  * Fix backwards compatibilty for CQL memtable properties (CASSANDRA-3190)
  * Add five-minute delay before starting compactions on a restarted server
    (CASSANDRA-3181)
-
+ * support of compaction strategy option for stress.java (CASSANDRA-3204)
 
 0.8.6
  * avoid trying to watch cassandra-topology.properties when loaded from jar

Modified: cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/config/CFMetaData.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/config/CFMetaData.java?rev=1170700&r1=1170699&r2=1170700&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/config/CFMetaData.java
(original)
+++ cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/config/CFMetaData.java
Wed Sep 14 16:02:18 2011
@@ -776,7 +776,7 @@ public final class CFMetaData
         logger.debug("application result is {}", this);
     }
 
-    private static Class<? extends AbstractCompactionStrategy> createCompactionSrategy(String
className) throws ConfigurationException
+    public static Class<? extends AbstractCompactionStrategy> createCompactionSrategy(String
className) throws ConfigurationException
     {
         className = className.contains(".") ? className : "org.apache.cassandra.db.compaction."
+ className;
         try

Modified: cassandra/branches/cassandra-1.0.0/tools/stress/src/org/apache/cassandra/stress/Session.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0.0/tools/stress/src/org/apache/cassandra/stress/Session.java?rev=1170700&r1=1170699&r2=1170700&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0.0/tools/stress/src/org/apache/cassandra/stress/Session.java
(original)
+++ cassandra/branches/cassandra-1.0.0/tools/stress/src/org/apache/cassandra/stress/Session.java
Wed Sep 14 16:02:18 2011
@@ -25,7 +25,9 @@ import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.db.compaction.AbstractCompactionStrategy;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.TypeParser;
 import org.apache.commons.cli.*;
@@ -86,6 +88,7 @@ public class Session implements Serializ
         availableOptions.addOption("T",  "send-to",              true,   "Send this as a
request to the stress daemon at specified address.");
         availableOptions.addOption("I",  "compression",          true,   "Specify the compression
to use for sstable, default:no compression");
         availableOptions.addOption("Q",  "query-names",          true,   "Comma-separated
list of column names to retrieve from each row.");
+        availableOptions.addOption("Z",  "compaction-strategy",  true,   "CompactionStrategy
to use.");
     }
 
     private int numKeys          = 1000 * 1000;
@@ -102,6 +105,7 @@ public class Session implements Serializ
     private int port             = 9160;
     private int superColumns     = 1;
     private String compression   = null;
+    private String compactionStrategy = null;
 
     private int progressInterval  = 10;
     private int keysPerCall       = 1000;
@@ -301,6 +305,22 @@ public class Session implements Serializ
             {
                 columnNames = null;
             }
+
+            if (cmd.hasOption("Z"))
+            {
+                compactionStrategy = cmd.getOptionValue("Z");
+
+                try
+                {
+                    // validate compaction strategy class
+                    CFMetaData.createCompactionSrategy(compactionStrategy);
+                }
+                catch (ConfigurationException e)
+                {
+                    System.err.println(e.getMessage());
+                    System.exit(1);
+                }
+            }
         }
         catch (ParseException e)
         {
@@ -483,6 +503,14 @@ public class Session implements Serializ
             keyspace.setStrategy_options(replicationStrategyOptions);
         }
 
+        if (compactionStrategy != null)
+        {
+            standardCfDef.setCompaction_strategy(compactionStrategy);
+            superCfDef.setCompaction_strategy(compactionStrategy);
+            counterCfDef.setCompaction_strategy(compactionStrategy);
+            counterSuperCfDef.setCompaction_strategy(compactionStrategy);
+        }
+
         keyspace.setCf_defs(new ArrayList<CfDef>(Arrays.asList(standardCfDef, superCfDef,
counterCfDef, counterSuperCfDef)));
 
         Cassandra.Client client = getClient(false);



Mime
View raw message