Elffuss BraidHub

kikocis/java-driver public

Switch parameter order in constant specex policy.

For consistency with percentile-based one, and because having the delay
first feels more natural.
Changeset12616ebdc305199270a87e7d6de6b6970e904bc8deff3c6c0aa7b44a4022df4b
Authorolim7t <omichallat+github@gmail.com> · 2015-04-29 19:00 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2015-04-29 19:00 +02:00
Parents77ca7d6c3905

Browse the files at this changeset

2 files changed

modified driver-core/src/main/java/com/datastax/driver/core/policies/ConstantSpeculativeExecutionPolicy.java +7 −7
@@ -33,18 +33,18 @@
3333 /**
3434 * Builds a new instance.
3535 *
36- * @param maxSpeculativeExecutions the number of speculative executions. Must be strictly positive.
3736 * @param constantDelayMillis the delay between each speculative execution. Must be strictly positive.
38- *
37+ * @param maxSpeculativeExecutions the number of speculative executions. Must be strictly positive.
38+ *
3939 * @throws IllegalArgumentException if one of the arguments does not respect the preconditions above.
4040 */
41- public ConstantSpeculativeExecutionPolicy(final int maxSpeculativeExecutions, final long constantDelayMillis) {
42- this.maxSpeculativeExecutions = maxSpeculativeExecutions;
43- this.constantDelayMillis = constantDelayMillis;
44- Preconditions.checkArgument(maxSpeculativeExecutions > 0,
45- "number of speculative executions must be strictly positive (was %d)", maxSpeculativeExecutions);
41+ public ConstantSpeculativeExecutionPolicy(final long constantDelayMillis, final int maxSpeculativeExecutions) {
4642 Preconditions.checkArgument(constantDelayMillis > 0,
4743 "delay must be strictly positive (was %d)", constantDelayMillis);
44+ Preconditions.checkArgument(maxSpeculativeExecutions > 0,
45+ "number of speculative executions must be strictly positive (was %d)", maxSpeculativeExecutions);
46+ this.constantDelayMillis = constantDelayMillis;
47+ this.maxSpeculativeExecutions = maxSpeculativeExecutions;
4848 }
4949
5050 @Override
modified driver-core/src/test/java/com/datastax/driver/core/SpeculativeExecutionTest.java +1 −1
@@ -52,7 +52,7 @@
5252 cluster = Cluster.builder()
5353 .addContactPoint(CCMBridge.ipOfNode(2))
5454 .withLoadBalancingPolicy(loadBalancingPolicy)
55- .withSpeculativeExecutionPolicy(new ConstantSpeculativeExecutionPolicy(1, speculativeExecutionDelay))
55+ .withSpeculativeExecutionPolicy(new ConstantSpeculativeExecutionPolicy(speculativeExecutionDelay, 1))
5656 .withQueryOptions(new QueryOptions().setDefaultIdempotence(true))
5757 .withRetryPolicy(new CustomRetryPolicy())
5858 .build();