@@ -197,7 +197,7 @@ void handleRebalanceComplete() {
197197 // we should pause consumer only within the listener since
198198 // before then the assignment has not been updated yet.
199199 // All tasks that are owned by the task manager are ready and do not need to be paused
200- final Set <TopicPartition > partitionsNotToPause = tasks .allNonFailedTasks ()
200+ final Set <TopicPartition > partitionsNotToPause = tasks .allNonFailedInitializedTasks ()
201201 .stream ()
202202 .flatMap (task -> task .inputPartitions ().stream ())
203203 .collect (Collectors .toSet ());
@@ -214,7 +214,7 @@ void handleRebalanceComplete() {
214214 * @throws TaskMigratedException
215215 */
216216 boolean handleCorruption (final Set <TaskId > corruptedTasks ) {
217- final Set <TaskId > activeTasks = new HashSet <>(tasks .activeTaskIds ());
217+ final Set <TaskId > activeTasks = new HashSet <>(tasks .activeInitializedTaskIds ());
218218
219219 // We need to stop all processing, since we need to commit non-corrupted tasks as well.
220220 maybeLockTasks (activeTasks );
@@ -223,7 +223,7 @@ boolean handleCorruption(final Set<TaskId> corruptedTasks) {
223223 final Set <Task > corruptedStandbyTasks = new TreeSet <>(Comparator .comparing (Task ::id ));
224224
225225 for (final TaskId taskId : corruptedTasks ) {
226- final Task task = tasks .task (taskId );
226+ final Task task = tasks .initializedTask (taskId );
227227 if (task .isActive ()) {
228228 corruptedActiveTasks .add (task );
229229 } else {
@@ -237,7 +237,7 @@ boolean handleCorruption(final Set<TaskId> corruptedTasks) {
237237
238238 // We need to commit before closing the corrupted active tasks since this will force the ongoing txn to abort
239239 try {
240- final Collection <Task > tasksToCommit = tasks .allTasksPerId ()
240+ final Collection <Task > tasksToCommit = tasks .allInitializedTasksPerId ()
241241 .values ()
242242 .stream ()
243243 .filter (t -> t .state () == Task .State .RUNNING )
@@ -247,10 +247,10 @@ boolean handleCorruption(final Set<TaskId> corruptedTasks) {
247247 } catch (final TaskCorruptedException e ) {
248248 log .info ("Some additional tasks were found corrupted while trying to commit, these will be added to the " +
249249 "tasks to clean and revive: {}" , e .corruptedTasks ());
250- corruptedActiveTasks .addAll (tasks .tasks (e .corruptedTasks ()));
250+ corruptedActiveTasks .addAll (tasks .initializedTasks (e .corruptedTasks ()));
251251 } catch (final TimeoutException e ) {
252252 log .info ("Hit TimeoutException when committing all non-corrupted tasks, these will be closed and revived" );
253- final Collection <Task > uncorruptedTasks = new HashSet <>(tasks .activeTasks ());
253+ final Collection <Task > uncorruptedTasks = new HashSet <>(tasks .activeInitializedTasks ());
254254 uncorruptedTasks .removeAll (corruptedActiveTasks );
255255 // Those tasks which just timed out can just be closed dirty without marking changelogs as corrupted
256256 closeDirtyAndRevive (uncorruptedTasks , false );
@@ -366,7 +366,7 @@ public void handleAssignment(final Map<TaskId, Set<TopicPartition>> activeTasks,
366366 final Set <Task > tasksToCloseClean = new TreeSet <>(Comparator .comparing (Task ::id ));
367367
368368 final Set <TaskId > tasksToLock =
369- tasks .allTaskIds ().stream ()
369+ tasks .allInitializedTaskIds ().stream ()
370370 .filter (x -> activeTasksToCreate .containsKey (x ) || standbyTasksToCreate .containsKey (x ))
371371 .collect (Collectors .toSet ());
372372
@@ -533,7 +533,7 @@ private void handleRunningAndSuspendedTasks(final Map<TaskId, Set<TopicPartition
533533 final Map <TaskId , Set <TopicPartition >> standbyTasksToCreate ,
534534 final Map <Task , Set <TopicPartition >> tasksToRecycle ,
535535 final Set <Task > tasksToCloseClean ) {
536- for (final Task task : tasks .allNonFailedTasks ()) {
536+ for (final Task task : tasks .allNonFailedInitializedTasks ()) {
537537 if (!task .isActive ()) {
538538 throw new IllegalStateException ("Standby tasks should only be managed by the state updater, " +
539539 "but standby task " + task .id () + " is managed by the stream thread" );
@@ -733,7 +733,7 @@ private Map<TaskId, Set<TopicPartition>> pendingTasksToCreate(final Map<TaskId,
733733 while (iter .hasNext ()) {
734734 final Map .Entry <TaskId , Set <TopicPartition >> entry = iter .next ();
735735 final TaskId taskId = entry .getKey ();
736- final boolean taskIsOwned = tasks .allTaskIds ().contains (taskId )
736+ final boolean taskIsOwned = tasks .allInitializedTaskIds ().contains (taskId )
737737 || (stateUpdater .tasks ().stream ().anyMatch (task -> task .id ().equals (taskId )));
738738 if (taskId .topologyName () != null && !taskIsOwned && !topologyMetadata .namedTopologiesView ().contains (taskId .topologyName ())) {
739739 log .info ("Cannot create the assigned task {} since it's topology name cannot be recognized, will put it " +
@@ -1079,7 +1079,7 @@ void handleRevocation(final Collection<TopicPartition> revokedPartitions) {
10791079 e .corruptedTasks ());
10801080
10811081 // If we hit a TaskCorruptedException it must be EOS, just handle the cleanup for those corrupted tasks right here
1082- dirtyTasks .addAll (tasks .tasks (e .corruptedTasks ()));
1082+ dirtyTasks .addAll (tasks .initializedTasks (e .corruptedTasks ()));
10831083 closeDirtyAndRevive (dirtyTasks , true );
10841084 } catch (final TimeoutException e ) {
10851085 log .warn ("Timed out while trying to commit all tasks during revocation, these will be cleaned and revived" );
@@ -1193,8 +1193,8 @@ void handleLostAll() {
11931193 }
11941194
11951195 private void closeRunningTasksDirty () {
1196- final Set <Task > allTask = tasks .allTasks ();
1197- final Set <TaskId > allTaskIds = tasks .allTaskIds ();
1196+ final Set <Task > allTask = tasks .allInitializedTasks ();
1197+ final Set <TaskId > allTaskIds = tasks .allInitializedTaskIds ();
11981198 maybeLockTasks (allTaskIds );
11991199 for (final Task task : allTask ) {
12001200 // Even though we've apparently dropped out of the group, we can continue safely to maintain our
@@ -1413,10 +1413,10 @@ void shutdown(final boolean clean) {
14131413
14141414 // TODO: change type to `StreamTask`
14151415 final Set <Task > activeTasks = new TreeSet <>(Comparator .comparing (Task ::id ));
1416- activeTasks .addAll (tasks .activeTasks ());
1416+ activeTasks .addAll (tasks .activeInitializedTasks ());
14171417 // TODO: change type to `StandbyTask`
14181418 final Set <Task > standbyTasks = new TreeSet <>(Comparator .comparing (Task ::id ));
1419- standbyTasks .addAll (tasks .standbyTasks ());
1419+ standbyTasks .addAll (tasks .standbyInitializedTasks ());
14201420
14211421 final Set <Task > pendingActiveTasks = tasks .drainPendingActiveTasksToInit ();
14221422 activeTasks .addAll (pendingActiveTasks );
@@ -1670,7 +1670,7 @@ Map<TaskId, Task> allTasks() {
16701670 // not bothering with an unmodifiable map, since the tasks themselves are mutable, but
16711671 // if any outside code modifies the map or the tasks, it would be a severe transgression.
16721672 final Map <TaskId , Task > ret = stateUpdater .tasks ().stream ().collect (Collectors .toMap (Task ::id , x -> x ));
1673- ret .putAll (tasks .allTasksPerId ());
1673+ ret .putAll (tasks .allInitializedTasksPerId ());
16741674 ret .putAll (tasks .pendingTasksToInit ().stream ().collect (Collectors .toMap (Task ::id , x -> x )));
16751675 return ret ;
16761676 }
@@ -1683,19 +1683,19 @@ Map<TaskId, Task> allTasks() {
16831683 Map <TaskId , Task > allRunningTasks () {
16841684 // not bothering with an unmodifiable map, since the tasks themselves are mutable, but
16851685 // if any outside code modifies the map or the tasks, it would be a severe transgression.
1686- return tasks .allTasksPerId ();
1686+ return tasks .allInitializedTasksPerId ();
16871687 }
16881688
16891689 Set <Task > readOnlyAllTasks () {
16901690 // not bothering with an unmodifiable map, since the tasks themselves are mutable, but
16911691 // if any outside code modifies the map or the tasks, it would be a severe transgression.
16921692 final HashSet <Task > ret = new HashSet <>(stateUpdater .tasks ());
1693- ret .addAll (tasks .allTasks ());
1693+ ret .addAll (tasks .allInitializedTasks ());
16941694 return Collections .unmodifiableSet (ret );
16951695 }
16961696
16971697 Map <TaskId , Task > notPausedTasks () {
1698- return Collections .unmodifiableMap (tasks .allTasks ()
1698+ return Collections .unmodifiableMap (tasks .allInitializedTasks ()
16991699 .stream ()
17001700 .filter (t -> !topologyMetadata .isPaused (t .id ().topologyName ()))
17011701 .collect (Collectors .toMap (Task ::id , v -> v )));
@@ -1721,7 +1721,7 @@ private Stream<Task> activeTaskStream() {
17211721 }
17221722
17231723 private Stream <Task > activeRunningTaskStream () {
1724- return tasks .allTasks ().stream ().filter (Task ::isActive );
1724+ return tasks .allInitializedTasks ().stream ().filter (Task ::isActive );
17251725 }
17261726
17271727 Map <TaskId , Task > standbyTaskMap () {
@@ -1733,23 +1733,23 @@ private List<Task> standbyTaskIterable() {
17331733 }
17341734
17351735 private Stream <Task > standbyTaskStream () {
1736- final Stream <Task > standbyTasksInTaskRegistry = tasks .allTasks ().stream ().filter (t -> !t .isActive ());
1736+ final Stream <Task > standbyTasksInTaskRegistry = tasks .allInitializedTasks ().stream ().filter (t -> !t .isActive ());
17371737 return Stream .concat (
17381738 stateUpdater .standbyTasks ().stream (),
17391739 standbyTasksInTaskRegistry
17401740 );
17411741 }
17421742 // For testing only.
17431743 int commitAll () {
1744- return commit (tasks .allTasks ());
1744+ return commit (tasks .allInitializedTasks ());
17451745 }
17461746
17471747 /**
17481748 * Resumes polling in the main consumer for all partitions for which
17491749 * the corresponding record queues have capacity (again).
17501750 */
17511751 public void resumePollingForPartitionsWithAvailableSpace () {
1752- for (final Task t : tasks .activeTasks ()) {
1752+ for (final Task t : tasks .activeInitializedTasks ()) {
17531753 t .resumePollingForPartitionsWithAvailableSpace ();
17541754 }
17551755 }
@@ -1758,7 +1758,7 @@ public void resumePollingForPartitionsWithAvailableSpace() {
17581758 * Fetches up-to-date lag information from the consumer.
17591759 */
17601760 public void updateLags () {
1761- for (final Task t : tasks .activeTasks ()) {
1761+ for (final Task t : tasks .activeInitializedTasks ()) {
17621762 t .updateLags ();
17631763 }
17641764 }
@@ -1808,7 +1808,7 @@ void maybeInitTaskTimeoutsOrThrow(
18081808 }
18091809
18101810 private Task getActiveTask (final TopicPartition partition ) {
1811- final Task activeTask = tasks .activeTasksForInputPartition (partition );
1811+ final Task activeTask = tasks .activeInitializedTasksForInputPartition (partition );
18121812
18131813 if (activeTask == null ) {
18141814 log .error ("Unable to locate active task for received-record partition {}. Current tasks: {}" ,
@@ -1912,7 +1912,7 @@ private int commitTasksAndMaybeUpdateCommittableOffsets(final Collection<Task> t
19121912 }
19131913
19141914 public void updateTaskEndMetadata (final TopicPartition topicPartition , final Long offset ) {
1915- for (final Task task : tasks .activeTasks ()) {
1915+ for (final Task task : tasks .activeInitializedTasks ()) {
19161916 if (task instanceof StreamTask ) {
19171917 if (task .inputPartitions ().contains (topicPartition )) {
19181918 ((StreamTask ) task ).updateEndOffsets (topicPartition , offset );
@@ -1943,7 +1943,7 @@ void maybeCloseTasksFromRemovedTopologies(final Set<String> currentNamedTopologi
19431943 try {
19441944 final Set <Task > activeTasksToRemove = new TreeSet <>(Comparator .comparing (Task ::id ));
19451945 final Set <Task > standbyTasksToRemove = new TreeSet <>(Comparator .comparing (Task ::id ));
1946- for (final Task task : tasks .allTasks ()) {
1946+ for (final Task task : tasks .allInitializedTasks ()) {
19471947 if (!currentNamedTopologies .contains (task .id ().topologyName ())) {
19481948 if (task .isActive ()) {
19491949 activeTasksToRemove .add (task );
@@ -2032,7 +2032,7 @@ public String toString(final String indent) {
20322032 stringBuilder .append ("TaskManager\n " );
20332033 stringBuilder .append (indent ).append ("\t MetadataState:\n " );
20342034 stringBuilder .append (indent ).append ("\t Tasks:\n " );
2035- for (final Task task : tasks .allTasks ()) {
2035+ for (final Task task : tasks .allInitializedTasks ()) {
20362036 stringBuilder .append (indent )
20372037 .append ("\t \t " )
20382038 .append (task .id ())
0 commit comments