You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2023/01/17 23:40:53 UTC
[nifi] branch main updated: NIFI-11028 Handle controller service 'Scheduled State' change (#6831)
This is an automated email from the ASF dual-hosted git repository.
markap14 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 9ad1d8a7ae NIFI-11028 Handle controller service 'Scheduled State' change (#6831)
9ad1d8a7ae is described below
commit 9ad1d8a7aece34ae78363d265492edec5a4c3bd8
Author: krisztina-zsihovszki <76...@users.noreply.github.com>
AuthorDate: Wed Jan 18 00:40:47 2023 +0100
NIFI-11028 Handle controller service 'Scheduled State' change (#6831)
---
.../org/apache/nifi/util/FlowDifferenceFilters.java | 8 ++++----
.../apache/nifi/util/TestFlowDifferenceFilters.java | 18 ++++++++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/util/FlowDifferenceFilters.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/util/FlowDifferenceFilters.java
index b052af8110..c9e07622e0 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/util/FlowDifferenceFilters.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/util/FlowDifferenceFilters.java
@@ -23,7 +23,6 @@ import org.apache.nifi.controller.flow.FlowManager;
import org.apache.nifi.controller.label.StandardLabel;
import org.apache.nifi.controller.service.ControllerServiceNode;
import org.apache.nifi.flow.ComponentType;
-import org.apache.nifi.flow.ScheduledState;
import org.apache.nifi.flow.VersionedComponent;
import org.apache.nifi.flow.VersionedConnection;
import org.apache.nifi.flow.VersionedFlowCoordinates;
@@ -308,11 +307,12 @@ public class FlowDifferenceFilters {
return false;
}
- // If Scheduled State transitions from null to ENABLED or ENABLED to null, consider it a "new" scheduled state.
- if (fd.getValueA() == null && ScheduledState.ENABLED.equals(fd.getValueB())) {
+ // If Scheduled State transitions from null to a real state or
+ // from a real state to null, consider it a "new" scheduled state.
+ if (fd.getValueA() == null && fd.getValueB() != null) {
return true;
}
- if (fd.getValueB() == null && "ENABLED".equals(fd.getValueA())) {
+ if (fd.getValueB() == null && fd.getValueA() != null) {
return true;
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/util/TestFlowDifferenceFilters.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/util/TestFlowDifferenceFilters.java
index a606769cea..b87bebc01c 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/util/TestFlowDifferenceFilters.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/util/TestFlowDifferenceFilters.java
@@ -17,6 +17,8 @@
package org.apache.nifi.util;
import org.apache.nifi.flow.ComponentType;
+import org.apache.nifi.flow.ScheduledState;
+import org.apache.nifi.flow.VersionedControllerService;
import org.apache.nifi.flow.VersionedFlowCoordinates;
import org.apache.nifi.flow.VersionedPort;
import org.apache.nifi.flow.VersionedProcessGroup;
@@ -169,5 +171,21 @@ public class TestFlowDifferenceFilters {
assertFalse(FlowDifferenceFilters.FILTER_PUBLIC_PORT_NAME_CHANGES.test(flowDifference));
}
+
+ @Test
+ public void testFilterControllerServiceStatusChangeWhenNewStateIntroduced() {
+ final VersionedControllerService controllerServiceA = new VersionedControllerService();
+ final VersionedControllerService controllerServiceB = new VersionedControllerService();
+ controllerServiceA.setScheduledState(null);
+ controllerServiceB.setScheduledState(ScheduledState.DISABLED);
+
+ final StandardFlowDifference flowDifference = new StandardFlowDifference(
+ DifferenceType.SCHEDULED_STATE_CHANGED,
+ controllerServiceA, controllerServiceB,
+ controllerServiceA.getScheduledState(), controllerServiceB.getScheduledState(),
+ "");
+
+ assertTrue(FlowDifferenceFilters.isScheduledStateNew(flowDifference));
+ }
}