mjsax commented on code in PR #23969:
URL: https://github.com/apache/kafka/pull/23969#discussion_r4594348595
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/AssignmentRefinerImpl.java:
##########
@@ -1411,6 +1388,40 @@ private record StandbyConflicts(
) {
}
+ /**
+ * The members the target assignment names as standby holders of each
stateful task.
+ *
+ * <p>The lookup is built from the target assignment on the first {@link
#holdersOf} call, which walks every target
+ * standby. Only a task that diverges from its target owner reads it -- to
rank the copies to promote, and to find
+ * the placement a borrowed migration holds back -- so a derivation of a
group that has converged never pays for
+ * the walk. The lookup is reachable only through {@link #holdersOf}, so
every caller sees it built. It lives for
+ * one derivation, on one thread.
+ */
+ static final class TargetStandbyHolders {
+
+ private final Map<String, TasksTuple> targetAssignment;
+ private final SortedMap<String, ConfiguredSubtopology> subtopologies;
+ private Map<TaskId, Set<String>> holders;
+
+ TargetStandbyHolders(
+ final Map<String, TasksTuple> targetAssignment,
+ final SortedMap<String, ConfiguredSubtopology> subtopologies
+ ) {
+ this.targetAssignment = targetAssignment;
+ this.subtopologies = subtopologies;
+ }
+
+ /**
+ * The members the target assignment names as standby holders of the
task; empty if it names none.
+ */
+ Set<String> holdersOf(final TaskId task) {
+ if (holders == null) {
+ holders = statefulStandbyHolders(targetAssignment,
subtopologies);
Review Comment:
Given that we embed this one inside `TargetStandbyHolders`, it would be good
to move the existing helper method into `TargetStandbyHolders` itself.
--
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]