This is an automated email from the ASF dual-hosted git repository.
mattyb149 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 db11961026 NIFI-9440 Allow Controller Services to have configurable
Bulletins
db11961026 is described below
commit db11961026e88d19efc8d5e6b68e4723840c27a1
Author: Nissim Shiman <[email protected]>
AuthorDate: Mon Dec 6 22:52:07 2021 +0000
NIFI-9440 Allow Controller Services to have configurable Bulletins
Signed-off-by: Matthew Burgess <[email protected]>
This closes #6035
---
.../nifi/flow/VersionedControllerService.java | 10 +++++++
.../images/add-controller-service-window.png | Bin 187532 -> 97189 bytes
.../configure-controller-service-settings.png | Bin 76193 -> 69597 bytes
nifi-docs/src/main/asciidoc/user-guide.adoc | 6 +++-
.../nifi/web/api/dto/ControllerServiceDTO.java | 15 ++++++++++
.../service/StandardControllerServiceNode.java | 24 ++++++++++++++++
.../StandardVersionedComponentSynchronizer.java | 8 ++++++
.../flow/mapping/NiFiRegistryFlowMapper.java | 1 +
.../controller/service/ControllerServiceNode.java | 5 ++++
.../nifi/controller/StandardFlowSnippet.java | 9 ++++++
.../nifi/controller/flow/StandardFlowManager.java | 3 +-
.../serialization/FlowFromDOMFactory.java | 1 +
.../serialization/StandardFlowSerializer.java | 1 +
.../serialization/VersionedFlowSynchronizer.java | 9 ++++++
.../service/ControllerServiceLoader.java | 11 ++++++++
.../nifi/fingerprint/FingerprintFactory.java | 1 +
.../src/main/resources/FlowConfiguration.xsd | 1 +
.../apache/nifi/controller/TestFlowController.java | 6 +++-
.../flow/mapping/NiFiRegistryFlowMapperTest.java | 1 +
.../conf/processor-with-cs-flow-0.7.0.xml | 1 +
.../conf/reporting-task-with-cs-flow-0.7.0.xml | 1 +
.../nifi/audit/ControllerServiceAuditor.java | 4 +++
.../org/apache/nifi/web/api/dto/DtoFactory.java | 2 ++
.../web/dao/impl/StandardControllerServiceDAO.java | 8 +++++-
.../canvas/controller-service-configuration.jsp | 15 ++++++++++
.../webapp/js/nf/canvas/nf-controller-service.js | 31 +++++++++++++++++++++
.../registry/flow/diff/StandardFlowComparator.java | 1 +
.../nifi/stateless/VersionedFlowBuilder.java | 1 +
28 files changed, 171 insertions(+), 5 deletions(-)
diff --git
a/nifi-api/src/main/java/org/apache/nifi/flow/VersionedControllerService.java
b/nifi-api/src/main/java/org/apache/nifi/flow/VersionedControllerService.java
index ecb3c982f9..67f01080dd 100644
---
a/nifi-api/src/main/java/org/apache/nifi/flow/VersionedControllerService.java
+++
b/nifi-api/src/main/java/org/apache/nifi/flow/VersionedControllerService.java
@@ -27,6 +27,7 @@ public class VersionedControllerService extends
VersionedConfigurableExtension {
private String annotationData;
private ScheduledState scheduledState;
+ private String bulletinLevel;
@ApiModelProperty(value = "Lists the APIs this Controller Service
implements.")
public List<ControllerServiceAPI> getControllerServiceApis() {
@@ -59,4 +60,13 @@ public class VersionedControllerService extends
VersionedConfigurableExtension {
public void setScheduledState(final ScheduledState scheduledState) {
this.scheduledState = scheduledState;
}
+
+ @ApiModelProperty("The level at which the controller service will report
bulletins.")
+ public String getBulletinLevel() {
+ return bulletinLevel;
+ }
+
+ public void setBulletinLevel(String bulletinLevel) {
+ this.bulletinLevel = bulletinLevel;
+ }
}
diff --git
a/nifi-docs/src/main/asciidoc/images/add-controller-service-window.png
b/nifi-docs/src/main/asciidoc/images/add-controller-service-window.png
index 012ce72bb9..323237984c 100644
Binary files
a/nifi-docs/src/main/asciidoc/images/add-controller-service-window.png and
b/nifi-docs/src/main/asciidoc/images/add-controller-service-window.png differ
diff --git
a/nifi-docs/src/main/asciidoc/images/configure-controller-service-settings.png
b/nifi-docs/src/main/asciidoc/images/configure-controller-service-settings.png
index 7680192bb7..18cba1b253 100644
Binary files
a/nifi-docs/src/main/asciidoc/images/configure-controller-service-settings.png
and
b/nifi-docs/src/main/asciidoc/images/configure-controller-service-settings.png
differ
diff --git a/nifi-docs/src/main/asciidoc/user-guide.adoc
b/nifi-docs/src/main/asciidoc/user-guide.adoc
index 2dbc063db6..8dceaa60d0 100644
--- a/nifi-docs/src/main/asciidoc/user-guide.adoc
+++ b/nifi-docs/src/main/asciidoc/user-guide.adoc
@@ -1265,7 +1265,11 @@ You can obtain information about Controller Services by
clicking the "Usage" and
image:controller-services-info-buttons.png["Controller Services Information
Buttons"]
-When the DFM clicks the "Configure" button, a Configure Controller Service
window opens. It has three tabs: Settings, Properties,and Comments. This window
is similar to the Configure Processor window. The Settings tab provides a place
for the DFM to give the Controller Service a unique name (if desired). It also
lists the UUID, Type, Bundle and Support information for the service and
provides a list of other components (reporting tasks or other controller
services) that reference the service.
+When the DFM clicks the "Configure" button, a Configure Controller Service
window opens. It has three tabs: Settings, Properties,and Comments. This window
is similar to the Configure Processor window.
+
+The Settings tab provides a place for the DFM to give the Controller Service a
unique name (if desired). It also lists the UUID, Type, Bundle and Support
information for the service and provides a list of other components (reporting
tasks or other controller services) that reference the service.
+
+Finally, the Bulletin level is able to be modified. Whenever the Controller
Service writes to its log, the Controller Service will also generate a
Bulletin. This setting indicates the lowest level of Bulletin that should be
shown in the User Interface. By default, the Bulletin level is set to WARN,
which means it will display all warning and error-level bulletins.
image:configure-controller-service-settings.png["Configure Controller Service
Settings"]
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java
index 1c92e233a1..2e3f69e19e 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java
@@ -58,6 +58,7 @@ public class ControllerServiceDTO extends ComponentDTO {
private Collection<String> validationErrors;
private String validationStatus;
+ private String bulletinLevel;
/**
* @return controller service name
@@ -133,6 +134,20 @@ public class ControllerServiceDTO extends ComponentDTO {
this.comments = comments;
}
+ /**
+ * @return the level at which this controller service will report bulletins
+ */
+ @ApiModelProperty(
+ value = "The level at which the controller service will report
bulletins."
+ )
+ public String getBulletinLevel() {
+ return bulletinLevel;
+ }
+
+ public void setBulletinLevel(String bulletinLevel) {
+ this.bulletinLevel = bulletinLevel;
+ }
+
/**
* @return whether this controller service persists state
*/
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 c64ed47ed8..d8673a2650 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
@@ -47,6 +47,8 @@ import org.apache.nifi.controller.VerifiableControllerService;
import
org.apache.nifi.controller.exception.ControllerServiceInstantiationException;
import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.logging.LogLevel;
+import org.apache.nifi.logging.LogRepositoryFactory;
import org.apache.nifi.nar.ExtensionManager;
import org.apache.nifi.nar.InstanceClassLoader;
import org.apache.nifi.nar.NarCloseable;
@@ -86,6 +88,8 @@ public class StandardControllerServiceNode extends
AbstractComponentNode impleme
private static final Logger LOG =
LoggerFactory.getLogger(StandardControllerServiceNode.class);
+ public static final String BULLETIN_OBSERVER_ID = "bulletin-observer";
+
private final AtomicReference<ControllerServiceDetails>
controllerServiceHolder = new AtomicReference<>(null);
private final ControllerServiceProvider serviceProvider;
private final ServiceStateTransition stateTransition;
@@ -98,6 +102,7 @@ public class StandardControllerServiceNode extends
AbstractComponentNode impleme
private final Set<Tuple<ComponentNode, PropertyDescriptor>>
referencingComponents = new HashSet<>();
private volatile String comment;
private volatile ProcessGroup processGroup;
+ private volatile LogLevel bulletinLevel = LogLevel.WARN;
private final AtomicBoolean active;
@@ -712,4 +717,23 @@ public class StandardControllerServiceNode extends
AbstractComponentNode impleme
public ParameterLookup getParameterLookup() {
return getParameterContext();
}
+
+
+ @Override
+ public LogLevel getBulletinLevel() {
+ return bulletinLevel;
+ }
+
+ @Override
+ public synchronized void setBulletinLevel(LogLevel level) {
+ // handling backward compatibility with nifi 1.16 and earlier when
bulletinLevel did not exist in flow.xml/flow.json
+ // and bulletins were always logged at WARN level
+ if (level == null) {
+ level = LogLevel.WARN;
+ }
+
+
LogRepositoryFactory.getRepository(getIdentifier()).setObservationLevel(BULLETIN_OBSERVER_ID,
level);
+ this.bulletinLevel = level;
+ }
+
}
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 1552dbc506..bc60d45ab3 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
@@ -1197,6 +1197,14 @@ public class StandardVersionedComponentSynchronizer
implements VersionedComponen
service.setComments(proposed.getComments());
service.setName(proposed.getName());
+ if (proposed.getBulletinLevel() != null) {
+
service.setBulletinLevel(LogLevel.valueOf(proposed.getBulletinLevel()));
+ } else {
+ // this situation exists for backward compatibility with nifi
1.16 and earlier where controller services do not have bulletinLevels set in
flow.xml/flow.json
+ // and bulletinLevels are at the WARN level by default
+ service.setBulletinLevel(LogLevel.WARN);
+ }
+
final Set<String> sensitiveDynamicPropertyNames =
getSensitiveDynamicPropertyNames(service, proposed.getProperties(),
proposed.getPropertyDescriptors().values());
final Map<String, String> properties =
populatePropertiesMap(service, proposed.getProperties(),
service.getProcessGroup());
service.setProperties(properties, true,
sensitiveDynamicPropertyNames);
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapper.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapper.java
index 20db633e06..8e6e64c462 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapper.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapper.java
@@ -442,6 +442,7 @@ public class NiFiRegistryFlowMapper {
versionedService.setAnnotationData(controllerService.getAnnotationData());
versionedService.setBundle(mapBundle(controllerService.getBundleCoordinate()));
versionedService.setComments(controllerService.getComments());
+
versionedService.setBulletinLevel(controllerService.getBulletinLevel().name());
versionedService.setControllerServiceApis(mapControllerServiceApis(controllerService));
versionedService.setProperties(mapProperties(controllerService,
serviceProvider));
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 0a8a7c3828..d060d16526 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
@@ -24,6 +24,7 @@ import org.apache.nifi.controller.ControllerService;
import org.apache.nifi.controller.LoggableComponent;
import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.logging.LogLevel;
import org.apache.nifi.nar.ExtensionManager;
import org.apache.nifi.components.ConfigVerificationResult;
@@ -141,6 +142,10 @@ public interface ControllerServiceNode extends
ComponentNode, VersionedComponent
String getComments();
+ void setBulletinLevel(LogLevel valueOf);
+
+ LogLevel getBulletinLevel();
+
void verifyCanEnable();
void verifyCanDisable();
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSnippet.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSnippet.java
index 6f4227d637..1490459ac7 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSnippet.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSnippet.java
@@ -239,6 +239,15 @@ public class StandardFlowSnippet implements FlowSnippet {
serviceNode.setAnnotationData(controllerServiceDTO.getAnnotationData());
serviceNode.setComments(controllerServiceDTO.getComments());
serviceNode.setName(controllerServiceDTO.getName());
+
+ if (controllerServiceDTO.getBulletinLevel() != null) {
+
serviceNode.setBulletinLevel(LogLevel.valueOf(controllerServiceDTO.getBulletinLevel()));
+ } else {
+ // this situation exists for backward compatibility with
nifi 1.16 and earlier where controller services do not have bulletinLevels set
in flow.xml/flow.json
+ // and bulletinLevels are at the WARN level by default
+ serviceNode.setBulletinLevel(LogLevel.WARN);
+ }
+
if (!topLevel) {
serviceNode.setVersionedComponentId(controllerServiceDTO.getVersionedComponentId());
}
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/flow/StandardFlowManager.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/flow/StandardFlowManager.java
index 4a88d40f26..f73f6141d4 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/flow/StandardFlowManager.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/flow/StandardFlowManager.java
@@ -487,8 +487,7 @@ public class StandardFlowManager extends
AbstractFlowManager implements FlowMana
LogRepositoryFactory.getRepository(serviceNode.getIdentifier()).setLogger(serviceNode.getLogger());
if (registerLogObserver) {
- // Register log observer to provide bulletins when reporting task
logs anything at WARN level or above
-
logRepository.addObserver(StandardProcessorNode.BULLETIN_OBSERVER_ID,
LogLevel.WARN, new ControllerServiceLogObserver(bulletinRepository,
serviceNode));
+
logRepository.addObserver(StandardProcessorNode.BULLETIN_OBSERVER_ID,
serviceNode.getBulletinLevel(), new
ControllerServiceLogObserver(bulletinRepository, serviceNode));
}
if (firstTimeAdded) {
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/FlowFromDOMFactory.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/FlowFromDOMFactory.java
index 838f765478..c548ef7337 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/FlowFromDOMFactory.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/FlowFromDOMFactory.java
@@ -115,6 +115,7 @@ public class FlowFromDOMFactory {
dto.setVersionedComponentId(getString(element,
"versionedComponentId"));
dto.setName(getString(element, "name"));
dto.setComments(getString(element, "comment"));
+ dto.setBulletinLevel(getString(element, "bulletinLevel"));
dto.setType(getString(element, "class"));
dto.setBundle(getBundle(DomUtils.getChild(element, "bundle")));
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/StandardFlowSerializer.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/StandardFlowSerializer.java
index cf11808932..aeb5f33fe2 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/StandardFlowSerializer.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/StandardFlowSerializer.java
@@ -624,6 +624,7 @@ public class StandardFlowSerializer implements
FlowSerializer<Document> {
addTextElement(serviceElement, "versionedComponentId",
serviceNode.getVersionedComponentId());
addTextElement(serviceElement, "name", serviceNode.getName());
addTextElement(serviceElement, "comment", serviceNode.getComments());
+ addTextElement(serviceElement, "bulletinLevel",
serviceNode.getBulletinLevel().toString());
addTextElement(serviceElement, "class",
serviceNode.getCanonicalClassName());
addBundle(serviceElement, serviceNode.getBundleCoordinate());
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 9f7991926d..48c69824aa 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
@@ -68,6 +68,7 @@ import org.apache.nifi.groups.ComponentIdGenerator;
import org.apache.nifi.groups.ComponentScheduler;
import org.apache.nifi.groups.FlowSynchronizationOptions;
import org.apache.nifi.groups.ProcessGroup;
+import org.apache.nifi.logging.LogLevel;
import org.apache.nifi.nar.ExtensionManager;
import org.apache.nifi.parameter.Parameter;
import org.apache.nifi.parameter.ParameterContext;
@@ -753,6 +754,14 @@ public class VersionedFlowSynchronizer implements
FlowSynchronizer {
serviceNode.setAnnotationData(versionedControllerService.getAnnotationData());
serviceNode.setComments(versionedControllerService.getComments());
+ if (versionedControllerService.getBulletinLevel() != null) {
+
serviceNode.setBulletinLevel(LogLevel.valueOf(versionedControllerService.getBulletinLevel()));
+ } else {
+ // this situation exists for backward compatibility with nifi
1.16 and earlier where controller services do not have bulletinLevels set in
flow.xml/flow.json
+ // and bulletinLevels are at the WARN level by default
+ serviceNode.setBulletinLevel(LogLevel.WARN);
+ }
+
final Set<String> sensitiveDynamicPropertyNames =
getSensitiveDynamicPropertyNames(serviceNode, versionedControllerService);
final Map<String, String> decryptedProperties =
decryptProperties(versionedControllerService.getProperties(), encryptor);
serviceNode.setProperties(decryptedProperties, false,
sensitiveDynamicPropertyNames);
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/ControllerServiceLoader.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/ControllerServiceLoader.java
index 1907fe7a98..295d825cc3 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/ControllerServiceLoader.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/ControllerServiceLoader.java
@@ -23,6 +23,7 @@ import
org.apache.nifi.controller.serialization.FlowEncodingVersion;
import org.apache.nifi.controller.serialization.FlowFromDOMFactory;
import org.apache.nifi.encrypt.PropertyEncryptor;
import org.apache.nifi.groups.ProcessGroup;
+import org.apache.nifi.logging.LogLevel;
import org.apache.nifi.reporting.BulletinRepository;
import org.apache.nifi.util.BundleUtils;
import org.apache.nifi.util.DomUtils;
@@ -175,6 +176,7 @@ public class ControllerServiceLoader {
controllerService.getBundleCoordinate(),
Collections.emptySet(), false, true, null);
clone.setName(controllerService.getName());
clone.setComments(controllerService.getComments());
+ clone.setBulletinLevel(controllerService.getBulletinLevel());
if (controllerService.getProperties() != null) {
Map<String,String> properties = new HashMap<>();
@@ -206,6 +208,15 @@ public class ControllerServiceLoader {
final ControllerServiceNode node =
flowController.getFlowManager().createControllerService(dto.getType(),
dto.getId(), coordinate, Collections.emptySet(), false, true, null);
node.setName(dto.getName());
node.setComments(dto.getComments());
+
+ if (dto.getBulletinLevel() != null) {
+ node.setBulletinLevel(LogLevel.valueOf(dto.getBulletinLevel()));
+ } else {
+ // this situation exists for backward compatibility with nifi 1.16
and earlier where controller services do not have bulletinLevels set in
flow.xml/flow.json
+ // and bulletinLevels are at the WARN level by default
+ node.setBulletinLevel(LogLevel.WARN);
+ }
+
node.setVersionedComponentId(dto.getVersionedComponentId());
return node;
}
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java
index 4aeb52661d..6601f7a8aa 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java
@@ -735,6 +735,7 @@ public class FingerprintFactory {
addBundleFingerprint(builder, dto.getBundle());
builder.append(dto.getComments());
+ builder.append(dto.getBulletinLevel());
builder.append(dto.getAnnotationData());
builder.append(dto.getState());
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/resources/FlowConfiguration.xsd
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/resources/FlowConfiguration.xsd
index 3605b4f7ba..2962962817 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/resources/FlowConfiguration.xsd
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/resources/FlowConfiguration.xsd
@@ -502,6 +502,7 @@
<xs:element name="versionedComponentId" type="NonEmptyStringType"
minOccurs="0" maxOccurs="1" />
<xs:element name="name" type="NonEmptyStringType" />
<xs:element name="comment" type="xs:string" />
+ <xs:element name="bulletinLevel" type="LogLevel" minOccurs="0"
maxOccurs="1" />
<xs:element name="class" type="NonEmptyStringType" />
<xs:element name="bundle" type="BundleType" />
<xs:element name="enabled" type="xs:boolean" />
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
index 595f0a12d9..385178fb12 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
@@ -821,13 +821,15 @@ public class TestFlowController {
assertEquals(ServiceA.class.getCanonicalName(),
controllerServiceNode.getCanonicalClassName());
assertEquals(ServiceA.class.getSimpleName(),
controllerServiceNode.getComponentType());
assertEquals(ServiceA.class.getCanonicalName(),
controllerServiceNode.getComponent().getClass().getCanonicalName());
+ assertEquals(LogLevel.WARN, controllerServiceNode.getBulletinLevel());
controller.getReloadComponent().reload(controllerServiceNode,
ServiceB.class.getName(), coordinate, Collections.emptySet());
- // ids and coordinate should stay the same
+ // ids, coordinate and bulletin Level should stay the same
assertEquals(id, controllerServiceNode.getIdentifier());
assertEquals(id, controllerServiceNode.getComponent().getIdentifier());
assertEquals(coordinate.getCoordinate(),
controllerServiceNode.getBundleCoordinate().getCoordinate());
+ assertEquals(LogLevel.WARN, controllerServiceNode.getBulletinLevel());
// in this test we happened to change between two services that have
different canonical class names
// but in the running application the DAO layer would call
verifyCanUpdateBundle and would prevent this so
@@ -1133,6 +1135,7 @@ public class TestFlowController {
csDto.setState(controllerServiceNode.getState().name());
csDto.setAnnotationData(controllerServiceNode.getAnnotationData());
csDto.setComments(controllerServiceNode.getComments());
+
csDto.setBulletinLevel(controllerServiceNode.getBulletinLevel().name());
csDto.setPersistsState(controllerServiceNode.getControllerServiceImplementation().getClass().isAnnotationPresent(Stateful.class));
csDto.setRestricted(controllerServiceNode.isRestricted());
csDto.setExtensionMissing(controllerServiceNode.isExtensionMissing());
@@ -1164,6 +1167,7 @@ public class TestFlowController {
csDto.setState(controllerServiceNode.getState().name());
csDto.setAnnotationData(controllerServiceNode.getAnnotationData());
csDto.setComments(controllerServiceNode.getComments());
+
csDto.setBulletinLevel(controllerServiceNode.getBulletinLevel().name());
csDto.setPersistsState(controllerServiceNode.getControllerServiceImplementation().getClass().isAnnotationPresent(Stateful.class));
csDto.setRestricted(controllerServiceNode.isRestricted());
csDto.setExtensionMissing(controllerServiceNode.isExtensionMissing());
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapperTest.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapperTest.java
index e366635474..9be810635f 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapperTest.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapperTest.java
@@ -519,6 +519,7 @@ public class NiFiRegistryFlowMapperTest {
when(controllerServiceNode.getBundleCoordinate()).thenReturn(mock(BundleCoordinate.class));
when(controllerServiceNode.getControllerServiceImplementation()).thenReturn(mock(ControllerService.class));
when(controllerServiceNode.getProperties()).thenReturn(Collections.emptyMap());
+
when(controllerServiceNode.getBulletinLevel()).thenReturn(LogLevel.WARN);
return controllerServiceNode;
}
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/conf/processor-with-cs-flow-0.7.0.xml
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/conf/processor-with-cs-flow-0.7.0.xml
index 7703a0b272..7440f61afc 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/conf/processor-with-cs-flow-0.7.0.xml
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/conf/processor-with-cs-flow-0.7.0.xml
@@ -48,6 +48,7 @@
<id>edf22ee5-376a-46dc-a38a-919351124457</id>
<name>ControllerService</name>
<comment/>
+ <bulletinLevel>WARN</bulletinLevel>
<class>org.apache.nifi.controller.service.mock.ServiceD</class>
<enabled>false</enabled>
<property>
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/conf/reporting-task-with-cs-flow-0.7.0.xml
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/conf/reporting-task-with-cs-flow-0.7.0.xml
index b9cff579fb..272616ec5e 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/conf/reporting-task-with-cs-flow-0.7.0.xml
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/conf/reporting-task-with-cs-flow-0.7.0.xml
@@ -48,6 +48,7 @@
<id>edf22ee5-376a-46dc-a38a-919351124456</id>
<name>ControllerService</name>
<comment/>
+ <bulletinLevel>WARN</bulletinLevel>
<class>org.apache.nifi.controller.service.mock.ServiceD</class>
<enabled>false</enabled>
<property>
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ControllerServiceAuditor.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ControllerServiceAuditor.java
index df764e5b5a..74aa6d62a6 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ControllerServiceAuditor.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ControllerServiceAuditor.java
@@ -62,6 +62,7 @@ public class ControllerServiceAuditor extends NiFiAuditor {
private static final String NAME = "Name";
private static final String ANNOTATION_DATA = "Annotation Data";
private static final String EXTENSION_VERSION = "Extension Version";
+ private static final String BULLETIN_LEVEL = "Bulletin Level";
/**
* Audits the creation of controller service via createControllerService().
@@ -436,6 +437,9 @@ public class ControllerServiceAuditor extends NiFiAuditor {
if (controllerServiceDTO.getComments() != null) {
values.put(COMMENTS, controllerService.getComments());
}
+ if (controllerServiceDTO.getBulletinLevel() != null) {
+ values.put(BULLETIN_LEVEL,
controllerService.getBulletinLevel().name());
+ }
return values;
}
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
index 724fef5df7..caa3c88d09 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
@@ -1635,6 +1635,7 @@ public final class DtoFactory {
dto.setState(controllerServiceNode.getState().name());
dto.setAnnotationData(controllerServiceNode.getAnnotationData());
dto.setComments(controllerServiceNode.getComments());
+ dto.setBulletinLevel(controllerServiceNode.getBulletinLevel().name());
dto.setPersistsState(controllerServiceClass.isAnnotationPresent(Stateful.class));
dto.setSupportsSensitiveDynamicProperties(controllerServiceNode.isSupportsSensitiveDynamicProperties());
dto.setRestricted(controllerServiceNode.isRestricted());
@@ -4128,6 +4129,7 @@ public final class DtoFactory {
copy.setId(original.getId());
copy.setParentGroupId(original.getParentGroupId());
copy.setName(original.getName());
+ copy.setBulletinLevel(original.getBulletinLevel());
copy.setProperties(copy(original.getProperties()));
copy.setSensitiveDynamicPropertyNames(copy(original.getSensitiveDynamicPropertyNames()));
copy.setReferencingComponents(copy(original.getReferencingComponents()));
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java
index 5d37af3fcf..1be14442a4 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java
@@ -33,6 +33,7 @@ import
org.apache.nifi.controller.service.ControllerServiceState;
import org.apache.nifi.controller.service.StandardConfigurationContext;
import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.logging.LogLevel;
import org.apache.nifi.logging.LogRepository;
import org.apache.nifi.logging.repository.NopLogRepository;
import org.apache.nifi.nar.ExtensionManager;
@@ -326,7 +327,8 @@ public class StandardControllerServiceDAO extends
ComponentDAO implements Contro
controllerServiceDTO.getAnnotationData(),
controllerServiceDTO.getComments(),
controllerServiceDTO.getProperties(),
- controllerServiceDTO.getBundle())) {
+ controllerServiceDTO.getBundle(),
+ controllerServiceDTO.getBulletinLevel())) {
modificationRequest = true;
// validate the request
@@ -356,6 +358,7 @@ public class StandardControllerServiceDAO extends
ComponentDAO implements Contro
final String annotationData = controllerServiceDTO.getAnnotationData();
final String comments = controllerServiceDTO.getComments();
final Map<String, String> properties =
controllerServiceDTO.getProperties();
+ final String bulletinLevel = controllerServiceDTO.getBulletinLevel();
controllerService.pauseValidationTrigger(); // avoid causing
validation to be triggered multiple times
try {
@@ -372,6 +375,9 @@ public class StandardControllerServiceDAO extends
ComponentDAO implements Contro
final Set<String> sensitiveDynamicPropertyNames =
controllerServiceDTO.getSensitiveDynamicPropertyNames();
controllerService.setProperties(properties, false,
sensitiveDynamicPropertyNames == null ? Collections.emptySet() :
sensitiveDynamicPropertyNames);
}
+ if (isNotNull(bulletinLevel)) {
+
controllerService.setBulletinLevel(LogLevel.valueOf(bulletinLevel));
+ }
} finally {
controllerService.resumeValidationTrigger();
}
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/controller-service-configuration.jsp
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/controller-service-configuration.jsp
index b645425cdd..aba320ffb1 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/controller-service-configuration.jsp
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/controller-service-configuration.jsp
@@ -50,6 +50,21 @@
<div class="setting-name">Supports Controller
Service</div>
<div id="controller-service-compatible-apis"
class="setting-field"></div>
</div>
+ <div class="setting">
+ <div class="bulletin-setting">
+ <div class="setting-name">
+ Bulletin level
+ <div class="fa fa-question-circle" alt="Info"
title="The level at which this controller service will generate
bulletins."></div>
+ </div>
+ <div class="controller-service-editable
setting-field">
+ <div
id="controller-service-bulletin-level-combo"></div>
+ </div>
+ <div class="controller-service-read-only
setting-field hidden">
+ <span
id="read-only-controller-service-bulletin-level"></span>
+ </div>
+ </div>
+ <div class="clear"></div>
+ </div>
</div>
<div class="spacer"> </div>
<div class="settings-right">
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
index 9b3a902ac6..086f31f7ff 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
@@ -98,6 +98,9 @@
if ($('#controller-service-comments').val() !==
entity.component['comments']) {
return true;
}
+ if
($('#controller-service-bulletin-level-combo').combo('getSelectedOption').value
!== (entity.component['bulletinLevel'] + '')) {
+ return true;
+ }
// defer to the properties
return
$('#controller-service-properties').propertytable('isSaveRequired');
@@ -114,6 +117,7 @@
var controllerServiceDto = {};
controllerServiceDto['id'] = $('#controller-service-id').text();
controllerServiceDto['name'] = $('#controller-service-name').val();
+ controllerServiceDto['bulletinLevel'] =
$('#controller-service-bulletin-level-combo').combo('getSelectedOption').value;
controllerServiceDto['comments'] =
$('#controller-service-comments').val();
// set the properties
@@ -1858,6 +1862,27 @@
}
}
});
+
+ // initialize the bulletin combo
+ $('#controller-service-bulletin-level-combo').combo({
+ options: [{
+ text: 'DEBUG',
+ value: 'DEBUG'
+ }, {
+ text: 'INFO',
+ value: 'INFO'
+ }, {
+ text: 'WARN',
+ value: 'WARN'
+ }, {
+ text: 'ERROR',
+ value: 'ERROR'
+ }, {
+ text: 'NONE',
+ value: 'NONE'
+ }]
+ });
+
// initialize the enable scope combo
$('#enable-controller-service-scope').combo({
@@ -2005,6 +2030,11 @@
$('#controller-service-name').val(controllerService['name']);
$('#controller-service-comments').val(controllerService['comments']);
+ // select the appropriate bulletin level
+
$('#controller-service-bulletin-level-combo').combo('setSelectedOption', {
+ value: controllerService['bulletinLevel']
+ });
+
// set the implemented apis
if
(!nfCommon.isEmpty(controllerService['controllerServiceApis'])) {
var formattedControllerServiceApis =
nfCommon.getFormattedServiceApis(controllerService['controllerServiceApis']);
@@ -2193,6 +2223,7 @@
nfCommon.populateField('controller-service-id',
controllerService['id']);
nfCommon.populateField('controller-service-type',
nfCommon.formatType(controllerService));
nfCommon.populateField('controller-service-bundle',
nfCommon.formatBundle(controllerService['bundle']));
+
nfCommon.populateField('read-only-controller-service-bulletin-level',
controllerService['bulletinLevel']);
nfCommon.populateField('read-only-controller-service-name',
controllerService['name']);
nfCommon.populateField('read-only-controller-service-comments',
controllerService['comments']);
diff --git
a/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java
b/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java
index 5fff2e84fc..f8da42e777 100644
---
a/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java
+++
b/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java
@@ -266,6 +266,7 @@ public class StandardFlowComparator implements
FlowComparator {
addIfDifferent(differences, DifferenceType.BUNDLE_CHANGED, serviceA,
serviceB, VersionedControllerService::getBundle);
compareProperties(serviceA, serviceB, serviceA.getProperties(),
serviceB.getProperties(), serviceA.getPropertyDescriptors(),
serviceB.getPropertyDescriptors(), differences);
addIfDifferent(differences, DifferenceType.SCHEDULED_STATE_CHANGED,
serviceA, serviceB, VersionedControllerService::getScheduledState);
+ addIfDifferent(differences, DifferenceType.BULLETIN_LEVEL_CHANGED,
serviceA, serviceB, VersionedControllerService::getBulletinLevel, true, "WARN");
}
private String decrypt(final String value, final
VersionedPropertyDescriptor descriptor) {
diff --git
a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/VersionedFlowBuilder.java
b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/VersionedFlowBuilder.java
index 7f38166919..08c40fbb81 100644
---
a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/VersionedFlowBuilder.java
+++
b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/VersionedFlowBuilder.java
@@ -226,6 +226,7 @@ public class VersionedFlowBuilder {
service.setGroupIdentifier(group.getIdentifier());
service.setIdentifier(UUID.randomUUID().toString());
service.setName(type);
+ service.setBulletinLevel("WARN");
service.setPosition(new Position(0, 0));
service.setProperties(new HashMap<>());
service.setPropertyDescriptors(new HashMap<>());