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: ninja fix profile param for user command to required, and print required fields first
Date Thu, 11 Sep 2014 05:36:24 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 530c9f52c -> 73b2dcc16
  refs/heads/trunk 51a6f0f7f -> 1963b7f03


cassandra-stress: ninja fix profile param for user command to required, and print required
fields first


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

Branch: refs/heads/cassandra-2.1
Commit: 73b2dcc165155fd90ecc978c7281276e536d317d
Parents: 530c9f5
Author: Benedict Elliott Smith <benedict@apache.org>
Authored: Thu Sep 11 12:35:29 2014 +0700
Committer: Benedict Elliott Smith <benedict@apache.org>
Committed: Thu Sep 11 12:35:29 2014 +0700

----------------------------------------------------------------------
 .../cassandra/stress/settings/GroupedOptions.java   | 16 ++++++++++++++++
 .../cassandra/stress/settings/OptionSimple.java     |  5 +++++
 .../stress/settings/SettingsCommandPreDefined.java  |  6 ++----
 .../settings/SettingsCommandPreDefinedMixed.java    |  7 ++-----
 .../stress/settings/SettingsCommandUser.java        |  7 +++++--
 5 files changed, 30 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/73b2dcc1/tools/stress/src/org/apache/cassandra/stress/settings/GroupedOptions.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/GroupedOptions.java b/tools/stress/src/org/apache/cassandra/stress/settings/GroupedOptions.java
index d0e63b0..8bbba15 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/GroupedOptions.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/GroupedOptions.java
@@ -26,6 +26,8 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import com.google.common.collect.ImmutableList;
+
 public abstract class GroupedOptions
 {
 
@@ -112,6 +114,20 @@ public abstract class GroupedOptions
         }
     }
 
+    public static List<? extends Option> merge(List<? extends Option> ... optionss)
+    {
+        ImmutableList.Builder<Option> builder = ImmutableList.builder();
+        for (List<? extends Option> options : optionss)
+            for (Option option : options)
+                if (option instanceof OptionSimple && ((OptionSimple) option).isRequired())
+                    builder.add(option);
+        for (List<? extends Option> options : optionss)
+            for (Option option : options)
+                if (!(option instanceof OptionSimple && ((OptionSimple) option).isRequired()))
+                    builder.add(option);
+        return builder.build();
+    }
+
     public static String formatLong(String longDisplay, String description)
     {
         return String.format("%-40s %s", longDisplay, description);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/73b2dcc1/tools/stress/src/org/apache/cassandra/stress/settings/OptionSimple.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/OptionSimple.java b/tools/stress/src/org/apache/cassandra/stress/settings/OptionSimple.java
index 71c1ffe..ba26c2a 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/OptionSimple.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/OptionSimple.java
@@ -88,6 +88,11 @@ class OptionSimple extends Option implements Serializable
         return value != null;
     }
 
+    public boolean isRequired()
+    {
+        return required;
+    }
+
     public boolean present()
     {
         return value != null || defaultValue != null;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/73b2dcc1/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 ab60dd1..8583e90 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefined.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefined.java
@@ -22,6 +22,7 @@ package org.apache.cassandra.stress.settings;
 
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
@@ -103,10 +104,7 @@ public class SettingsCommandPreDefined extends SettingsCommand
         @Override
         public List<? extends Option> options()
         {
-            final List<Option> options = new ArrayList<>();
-            options.addAll(parent.options());
-            options.add(add);
-            return options;
+            return merge(parent.options(), Arrays.asList(add, keysize));
         }
 
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/73b2dcc1/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 dc45b89..6beb55f 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefinedMixed.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefinedMixed.java
@@ -22,6 +22,7 @@ package org.apache.cassandra.stress.settings;
 
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
@@ -108,11 +109,7 @@ public class SettingsCommandPreDefinedMixed extends SettingsCommandPreDefined
         @Override
         public List<? extends Option> options()
         {
-            final List<Option> options = new ArrayList<>();
-            options.add(clustering);
-            options.add(probabilities);
-            options.addAll(super.options());
-            return options;
+            return merge(Arrays.asList(clustering, probabilities), super.options());
         }
 
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/73b2dcc1/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 2e30d62..a6dad35 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java
@@ -23,6 +23,9 @@ package org.apache.cassandra.stress.settings;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 
@@ -88,13 +91,13 @@ public class SettingsCommandUser extends SettingsCommand
             this.parent = parent;
         }
         final OptionDistribution clustering = new OptionDistribution("clustering=", "gaussian(1..10)",
"Distribution clustering runs of operations of the same kind");
-        final OptionSimple profile = new OptionSimple("profile=", ".*", null, "Specify the
path to a yaml cql3 profile", false);
+        final OptionSimple profile = new OptionSimple("profile=", ".*", null, "Specify the
path to a yaml cql3 profile", true);
         final OptionAnyProbabilities ops = new OptionAnyProbabilities("ops", "Specify the
ratios for inserts/queries to perform; e.g. ops(insert=2,<query1>=1) will perform 2
inserts for each query1");
 
         @Override
         public List<? extends Option> options()
         {
-            return ImmutableList.<Option>builder().add(ops, clustering, profile).addAll(parent.options()).build();
+            return merge(Arrays.asList(ops, profile, clustering), parent.options());
         }
     }
 


Mime
View raw message