ifesdjeen commented on code in PR #3196:
URL: https://github.com/apache/cassandra/pull/3196#discussion_r1560745961
##########
test/distributed/org/apache/cassandra/distributed/test/log/PlacementSimulator.java:
##########
@@ -985,20 +977,84 @@ public Diff<T> invert()
}
}
- public static String diffsToString(Map<Range, Diff<Node>> placements)
+ public static Diff<Replica> additionsAndTransientToFull(Diff<Replica>
unfiltered)
+ {
+ if (unfiltered.additions.isEmpty())
+ return null;
+ List<Replica> additions = new ArrayList<>(unfiltered.additions.size());
+ List<Replica> removals = new ArrayList<>(unfiltered.additions.size());
+ for (Replica added : unfiltered.additions)
+ {
+ // Include any new FULL replicas here. If there exists the removal
of a corresponding Transient
+ // replica (i.e. a switch from T -> F), add that too. We want T ->
F transitions to happen early
+ // in a multi-step operation, at the same time as new write
replicas are added.
+ if (added.isFull())
+ {
+ additions.add(added);
+ for (Replica removed : unfiltered.removals)
Review Comment:
I thought maybe something like this:
```
if (added.isFull())
{
additions.add(added);
Optional<Replica> removed = unfiltered.removals.stream()
.filter(r ->
r.isTransient() && r.node().equals(added.node()))
.findFirst();
if (removed.isPresent())
removals.add(removed.get());
}
else
{
// Conversely, when a replica transitions from F -> T, it's
enacted late in a multi-step operation.
// So only include TRANSIENT additions if there is no
removal of a corresponding FULL replica.
boolean include = unfiltered.removals.stream()
.noneMatch(removed ->
removed.node().equals(added.node())
&& removed.isFull());
if (include)
additions.add(added);
}
```
--
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]