NIFI-9730: Consider a change in value for retry-related fields from 'null' to the default value as an environmental change so that it's not flagged as a Local Modification, which would prevent users from updating the version of the Process Group that they are using

Signed-off-by: Joe Gresock <jgresock@gmail.com>

This closes #5809.
This commit is contained in:
Mark Payne 2022-02-25 14:14:28 -05:00 committed by Joe Gresock
parent db28c91cdb
commit 9d3788ff05
No known key found for this signature in database
GPG Key ID: 37F5B9B6E258C8B7
3 changed files with 38 additions and 4 deletions

View File

@ -127,7 +127,6 @@ public class StandardProcessorNode extends ProcessorNode implements Connectable
public static final TimeUnit DEFAULT_TIME_UNIT = TimeUnit.MILLISECONDS;
public static final String DEFAULT_YIELD_PERIOD = "1 sec";
public static final String DEFAULT_PENALIZATION_PERIOD = "30 sec";
private static final String DEFAULT_MAX_BACKOFF_PERIOD = "10 mins";
private final AtomicReference<ProcessGroup> processGroup;
private final AtomicReference<ProcessorDetails> processorRef;
private final AtomicReference<String> identifier;
@ -208,9 +207,9 @@ public class StandardProcessorNode extends ProcessorNode implements Connectable
executionNode = isExecutionNodeRestricted() ? ExecutionNode.PRIMARY : ExecutionNode.ALL;
this.hashCode = new HashCodeBuilder(7, 67).append(identifier).toHashCode();
retryCount = 10;
retryCount = DEFAULT_RETRY_COUNT;
retriedRelationships = new HashSet<>();
backoffMechanism = BackoffMechanism.PENALIZE_FLOWFILE;
backoffMechanism = DEFAULT_BACKOFF_MECHANISM;
maxBackoffPeriod = DEFAULT_MAX_BACKOFF_PERIOD;
try {

View File

@ -64,7 +64,8 @@ public class FlowDifferenceFilters {
|| isNewRelationshipAutoTerminatedAndDefaulted(difference, localGroup, flowManager)
|| isScheduledStateNew(difference)
|| isLocalScheduleStateChange(difference)
|| isPropertyMissingFromGhostComponent(difference, flowManager);
|| isPropertyMissingFromGhostComponent(difference, flowManager)
|| isNewRetryConfigWithDefaultValue(difference, flowManager);
}
/**
@ -143,6 +144,37 @@ public class FlowDifferenceFilters {
return false;
}
private static boolean isNewRetryConfigWithDefaultValue(final FlowDifference fd, final FlowManager flowManager) {
final Object valueA = fd.getValueA();
if (valueA != null) {
return false;
}
final VersionedComponent componentB = fd.getComponentB();
if (!(componentB instanceof InstantiatedVersionedProcessor)) {
return false;
}
final DifferenceType type = fd.getDifferenceType();
final InstantiatedVersionedProcessor instantiatedProcessor = (InstantiatedVersionedProcessor) componentB;
final ProcessorNode processorNode = flowManager.getProcessorNode(instantiatedProcessor.getInstanceIdentifier());
if (processorNode == null) {
return false;
}
switch (type) {
case RETRIED_RELATIONSHIPS_CHANGED:
return processorNode.getRetriedRelationships().isEmpty();
case RETRY_COUNT_CHANGED:
return processorNode.getRetryCount() == ProcessorNode.DEFAULT_RETRY_COUNT;
case MAX_BACKOFF_PERIOD_CHANGED:
return ProcessorNode.DEFAULT_MAX_BACKOFF_PERIOD.equals(processorNode.getMaxBackoffPeriod());
case BACKOFF_MECHANISM_CHANGED:
return ProcessorNode.DEFAULT_BACKOFF_MECHANISM == processorNode.getBackoffMechanism();
default:
return false;
}
}
public static boolean isNewPropertyWithDefaultValue(final FlowDifference fd, final FlowManager flowManager) {
if (fd.getDifferenceType() != DifferenceType.PROPERTY_ADDED) {

View File

@ -45,6 +45,9 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
public abstract class ProcessorNode extends AbstractComponentNode implements Connectable {
public static final int DEFAULT_RETRY_COUNT = 10;
public static final BackoffMechanism DEFAULT_BACKOFF_MECHANISM = BackoffMechanism.PENALIZE_FLOWFILE;
public static final String DEFAULT_MAX_BACKOFF_PERIOD = "10 mins";
protected final AtomicReference<ScheduledState> scheduledState;