Repository: cassandra Updated Branches: refs/heads/cassandra-2.1 6bff5a331 -> b3573f3d3
Better error checking of stress profile patch by tjake; reviewed by belliottsmith for CASSANDRA-7716 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b3573f3d Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b3573f3d Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b3573f3d Branch: refs/heads/cassandra-2.1 Commit: b3573f3d3bc8ab18ee82534625868dae12f7234c Parents: 6bff5a3 Author: Jake Luciani <[email protected]> Authored: Mon Sep 15 12:20:43 2014 -0400 Committer: Jake Luciani <[email protected]> Committed: Mon Sep 15 12:20:43 2014 -0400 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/stress/StressProfile.java | 29 ++++++++++++++++---- .../settings/OptionRatioDistribution.java | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/b3573f3d/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 4c0dbf9..8fe4253 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.1.1 + * Add better error checking of new stress profile (CASSANDRA-7716) * Use ThreadLocalRandom and remove FBUtilities.threadLocalRandom (CASSANDRA-7934) * Prevent operator mistakes due to simultaneous bootstrap (CASSANDRA-7069) * cassandra-stress supports whitelist mode for node config (CASSANDRA-7658) http://git-wip-us.apache.org/repos/asf/cassandra/blob/b3573f3d/tools/stress/src/org/apache/cassandra/stress/StressProfile.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/StressProfile.java b/tools/stress/src/org/apache/cassandra/stress/StressProfile.java index bd873e8..b0a149c 100644 --- a/tools/stress/src/org/apache/cassandra/stress/StressProfile.java +++ b/tools/stress/src/org/apache/cassandra/stress/StressProfile.java @@ -31,6 +31,7 @@ import org.apache.cassandra.cql3.QueryProcessor; import org.apache.cassandra.cql3.statements.CreateKeyspaceStatement; import org.apache.cassandra.exceptions.RequestValidationException; +import org.apache.cassandra.exceptions.SyntaxException; import org.apache.cassandra.stress.generate.Distribution; import org.apache.cassandra.stress.generate.DistributionFactory; import org.apache.cassandra.stress.generate.PartitionGenerator; @@ -124,8 +125,15 @@ public class StressProfile implements Serializable if (keyspaceCql != null && keyspaceCql.length() > 0) { - String name = ((CreateKeyspaceStatement) QueryProcessor.parseStatement(keyspaceCql)).keyspace(); - assert name.equalsIgnoreCase(keyspaceName) : "Name in keyspace_definition doesn't match keyspace property: '" + name + "' != '" + keyspaceName + "'"; + try + { + String name = ((CreateKeyspaceStatement) QueryProcessor.parseStatement(keyspaceCql)).keyspace(); + assert name.equalsIgnoreCase(keyspaceName) : "Name in keyspace_definition doesn't match keyspace property: '" + name + "' != '" + keyspaceName + "'"; + } + catch (SyntaxException e) + { + throw new IllegalArgumentException("There was a problem parsing the keyspace cql: " + e.getMessage()); + } } else { @@ -134,8 +142,15 @@ public class StressProfile implements Serializable if (tableCql != null && tableCql.length() > 0) { - String name = CFMetaData.compile(tableCql, keyspaceName).cfName; - assert name.equalsIgnoreCase(tableName) : "Name in table_definition doesn't match table property: '" + name + "' != '" + tableName + "'"; + try + { + String name = CFMetaData.compile(tableCql, keyspaceName).cfName; + assert name.equalsIgnoreCase(tableName) : "Name in table_definition doesn't match table property: '" + name + "' != '" + tableName + "'"; + } + catch (RuntimeException e) + { + throw new IllegalArgumentException("There was a problem parsing the table cql: " + e.getCause().getMessage()); + } } else { @@ -217,6 +232,9 @@ public class StressProfile implements Serializable .getKeyspace(keyspaceName) .getTable(tableName); + if (metadata == null) + throw new RuntimeException("Unable to find table " + keyspaceName + "." + tableName); + //Fill in missing column configs for (ColumnMetadata col : metadata.getColumns()) { @@ -391,9 +409,10 @@ public class StressProfile implements Serializable private static <E> E select(E first, String key, String defValue, Map<String, String> map, Function<String, E> builder) { String val = map.remove(key); + if (first != null) return first; - if (val != null) + if (val != null && val.trim().length() > 0) return builder.apply(val); return builder.apply(defValue); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/b3573f3d/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 aacb616..756536f 100644 --- a/tools/stress/src/org/apache/cassandra/stress/settings/OptionRatioDistribution.java +++ b/tools/stress/src/org/apache/cassandra/stress/settings/OptionRatioDistribution.java @@ -90,7 +90,7 @@ public class OptionRatioDistribution extends Option { OptionRatioDistribution opt = new OptionRatioDistribution("", "", "", true); if (!opt.accept(spec)) - throw new IllegalArgumentException(); + throw new IllegalArgumentException("Invalid ratio definition: "+spec); return opt.get(); }
