mirror of https://github.com/apache/cassandra
cassandra-stress: ninja fix profile param for user command to required, and print required fields first
This commit is contained in:
parent
530c9f52c3
commit
73b2dcc165
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue