This is an automated email from the ASF dual-hosted git repository.

pvillard 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 423381d4c5 NIFI-15008 Allow affected components to be reloaded if 
necessary during parameter context update
423381d4c5 is described below

commit 423381d4c53e5765d9a92bebf72804f36294bfa7
Author: Bryan Bende <[email protected]>
AuthorDate: Tue Sep 23 15:47:00 2025 -0400

    NIFI-15008 Allow affected components to be reloaded if necessary during 
parameter context update
    
    Signed-off-by: Pierre Villard <[email protected]>
    
    This closes #10338.
---
 .../org/apache/nifi/web/NiFiServiceFacade.java     | 14 +++++++++
 .../apache/nifi/web/StandardNiFiServiceFacade.java | 14 +++++++++
 .../nifi/web/util/ParameterUpdateManager.java      | 33 ++++++++++++++++++++--
 3 files changed, 59 insertions(+), 2 deletions(-)

diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
index 9218dba029..42ba49135c 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
@@ -763,6 +763,13 @@ public interface NiFiServiceFacade {
      */
     ProcessorEntity deleteProcessor(Revision revision, String processorId);
 
+    /**
+     * Reloads the underlying processor if the additional classpath resources 
have changed.
+     *
+     * @param processorId the id of the processor to reload
+     */
+    void reloadProcessor(String processorId);
+
     // ----------------------------------------
     // Connections methods
     // ----------------------------------------
@@ -2269,6 +2276,13 @@ public interface NiFiServiceFacade {
      */
     void verifyDeleteControllerService(String controllerServiceId);
 
+    /**
+     * Reloads the underlying controller service if the additional classpath 
resources have changed.
+     *
+     * @param controllerServiceId the id of the controller service to reload
+     */
+    void reloadControllerService(String controllerServiceId);
+
     // ----------------------------------------
     // Parameter Provider methods
     // ----------------------------------------
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
index 85246e1b87..e4b234dd82 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
@@ -754,6 +754,13 @@ public class StandardNiFiServiceFacade implements 
NiFiServiceFacade {
         controllerServiceDAO.verifyDelete(controllerServiceId);
     }
 
+    @Override
+    public void reloadControllerService(final String controllerServiceId) {
+        final ControllerServiceNode controllerServiceNode = 
controllerServiceDAO.getControllerService(controllerServiceId);
+        controllerServiceNode.verifyCanUpdate();
+        controllerServiceNode.reloadAdditionalResourcesIfNecessary();
+    }
+
     @Override
     public void verifyCreateReportingTask(ReportingTaskDTO reportingTaskDTO) {
         reportingTaskDAO.verifyCreate(reportingTaskDTO);
@@ -2113,6 +2120,13 @@ public class StandardNiFiServiceFacade implements 
NiFiServiceFacade {
         processorDAO.verifyTerminate(processorId);
     }
 
+    @Override
+    public void reloadProcessor(final String processorId) {
+        final ProcessorNode processorNode = 
processorDAO.getProcessor(processorId);
+        processorNode.verifyCanUpdate();
+        processorNode.reloadAdditionalResourcesIfNecessary();
+    }
+
     @Override
     public LabelEntity deleteLabel(final Revision revision, final String 
labelId) {
         final Label label = labelDAO.getLabel(labelId);
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/ParameterUpdateManager.java
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/ParameterUpdateManager.java
index b60f643537..ea915377e9 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/ParameterUpdateManager.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/ParameterUpdateManager.java
@@ -53,6 +53,9 @@ import java.util.stream.Collectors;
 public class ParameterUpdateManager {
     private static final Logger logger = 
LoggerFactory.getLogger(ParameterUpdateManager.class);
 
+    private static final String PROCESSOR_COMPONENT_TYPE = "processor";
+    private static final String STATELESS_PROCESS_GROUP_COMPONENT_TYPE = 
"stateless process group";
+
     private final NiFiServiceFacade serviceFacade;
     private final DtoFactory dtoFactory;
     private final Authorizer authorizer;
@@ -180,13 +183,17 @@ public class ParameterUpdateManager {
             asyncRequest.markStepComplete();
         } finally {
             // TODO: can almost certainly be refactored so that the same code 
is shared between VersionsResource and ParameterContextResource.
+            if (!asyncRequest.isCancelled()) {
+                reloadAffectedComponents(affectedComponents);
+            }
+
             if (!asyncRequest.isCancelled()) {
                 enableControllerServices(enabledControllerServices, 
enabledControllerServices, asyncRequest, componentLifecycle, uri);
             }
 
             if (!asyncRequest.isCancelled()) {
-                restartComponents(runningProcessors, "processor", 
asyncRequest, componentLifecycle, uri);
-                restartComponents(runningStatelessGroups, "stateless process 
group", asyncRequest, componentLifecycle, uri);
+                restartComponents(runningProcessors, PROCESSOR_COMPONENT_TYPE, 
asyncRequest, componentLifecycle, uri);
+                restartComponents(runningStatelessGroups, 
STATELESS_PROCESS_GROUP_COMPONENT_TYPE, asyncRequest, componentLifecycle, uri);
 
                 asyncRequest.markStepComplete();
             }
@@ -344,4 +351,26 @@ public class ParameterUpdateManager {
 
         return entities;
     }
+
+    private void reloadAffectedComponents(final Set<AffectedComponentEntity> 
affectedComponents) {
+        final Set<AffectedComponentEntity> allAffectedServices = 
affectedComponents.stream()
+            .filter(entity -> entity.getComponent() != null)
+            .filter(dto -> 
AffectedComponentDTO.COMPONENT_TYPE_CONTROLLER_SERVICE.equals(dto.getComponent().getReferenceType()))
+            .collect(Collectors.toSet());
+
+        final Set<AffectedComponentEntity> allAffectedProcessors = 
affectedComponents.stream()
+            .filter(entity -> entity.getComponent() != null)
+            .filter(dto -> 
AffectedComponentDTO.COMPONENT_TYPE_PROCESSOR.equals(dto.getComponent().getReferenceType()))
+            .collect(Collectors.toSet());
+
+        for (final AffectedComponentEntity controllerServiceEntity : 
allAffectedServices) {
+            logger.info("Reloading Controller Service {} after having updated 
Parameter Context", controllerServiceEntity.getId());
+            
serviceFacade.reloadControllerService(controllerServiceEntity.getId());
+        }
+
+        for (final AffectedComponentEntity processorEntity : 
allAffectedProcessors) {
+            logger.info("Reloading Processor {} after having updated Parameter 
Context", processorEntity.getId());
+            serviceFacade.reloadProcessor(processorEntity.getId());
+        }
+    }
 }

Reply via email to