markap14 commented on PR #110:
URL: https://github.com/apache/nifi-api/pull/110#issuecomment-6172470779
[Claude Opus 5.5] I believe this change is correct, but I think there's a
simpler way to fix it. When called on the root group, `getSourceProcessors` and
`getNonSourceProcessors` already return the right processors from the entire
tree, classified against every connection in the flow. The port, Remote Process
Group, and stateless group start methods also accept
`ComponentHierarchyScope.INCLUDE_CHILD_GROUPS`. So we can drop the recursion
completely. That removes the private overloads, the ID set passed down the
tree, and the negated `contains` checks, and each processor is visited exactly
once:
```java
protected CompletableFuture<Void> stopSourceComponents(final FlowContext
context) {
final List<CompletableFuture<Void>> stopFutures = new ArrayList<>();
for (final ProcessorFacade sourceProcessor :
getSourceProcessors(context.getRootGroup())) {
stopFutures.add(sourceProcessor.getLifecycle().stop());
}
return CompletableFuture.allOf(stopFutures.toArray(new
CompletableFuture[0]));
}
protected CompletableFuture<Void> startNonSourceComponents(final FlowContext
flowContext) {
final ProcessGroupFacade rootGroup = flowContext.getRootGroup();
final List<CompletableFuture<Void>> startFutures = new ArrayList<>();
for (final ProcessorFacade nonSourceProcessor :
getNonSourceProcessors(rootGroup)) {
startFutures.add(nonSourceProcessor.getLifecycle().start());
}
final ProcessGroupLifecycle lifecycle = rootGroup.getLifecycle();
startFutures.add(lifecycle.startPorts(ComponentHierarchyScope.INCLUDE_CHILD_GROUPS));
startFutures.add(lifecycle.startRemoteProcessGroups(ComponentHierarchyScope.INCLUDE_CHILD_GROUPS));
startFutures.add(lifecycle.startStatelessGroups(ComponentHierarchyScope.INCLUDE_CHILD_GROUPS));
return CompletableFuture.allOf(startFutures.toArray(new
CompletableFuture[0]));
}
```
In the framework's `StandaloneProcessGroupLifecycle`, the single root-level
calls behave the same as one call per group, with one exception: groups nested
inside a stateless group. The recursive `startStatelessGroups` call doesn't go
into those. The per-group walk does go into them, and may call `start()` on
them again. So the simpler version is likely more correct in that case as well.
The new tests in this PR should still pass against this version.
--
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]