belliottsmith commented on code in PR #28:
URL: https://github.com/apache/cassandra-accord/pull/28#discussion_r1091817355
##########
accord-core/src/test/java/accord/burn/random/SegmentedIntRange.java:
##########
@@ -0,0 +1,23 @@
+package accord.burn.random;
+
+import java.util.Objects;
+import java.util.Random;
+
+public class SegmentedIntRange implements RandomInt
+{
+ private final RandomInt small, large;
+ private final Decision largeDecision;
+
+ public SegmentedIntRange(RandomInt small, RandomInt large, Decision
largeDecision) {
+ this.small = Objects.requireNonNull(small);
+ this.large = Objects.requireNonNull(large);
+ this.largeDecision = Objects.requireNonNull(largeDecision);
Review Comment:
chooseLargeChance?
##########
accord-core/src/test/java/accord/burn/random/SegmentedIntRange.java:
##########
@@ -0,0 +1,23 @@
+package accord.burn.random;
+
+import java.util.Objects;
+import java.util.Random;
+
+public class SegmentedIntRange implements RandomInt
+{
+ private final RandomInt small, large;
+ private final Decision largeDecision;
+
+ public SegmentedIntRange(RandomInt small, RandomInt large, Decision
largeDecision) {
Review Comment:
braces/newlines
##########
accord-core/src/test/java/accord/impl/basic/DelayedExecutorService.java:
##########
@@ -0,0 +1,107 @@
+package accord.impl.basic;
+
+import accord.burn.random.Decision;
+import accord.burn.random.IntRange;
+import accord.burn.random.RandomInt;
+import accord.burn.random.SegmentedIntRange;
+import org.apache.cassandra.concurrent.FutureTask;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.AbstractExecutorService;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+public class DelayedExecutorService extends AbstractExecutorService
Review Comment:
Perhaps make clearer this isn't a real executor service? Perhaps
`SimulatedExecutorService` or some other better name.
##########
accord-core/src/test/java/accord/burn/random/IntRange.java:
##########
@@ -0,0 +1,21 @@
+package accord.burn.random;
+
+import java.util.Random;
+
+public class IntRange implements RandomInt
+{
+ private final int min, upperBound;
Review Comment:
upperBound is confusing. Perhaps `maxDelta`, or `range`?
##########
accord-core/src/test/java/accord/impl/basic/DelayedExecutorService.java:
##########
@@ -0,0 +1,107 @@
+package accord.impl.basic;
+
+import accord.burn.random.Decision;
+import accord.burn.random.IntRange;
+import accord.burn.random.RandomInt;
+import accord.burn.random.SegmentedIntRange;
+import org.apache.cassandra.concurrent.FutureTask;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.AbstractExecutorService;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+public class DelayedExecutorService extends AbstractExecutorService
+{
+ private final PendingQueue pending;
+ private final Random random;
+ private final RandomInt jitterInNano;
+
+ public DelayedExecutorService(PendingQueue pending, Random random)
+ {
+ this.pending = pending;
+ this.random = random;
+ this.jitterInNano = new SegmentedIntRange(
+ new IntRange(microToNanos(0), microToNanos(50)),
+ new IntRange(microToNanos(50), msToNanos(5)),
+ // this is different from Apache Cassandra Simulator as this
is computed differently for each executor
Review Comment:
Ideally it would probably be per-node for both, but not super important. I
thought the C* simulator also used the random walk behaviour for jitter, but it
looks like it doesn't. It would be good if both did, to simulate nodes becoming
unhealthy for a period, then restoring behaviour. But not essential for this
patch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]