This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 9b33d54f53 NIFI-12301 Corrected hasProperty() check when Migrating
Properties
9b33d54f53 is described below
commit 9b33d54f53d9730a7891e913e466b7ab0148a188
Author: Mark Payne <[email protected]>
AuthorDate: Tue Oct 31 17:21:59 2023 -0400
NIFI-12301 Corrected hasProperty() check when Migrating Properties
When calling migrateProperties, provide the properties that were configured
in the VersionedComponent, rather than creating a new property map based on the
component's new properties
This closes #7964
Signed-off-by: David Handermann <[email protected]>
---
.../nifi/controller/StandardProcessorNode.java | 16 ++---
.../reporting/AbstractReportingTaskNode.java | 11 +++-
.../service/StandardControllerServiceNode.java | 10 ++-
.../StandardVersionedComponentSynchronizer.java | 72 +++++++---------------
.../StandardControllerServiceFactory.java | 2 +-
.../org/apache/nifi/controller/ProcessorNode.java | 2 +-
.../apache/nifi/controller/ReportingTaskNode.java | 3 +-
.../controller/service/ControllerServiceNode.java | 2 +-
.../serialization/VersionedFlowSynchronizer.java | 15 +++--
.../processors/tests/system/MigrateProperties.java | 15 ++++-
.../processors/tests/system/MigrateProperties.java | 1 +
.../system/migration/PropertyMigrationIT.java | 5 ++
12 files changed, 81 insertions(+), 73 deletions(-)
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
index 3781655bf3..28f45cf82c 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
@@ -88,9 +88,9 @@ import org.apache.nifi.util.FormatUtils;
import org.apache.nifi.util.ReflectionUtils;
import org.apache.nifi.util.ThreadUtils;
import org.apache.nifi.util.file.classloader.ClassLoaderUtils;
-import org.springframework.scheduling.support.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.scheduling.support.CronExpression;
import java.lang.management.ThreadInfo;
import java.lang.reflect.InvocationTargetException;
@@ -1111,7 +1111,6 @@ public class StandardProcessorNode extends ProcessorNode
implements Connectable
}
@Override
- @SuppressWarnings("deprecation")
public List<ValidationResult> validateConfig() {
final List<ValidationResult> results = new ArrayList<>();
@@ -2078,9 +2077,9 @@ public class StandardProcessorNode extends ProcessorNode
implements Connectable
}
@Override
- public void migrateConfiguration(final ControllerServiceFactory
serviceFactory) {
+ public void migrateConfiguration(final Map<String, String>
rawPropertyValues, final ControllerServiceFactory serviceFactory) {
try {
- migrateProperties(serviceFactory);
+ migrateProperties(rawPropertyValues, serviceFactory);
} catch (final Exception e) {
LOG.error("Failed to migrate Property Configuration for {}.",
this, e);
}
@@ -2092,11 +2091,14 @@ public class StandardProcessorNode extends
ProcessorNode implements Connectable
}
}
- private void migrateProperties(final ControllerServiceFactory
serviceFactory) {
+ private void migrateProperties(final Map<String, String>
originalPropertyValues, final ControllerServiceFactory serviceFactory) {
final Processor processor = getProcessor();
- final StandardPropertyConfiguration propertyConfig = new
StandardPropertyConfiguration(toPropertyNameMap(getEffectivePropertyValues()),
- toPropertyNameMap(getRawPropertyValues()),
this::mapRawValueToEffectiveValue, toString(), serviceFactory);
+ final Map<String, String> effectiveValues = new HashMap<>();
+ originalPropertyValues.forEach((key, value) ->
effectiveValues.put(key, mapRawValueToEffectiveValue(value)));
+
+ final StandardPropertyConfiguration propertyConfig = new
StandardPropertyConfiguration(effectiveValues,
+ originalPropertyValues, this::mapRawValueToEffectiveValue,
toString(), serviceFactory);
try (final NarCloseable nc =
NarCloseable.withComponentNarLoader(getExtensionManager(),
processor.getClass(), getIdentifier())) {
processor.migrateProperties(propertyConfig);
}
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/reporting/AbstractReportingTaskNode.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/reporting/AbstractReportingTaskNode.java
index b18db120c7..6ea63a26e0 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/reporting/AbstractReportingTaskNode.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/reporting/AbstractReportingTaskNode.java
@@ -65,7 +65,9 @@ import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -428,11 +430,14 @@ public abstract class AbstractReportingTaskNode extends
AbstractComponentNode im
}
@Override
- public void migrateConfiguration(final ControllerServiceFactory
serviceFactory) {
+ public void migrateConfiguration(final Map<String, String>
originalPropertyValues, final ControllerServiceFactory serviceFactory) {
final ReportingTask task = getReportingTask();
- final StandardPropertyConfiguration propertyConfig = new
StandardPropertyConfiguration(toPropertyNameMap(getEffectivePropertyValues()),
- toPropertyNameMap(getRawPropertyValues()),
this::mapRawValueToEffectiveValue, toString(), serviceFactory);
+ final Map<String, String> effectiveValues = new HashMap<>();
+ originalPropertyValues.forEach((key, value) ->
effectiveValues.put(key, mapRawValueToEffectiveValue(value)));
+
+ final StandardPropertyConfiguration propertyConfig = new
StandardPropertyConfiguration(effectiveValues,
+ originalPropertyValues, this::mapRawValueToEffectiveValue,
toString(), serviceFactory);
try (final NarCloseable nc =
NarCloseable.withComponentNarLoader(getExtensionManager(), task.getClass(),
getIdentifier())) {
task.migrateProperties(propertyConfig);
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
index d1a112b835..f6231c5e3d 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
@@ -75,6 +75,7 @@ import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -836,9 +837,12 @@ public class StandardControllerServiceNode extends
AbstractComponentNode impleme
}
@Override
- public void migrateConfiguration(final ControllerServiceFactory
serviceFactory) {
- final StandardPropertyConfiguration propertyConfig = new
StandardPropertyConfiguration(toPropertyNameMap(getEffectivePropertyValues()),
- toPropertyNameMap(getRawPropertyValues()),
super::mapRawValueToEffectiveValue, toString(), serviceFactory);
+ public void migrateConfiguration(final Map<String, String>
originalPropertyValues, final ControllerServiceFactory serviceFactory) {
+ final Map<String, String> effectiveValues = new HashMap<>();
+ originalPropertyValues.forEach((key, value) ->
effectiveValues.put(key, mapRawValueToEffectiveValue(value)));
+
+ final StandardPropertyConfiguration propertyConfig = new
StandardPropertyConfiguration(effectiveValues,
+ originalPropertyValues, super::mapRawValueToEffectiveValue,
toString(), serviceFactory);
final ControllerService implementation =
getControllerServiceImplementation();
try (final NarCloseable nc =
NarCloseable.withComponentNarLoader(getExtensionManager(),
implementation.getClass(), getIdentifier())) {
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizer.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizer.java
index 17f10cee15..184f53aa0f 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizer.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizer.java
@@ -75,6 +75,7 @@ import org.apache.nifi.groups.ComponentIdGenerator;
import org.apache.nifi.groups.FlowFileConcurrency;
import org.apache.nifi.groups.FlowFileOutboundPolicy;
import org.apache.nifi.groups.FlowSynchronizationOptions;
+import
org.apache.nifi.groups.FlowSynchronizationOptions.ComponentStopTimeoutAction;
import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.groups.PropertyDecryptor;
import org.apache.nifi.groups.RemoteProcessGroup;
@@ -93,11 +94,7 @@ import
org.apache.nifi.parameter.ParameterReferencedControllerServiceData;
import org.apache.nifi.parameter.StandardParameterProviderConfiguration;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.registry.flow.FlowRegistryClientContextFactory;
import org.apache.nifi.registry.flow.FlowRegistryClientNode;
-import org.apache.nifi.registry.flow.FlowRegistryException;
-import org.apache.nifi.registry.flow.FlowSnapshotContainer;
-import org.apache.nifi.registry.flow.RegisteredFlowSnapshot;
import org.apache.nifi.registry.flow.StandardVersionControlInformation;
import org.apache.nifi.registry.flow.VersionControlInformation;
import org.apache.nifi.registry.flow.VersionedFlowState;
@@ -119,11 +116,9 @@ import
org.apache.nifi.remote.protocol.SiteToSiteTransportProtocol;
import org.apache.nifi.scheduling.ExecutionNode;
import org.apache.nifi.scheduling.SchedulingStrategy;
import org.apache.nifi.util.FlowDifferenceFilters;
-import org.apache.nifi.web.ResourceNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
import java.net.URL;
import java.time.Duration;
import java.util.ArrayList;
@@ -155,7 +150,7 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
private final VersionedFlowSynchronizationContext context;
private final Set<String> updatedVersionedComponentIds = new HashSet<>();
- private final Set<ComponentNode> createdExtensions = new HashSet<>();
+ private final List<CreatedExtension> createdExtensions = new ArrayList<>();
private FlowSynchronizationOptions syncOptions;
private final ConnectableAdditionTracker connectableAdditionTracker = new
ConnectableAdditionTracker();
@@ -251,16 +246,19 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
}
});
- for (final ComponentNode extension : createdExtensions) {
+ for (final CreatedExtension createdExtension : createdExtensions) {
+ final ComponentNode extension = createdExtension.extension();
+ final Map<String, String> originalPropertyValues =
createdExtension.propertyValues();
+
final ControllerServiceFactory serviceFactory = new
StandardControllerServiceFactory(context.getExtensionManager(),
context.getFlowManager(),
context.getControllerServiceProvider(), extension);
if (extension instanceof final ProcessorNode processor) {
- processor.migrateConfiguration(serviceFactory);
+ processor.migrateConfiguration(originalPropertyValues,
serviceFactory);
} else if (extension instanceof final ControllerServiceNode
service) {
- service.migrateConfiguration(serviceFactory);
+ service.migrateConfiguration(originalPropertyValues,
serviceFactory);
} else if (extension instanceof final ReportingTaskNode task) {
- task.migrateConfiguration(serviceFactory);
+ task.migrateConfiguration(originalPropertyValues,
serviceFactory);
}
}
@@ -1195,7 +1193,7 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
}
updateControllerService(newService, proposed, topLevelGroup);
- createdExtensions.add(newService);
+ createdExtensions.add(new CreatedExtension(newService,
proposed.getProperties()));
return newService;
}
@@ -2115,29 +2113,6 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
return new BundleCoordinate(bundle.getGroup(), bundle.getArtifact(),
bundle.getVersion());
}
- private Map<String, VersionedParameterContext>
getVersionedParameterContexts(final VersionedFlowCoordinates
versionedFlowCoordinates) {
- final String registryId =
determineRegistryId(versionedFlowCoordinates);
- final FlowRegistryClientNode flowRegistry =
context.getFlowManager().getFlowRegistryClient(registryId);
- if (flowRegistry == null) {
- throw new ResourceNotFoundException("Could not find any Flow
Registry registered with identifier " + registryId);
- }
-
- final String bucketId = versionedFlowCoordinates.getBucketId();
- final String flowId = versionedFlowCoordinates.getFlowId();
- final int flowVersion = versionedFlowCoordinates.getVersion();
-
- try {
- final FlowSnapshotContainer snapshotContainer =
flowRegistry.getFlowContents(FlowRegistryClientContextFactory.getAnonymousContext(),
bucketId, flowId, flowVersion, false);
- final RegisteredFlowSnapshot childSnapshot =
snapshotContainer.getFlowSnapshot();
- return childSnapshot.getParameterContexts();
- } catch (final FlowRegistryException e) {
- throw new IllegalArgumentException("The Flow Registry with ID " +
registryId + " reports that no Flow exists with Bucket "
- + bucketId + ", Flow " + flowId + ", Version " + flowVersion,
e);
- } catch (final IOException ioe) {
- throw new IllegalStateException("Failed to communicate with Flow
Registry when attempting to retrieve a versioned flow");
- }
- }
-
@Override
public void synchronize(final Funnel funnel, final VersionedFunnel
proposed, final ProcessGroup group, final FlowSynchronizationOptions
synchronizationOptions)
throws FlowSynchronizationException, TimeoutException,
InterruptedException {
@@ -2404,7 +2379,7 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
destination.addProcessor(procNode);
updateProcessor(procNode, proposed, topLevelGroup);
- createdExtensions.add(procNode);
+ createdExtensions.add(new CreatedExtension(procNode,
proposed.getProperties()));
// Notify the processor node that the configuration (properties, e.g.)
has been restored
final ProcessContext processContext =
context.getProcessContextFactory().apply(procNode);
@@ -2573,6 +2548,7 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
if (intendedState ==
org.apache.nifi.flow.ScheduledState.RUNNING &&
reportingTaskNode.getScheduledState() == ScheduledState.DISABLED) {
return;
}
+
synchronizationOptions.getScheduledStateChangeListener().onScheduledStateChange(reportingTaskNode,
intendedState);
}
} catch (final Exception e) {
@@ -2637,14 +2613,12 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
return stopProcessor(processor, timeout);
} catch (final TimeoutException te) {
- switch (synchronizationOptions.getComponentStopTimeoutAction()) {
- case THROW_TIMEOUT_EXCEPTION:
- throw te;
- case TERMINATE:
- default:
- processor.terminate();
- return true;
+ if (synchronizationOptions.getComponentStopTimeoutAction() ==
ComponentStopTimeoutAction.THROW_TIMEOUT_EXCEPTION) {
+ throw te;
}
+
+ processor.terminate();
+ return true;
} finally {
notifyScheduledStateChange((ComponentNode) processor,
synchronizationOptions, org.apache.nifi.flow.ScheduledState.ENABLED);
}
@@ -3309,9 +3283,7 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
}
final Optional<Connectable> addedComponent =
connectableAdditionTracker.getComponent(group.getIdentifier(),
connectableComponent.getId());
- if (addedComponent.isPresent()) {
- LOG.debug("Found Connectable in Process Group {} as newly added
component {}", group, addedComponent.get());
- }
+ addedComponent.ifPresent(value -> LOG.debug("Found Connectable in
Process Group {} as newly added component {}", group, value));
return addedComponent.orElse(null);
}
@@ -3402,7 +3374,7 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
NiFiRegistryFlowMapper.generateVersionedComponentId(component.getIdentifier()))))
.findAny();
- if (!rpgOption.isPresent()) {
+ if (rpgOption.isEmpty()) {
throw new IllegalArgumentException("Connection refers to a
Port with ID " + id + " within Remote Process Group with ID "
+ rpgId + " but could not find a Remote Process Group
corresponding to that ID");
}
@@ -3428,7 +3400,7 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
NiFiRegistryFlowMapper.generateVersionedComponentId(component.getIdentifier()))))
.findAny();
- if (!rpgOption.isPresent()) {
+ if (rpgOption.isEmpty()) {
throw new IllegalArgumentException("Connection refers to a
Port with ID " + id + " within Remote Process Group with ID "
+ rpgId + " but could not find a Remote Process Group
corresponding to that ID");
}
@@ -3487,7 +3459,7 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
final BundleCoordinate coordinate =
toCoordinate(reportingTask.getBundle());
final ReportingTaskNode taskNode =
context.getFlowManager().createReportingTask(reportingTask.getType(),
reportingTask.getInstanceIdentifier(), coordinate, false);
updateReportingTask(taskNode, reportingTask);
- createdExtensions.add(taskNode);
+ createdExtensions.add(new CreatedExtension(taskNode,
reportingTask.getProperties()));
return taskNode;
}
@@ -3732,4 +3704,6 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
return getVersionedControllerService(group.getParent(),
versionedComponentId);
}
+ private record CreatedExtension(ComponentNode extension, Map<String,
String> propertyValues) {
+ }
}
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/migration/StandardControllerServiceFactory.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/migration/StandardControllerServiceFactory.java
index dcd2a3de65..956d8c0b8b 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/migration/StandardControllerServiceFactory.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/migration/StandardControllerServiceFactory.java
@@ -98,7 +98,7 @@ public class StandardControllerServiceFactory implements
ControllerServiceFactor
serviceNode.setProperties(creationDetails.serviceProperties());
final ControllerServiceFactory serviceFactory = new
StandardControllerServiceFactory(extensionManager, flowManager,
serviceProvider, serviceNode);
- serviceNode.migrateConfiguration(serviceFactory);
+ serviceNode.migrateConfiguration(creationDetails.serviceProperties(),
serviceFactory);
if (isEnable()) {
final ValidationStatus validationStatus =
serviceNode.performValidation();
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ProcessorNode.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ProcessorNode.java
index fa5b130a37..be53eabf81 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ProcessorNode.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ProcessorNode.java
@@ -298,6 +298,6 @@ public abstract class ProcessorNode extends
AbstractComponentNode implements Con
public abstract void notifyPrimaryNodeChanged(PrimaryNodeState
primaryNodeState, LifecycleState lifecycleState);
- public abstract void migrateConfiguration(ControllerServiceFactory
serviceFactory);
+ public abstract void migrateConfiguration(Map<String, String>
originalPropertyValues, ControllerServiceFactory serviceFactory);
}
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ReportingTaskNode.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ReportingTaskNode.java
index 548476f967..e7096bf60b 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ReportingTaskNode.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ReportingTaskNode.java
@@ -28,6 +28,7 @@ import org.apache.nifi.reporting.ReportingTask;
import org.apache.nifi.scheduling.SchedulingStrategy;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -138,5 +139,5 @@ public interface ReportingTaskNode extends ComponentNode {
void notifyPrimaryNodeChanged(PrimaryNodeState primaryNodeState,
LifecycleState lifecycleState);
- void migrateConfiguration(ControllerServiceFactory
controllerServiceFactory);
+ void migrateConfiguration(Map<String, String> originalPropertyValues,
ControllerServiceFactory controllerServiceFactory);
}
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceNode.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceNode.java
index 40f3be083d..02dafdfc54 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceNode.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceNode.java
@@ -257,6 +257,6 @@ public interface ControllerServiceNode extends
ComponentNode, VersionedComponent
void notifyPrimaryNodeChanged(PrimaryNodeState primaryNodeState);
- void migrateConfiguration(ControllerServiceFactory serviceFactory);
+ void migrateConfiguration(Map<String, String> originalPropertyValues,
ControllerServiceFactory serviceFactory);
}
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/VersionedFlowSynchronizer.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/VersionedFlowSynchronizer.java
index 0aaaafc73c..d4b5c78ab4 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/VersionedFlowSynchronizer.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/VersionedFlowSynchronizer.java
@@ -616,7 +616,7 @@ public class VersionedFlowSynchronizer implements
FlowSynchronizer {
final ControllerServiceFactory serviceFactory = new
StandardControllerServiceFactory(controller.getExtensionManager(),
controller.getFlowManager(),
controller.getControllerServiceProvider(), taskNode);
- taskNode.migrateConfiguration(serviceFactory);
+ taskNode.migrateConfiguration(reportingTask.getProperties(),
serviceFactory);
}
private void updateReportingTask(final ReportingTaskNode taskNode, final
VersionedReportingTask reportingTask, final FlowController controller) {
@@ -957,26 +957,29 @@ public class VersionedFlowSynchronizer implements
FlowSynchronizer {
// Service B's references won't be updated. To avoid this, we create
them all first, and then configure/update
// them so that when AbstractComponentNode#setProperty is called, it
properly establishes that reference.
final List<VersionedControllerService> controllerServices =
dataflow.getControllerServices();
- final Set<ControllerServiceNode> controllerServicesAdded = new
HashSet<>();
+ final Map<ControllerServiceNode, Map<String, String>>
controllerServicesAddedAndProperties = new HashMap<>();
for (final VersionedControllerService versionedControllerService :
controllerServices) {
final ControllerServiceNode serviceNode =
flowManager.getRootControllerService(versionedControllerService.getInstanceIdentifier());
if (serviceNode == null) {
final ControllerServiceNode added =
addRootControllerService(controller, versionedControllerService);
- controllerServicesAdded.add(added);
+ controllerServicesAddedAndProperties.put(added,
versionedControllerService.getProperties());
}
}
for (final VersionedControllerService versionedControllerService :
controllerServices) {
final ControllerServiceNode serviceNode =
flowManager.getRootControllerService(versionedControllerService.getInstanceIdentifier());
- if (controllerServicesAdded.contains(serviceNode) ||
affectedComponentSet.isControllerServiceAffected(serviceNode.getIdentifier())) {
+ if (controllerServicesAddedAndProperties.containsKey(serviceNode)
||
affectedComponentSet.isControllerServiceAffected(serviceNode.getIdentifier())) {
updateRootControllerService(serviceNode,
versionedControllerService, controller.getEncryptor());
}
}
- for (final ControllerServiceNode service : controllerServicesAdded) {
+ for (final Map.Entry<ControllerServiceNode, Map<String, String>> entry
: controllerServicesAddedAndProperties.entrySet()) {
+ final ControllerServiceNode service = entry.getKey();
+ final Map<String, String> originalPropertyValues =
entry.getValue();
+
final ControllerServiceFactory serviceFactory = new
StandardControllerServiceFactory(controller.getExtensionManager(),
controller.getFlowManager(),
controller.getControllerServiceProvider(), service);
- service.migrateConfiguration(serviceFactory);
+ service.migrateConfiguration(originalPropertyValues,
serviceFactory);
}
for (final VersionedControllerService versionedControllerService :
controllerServices) {
diff --git
a/nifi-system-tests/nifi-alternate-config-extensions-bundle/nifi-alternate-config-extensions/src/main/java/org/apache/nifi/processors/tests/system/MigrateProperties.java
b/nifi-system-tests/nifi-alternate-config-extensions-bundle/nifi-alternate-config-extensions/src/main/java/org/apache/nifi/processors/tests/system/MigrateProperties.java
index cfa974166a..af7e9dadd3 100644
---
a/nifi-system-tests/nifi-alternate-config-extensions-bundle/nifi-alternate-config-extensions/src/main/java/org/apache/nifi/processors/tests/system/MigrateProperties.java
+++
b/nifi-system-tests/nifi-alternate-config-extensions-bundle/nifi-alternate-config-extensions/src/main/java/org/apache/nifi/processors/tests/system/MigrateProperties.java
@@ -18,6 +18,7 @@
package org.apache.nifi.processors.tests.system;
import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.Validator;
import org.apache.nifi.controller.ControllerService;
import org.apache.nifi.cs.tests.system.MigrationService;
import org.apache.nifi.flowfile.FlowFile;
@@ -63,6 +64,13 @@ public class MigrateProperties extends AbstractProcessor {
.identifiesControllerService(ControllerService.class)
.build();
+ static PropertyDescriptor DEPRECATED = new PropertyDescriptor.Builder()
+ .name("Deprecated")
+ .required(false)
+ .addValidator(Validator.VALID)
+ .defaultValue("Deprecated Value")
+ .build();
+
static Relationship REL_ODD = new
Relationship.Builder().name("odd").build();
static Relationship REL_EVEN = new
Relationship.Builder().name("even").build();
static Relationship REL_BROKEN = new
Relationship.Builder().name("broken").build();
@@ -72,7 +80,8 @@ public class MigrateProperties extends AbstractProcessor {
INGEST,
ATTRIBUTE_NAME,
ATTRIBUTE_VALUE,
- SERVICE
+ SERVICE,
+ DEPRECATED
);
private final AtomicLong counter = new AtomicLong(0L);
@@ -98,6 +107,10 @@ public class MigrateProperties extends AbstractProcessor {
final String ignoredValue =
config.getPropertyValue("ignored").orElse(null);
config.removeProperty("ignored");
+ if (config.hasProperty("Deprecated")) {
+ config.setProperty("Deprecated Found", "true");
+ }
+
// If the 'ignored' value was set, create a new Controller Service
whose Start value is set to that value.
if (ignoredValue != null && ignoredValue.matches("\\d+")) {
final String serviceId =
config.createControllerService(MigrationService.class.getName(),
Map.of("Start", ignoredValue));
diff --git
a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/processors/tests/system/MigrateProperties.java
b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/processors/tests/system/MigrateProperties.java
index 6f677656fe..beac6d1260 100644
---
a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/processors/tests/system/MigrateProperties.java
+++
b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/processors/tests/system/MigrateProperties.java
@@ -62,6 +62,7 @@ public class MigrateProperties extends AbstractProcessor {
.addValidator(Validator.VALID)
.build();
+
static Relationship REL_SUCCESS = new
Relationship.Builder().name("success").build();
static Relationship REL_FAILURE = new
Relationship.Builder().name("failure").build();
diff --git
a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/migration/PropertyMigrationIT.java
b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/migration/PropertyMigrationIT.java
index 45344cdc6a..55f52d5ef7 100644
---
a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/migration/PropertyMigrationIT.java
+++
b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/migration/PropertyMigrationIT.java
@@ -45,6 +45,7 @@ import java.util.Set;
import java.util.regex.Pattern;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -105,6 +106,9 @@ public class PropertyMigrationIT extends NiFiSystemIT {
final String serviceId = propertiesMap.get(SERVICE);
assertNotNull(serviceId);
serviceIds.add(serviceId);
+
+ assertEquals("Deprecated Value", propertiesMap.get("Deprecated"));
+ assertFalse(propertiesMap.containsKey("Deprecated Found"));
}
// Should be 3 different services
@@ -191,6 +195,7 @@ public class PropertyMigrationIT extends NiFiSystemIT {
expectedUpdatedProperties.put("Attribute Value", "Hi");
expectedUpdatedProperties.put("New Property", "true");
expectedUpdatedProperties.put("Service", null);
+ expectedUpdatedProperties.put("Deprecated", "Deprecated Value");
assertEquals(expectedUpdatedProperties, updatedProperties);
final ProcessorConfigDTO updatedConfig =
updated.getComponent().getConfig();