bobpaulin commented on code in PR #11872:
URL: https://github.com/apache/nifi/pull/11872#discussion_r4606471432
##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/connector/StandardConnectorNode.java:
##########
@@ -3051,6 +3909,57 @@ private List<DescribedValue> fetchAllowableValues(final
String stepName, final S
return allowableValues;
}
+ /**
+ * Progress through a pending flow evolution. The drain status is kept
when the evolution fails, so a retry knows whether
+ * this node has already drained the outgoing flow.
+ *
+ * @param drainStatus {@link FlowEvolutionStatus#INACTIVE} when no
evolution is pending, otherwise this node's evolve-drain progress
+ * @param failureExplanation why the evolution failed, or null when it has
not failed
+ */
+ private record FlowEvolutionProgress(FlowEvolutionStatus drainStatus,
String failureExplanation) {
+ private static final FlowEvolutionProgress NONE = new
FlowEvolutionProgress(FlowEvolutionStatus.INACTIVE, null);
+
+ FlowEvolutionStatus reportedStatus() {
+ return hasFailed() ? FlowEvolutionStatus.FAILED : drainStatus;
+ }
+
+ boolean isDrainComplete() {
+ return drainStatus == FlowEvolutionStatus.EVOLVE_DRAIN_COMPLETE;
+ }
+
+ boolean hasFailed() {
+ return failureExplanation != null;
+ }
+
+ FlowEvolutionProgress withDrainStatus(final FlowEvolutionStatus
status) {
+ return new FlowEvolutionProgress(status, failureExplanation);
+ }
+
+ FlowEvolutionProgress replaceDrainStatus(final FlowEvolutionStatus
expected, final FlowEvolutionStatus replacement) {
+ return drainStatus == expected ? withDrainStatus(replacement) :
this;
+ }
+
+ FlowEvolutionProgress withFailureIfAbsent(final String explanation) {
+ return hasFailed() ? this : new FlowEvolutionProgress(drainStatus,
explanation);
+ }
+ }
+
+ /**
+ * One attempt at a pending flow evolution. The futures are each set at
most once per attempt, and are read and written
+ * only while holding the evolution lock, so closing the attempt cancels
this attempt's work and never a newer attempt's.
+ */
+ private static final class FlowEvolutionAttempt {
Review Comment:
[Claude Opus 5.5] I think it's worthwhile, so it's in this PR. The
flow-evolution code now lives in a package-private ConnectorFlowEvolution owned
by the node. That includes the lock, the progress and attempt state, the
authoritative snapshot, and the prepare, evolve-drain, begin-update, fail and
retry-stop steps. The node keeps its lifecycle methods and delegates to it,
which takes about 700 lines out of StandardConnectorNode. The evolution tests
stay in TestStandardConnectorNode and run through the node's public behavior,
for example testFlowEvolutionLifecycle and
testFlowEvolutionAfterFailedApplyResumesAfterHook. That way they don't depend
on the new class's internals.
--
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]