belliottsmith commented on code in PR #2056:
URL: https://github.com/apache/cassandra/pull/2056#discussion_r1066316978
##########
test/simulator/main/org/apache/cassandra/simulator/paxos/AbstractPairOfSequencesPaxosSimulation.java:
##########
@@ -124,101 +122,25 @@ public ActionPlan plan()
plan = plan.encapsulate(ActionPlan.setUpTearDown(
ActionList.of(
- cluster.stream().map(i -> simulated.run("Insert Partitions",
i, executeForPrimaryKeys(preInsertStmt(), primaryKeys)))
- ).andThen(
- // TODO (now): this is temporary until we have correct epoch
handling
- ActionList.of(
- cluster.stream().map(i -> simulated.run("Create Accord
Epoch", i, () -> AccordService.instance().createEpochFromConfigUnsafe()))
- )
-// ).andThen(
-// // TODO (now): this is temporary until we have
parameterisation of simulation
-// ActionList.of(
-// cluster.stream().map(i -> simulated.run("Disable Accord
Cache", i, () -> AccordService.instance.setCacheSize(0)))
-// )
+ cluster.stream().map(i -> simulated.run("Insert Partitions",
i, executeForPrimaryKeys(preInsertStmt(), primaryKeys))),
+ cluster.stream().map(i -> simulated.run("Create Accord Epoch",
i, () -> AccordService.instance().createEpochFromConfigUnsafe()))
),
ActionList.of(
cluster.stream().map(i ->
SimulatedActionTask.unsafeTask("Shutdown " + i.broadcastAddress(), RELIABLE,
RELIABLE_NO_TIMEOUTS, simulated, i, i::shutdown))
)
));
- final int nodes = cluster.size();
- for (int primaryKey : primaryKeys)
- historyCheckers.add(new HistoryChecker(primaryKey));
-
- List<Supplier<Action>> primaryKeyActions = new ArrayList<>();
- for (int pki = 0 ; pki < primaryKeys.length ; ++pki)
- {
- int primaryKey = primaryKeys[pki];
- HistoryChecker historyChecker = historyCheckers.get(pki);
- Supplier<Action> supplier = new Supplier<Action>()
- {
- int i = 0;
-
- @Override
- public Action get()
- {
- int node = simulated.random.uniform(1, nodes + 1);
- IInvokableInstance instance = cluster.get(node);
- switch (serialConsistency)
- {
- default: throw new AssertionError();
- case LOCAL_SERIAL:
- if (simulated.snitch.dcOf(node) > 0)
- {
- // perform some queries against these nodes
but don't expect them to be linearizable
- return nonVerifying(i++, instance, primaryKey,
historyChecker);
- }
- case SERIAL:
- return simulated.random.decide(readRatio)
- ? verifying(i++, instance, primaryKey,
historyChecker)
- : modifying(i++, instance, primaryKey,
historyChecker);
- }
- }
-
- @Override
- public String toString()
- {
- return Integer.toString(primaryKey);
- }
- };
-
- final ActionListener listener = debug.debug(PARTITION,
simulated.time, cluster, KEYSPACE, primaryKey);
- if (listener != null)
- {
- Supplier<Action> wrap = supplier;
- supplier = new Supplier<Action>()
- {
- @Override
- public Action get()
- {
- Action action = wrap.get();
- action.register(listener);
- return action;
- }
-
- @Override
- public String toString()
- {
- return wrap.toString();
- }
- };
- }
-
- primaryKeyActions.add(supplier);
- }
+ BiFunction<SimulatedSystems, int[], Supplier<Action>> factory =
actionFactory();
List<Integer> available = IntStream.range(0,
primaryKeys.length).boxed().collect(Collectors.toList());
Action stream = Actions.infiniteStream(concurrency, new
Supplier<Action>() {
@Override
public Action get()
{
- int i = simulated.random.uniform(0, available.size());
- int next = available.get(i);
- available.set(i, available.get(available.size() - 1));
- available.remove(available.size() - 1);
+ int[] partitions = consume(simulated.random, available);
Review Comment:
Sure, sounds good
--
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]