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 66f94aa9a2f NIFI-16531 Added decoupled framework Reporter
Configuration (#11880)
66f94aa9a2f is described below
commit 66f94aa9a2f0154ad5279d91b3953072a66ed831
Author: David Handermann <[email protected]>
AuthorDate: Mon Nov 2 16:05:22 2026 -0600
NIFI-16531 Added decoupled framework Reporter Configuration (#11880)
- Fixed FlowActionReporter.onConfigured issue with SSLContext access
---
.../configuration/FlowControllerConfiguration.java | 70 ++----------
.../configuration/ReporterConfiguration.java | 120 +++++++++++++++++++++
2 files changed, 128 insertions(+), 62 deletions(-)
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/framework/configuration/FlowControllerConfiguration.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/framework/configuration/FlowControllerConfiguration.java
index 4ea40e13b60..be649bb82cc 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/framework/configuration/FlowControllerConfiguration.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/framework/configuration/FlowControllerConfiguration.java
@@ -16,9 +16,6 @@
*/
package org.apache.nifi.framework.configuration;
-import org.apache.nifi.action.FlowActionReporter;
-import org.apache.nifi.action.FlowActionReporterConfigurationContext;
-import org.apache.nifi.action.StandardFlowActionReporterConfigurationContext;
import org.apache.nifi.admin.service.AuditService;
import org.apache.nifi.asset.AssetComponentManager;
import org.apache.nifi.asset.AssetManager;
@@ -37,9 +34,6 @@ import org.apache.nifi.controller.FlowController;
import org.apache.nifi.controller.StandardFlowService;
import org.apache.nifi.controller.leader.election.LeaderElectionManager;
import org.apache.nifi.controller.metrics.ComponentMetricReporter;
-import
org.apache.nifi.controller.metrics.ComponentMetricReporterConfigurationContext;
-import org.apache.nifi.controller.metrics.DefaultComponentMetricReporter;
-import
org.apache.nifi.controller.metrics.StandardComponentMetricReporterConfigurationContext;
import org.apache.nifi.controller.repository.metrics.RingBufferEventRepository;
import
org.apache.nifi.controller.status.history.JsonNodeStatusHistoryDumpFactory;
import org.apache.nifi.controller.status.history.StatusHistoryDumpFactory;
@@ -92,10 +86,6 @@ import javax.net.ssl.X509TrustManager;
@Configuration
public class FlowControllerConfiguration {
- private static final String FLOW_ACTION_REPORTER_IMPLEMENTATION =
"nifi.flow.action.reporter.implementation";
-
- private static final String COMPONENT_METRIC_REPORTER_IMPLEMENTATION =
"nifi.component.metric.reporter.implementation";
-
private NiFiProperties properties;
private ExtensionDiscoveringManager extensionManager;
private AuditService auditService;
@@ -107,6 +97,7 @@ public class FlowControllerConfiguration {
private X509TrustManager trustManager;
private StateManagerProvider stateManagerProvider;
private BulletinRepository bulletinRepository;
+ private ComponentMetricReporter componentMetricReporter;
private NodeProtocolSender nodeProtocolSender;
private NodeProtocolSenderListener nodeProtocolSenderListener;
private HeartbeatMonitor heartbeatMonitor;
@@ -153,6 +144,11 @@ public class FlowControllerConfiguration {
this.bulletinRepository = bulletinRepository;
}
+ @Autowired
+ public void setComponentMetricReporter(final ComponentMetricReporter
componentMetricReporter) {
+ this.componentMetricReporter = componentMetricReporter;
+ }
+
@Autowired(required = false)
public void setConnectorRequestReplicator(final ConnectorRequestReplicator
connectorRequestReplicator) {
this.connectorRequestReplicator = connectorRequestReplicator;
@@ -212,7 +208,7 @@ public class FlowControllerConfiguration {
properties,
authorizer,
auditService,
- componentMetricReporter(),
+ componentMetricReporter,
propertyEncryptionProvider(),
bulletinRepository,
extensionManager,
@@ -228,7 +224,7 @@ public class FlowControllerConfiguration {
properties,
authorizer,
auditService,
- componentMetricReporter(),
+ componentMetricReporter,
propertyEncryptionProvider(),
nodeProtocolSender,
bulletinRepository,
@@ -489,56 +485,6 @@ public class FlowControllerConfiguration {
return new StandardAssetComponentManager(flowController());
}
- /**
- * Flow Action Reporter configured from NiFi Application Properties
- *
- * @return Flow Action Reporter
- */
- @Bean
- public FlowActionReporter flowActionReporter() {
- final FlowActionReporter flowActionReporter;
-
- final String configuredClassName =
properties.getProperty(FLOW_ACTION_REPORTER_IMPLEMENTATION);
- if (configuredClassName == null || configuredClassName.isBlank()) {
- flowActionReporter = null;
- } else {
- try {
- flowActionReporter =
NarThreadContextClassLoader.createInstance(extensionManager,
configuredClassName, FlowActionReporter.class, properties);
- final FlowActionReporterConfigurationContext
configurationContext = new
StandardFlowActionReporterConfigurationContext(sslContext, trustManager);
- flowActionReporter.onConfigured(configurationContext);
- } catch (final Exception e) {
- throw new IllegalStateException("Failed to create
FlowActionReporter with class [%s]".formatted(configuredClassName), e);
- }
- }
-
- return flowActionReporter;
- }
-
- /**
- * Component Metric Reporter configured from NiFi Application Properties
- *
- * @return Component Metric Reporter
- */
- @Bean
- public ComponentMetricReporter componentMetricReporter() {
- final ComponentMetricReporter componentMetricReporter;
-
- final String configuredClassName =
properties.getProperty(COMPONENT_METRIC_REPORTER_IMPLEMENTATION);
- if (configuredClassName == null || configuredClassName.isBlank()) {
- componentMetricReporter = new DefaultComponentMetricReporter();
- } else {
- try {
- componentMetricReporter =
NarThreadContextClassLoader.createInstance(extensionManager,
configuredClassName, ComponentMetricReporter.class, properties);
- final ComponentMetricReporterConfigurationContext
configurationContext = new
StandardComponentMetricReporterConfigurationContext(sslContext, trustManager);
- componentMetricReporter.onConfigured(configurationContext);
- } catch (final Exception e) {
- throw new IllegalStateException("Failed to create
ComponentMetricReporter with class [%s]".formatted(configuredClassName), e);
- }
- }
-
- return componentMetricReporter;
- }
-
/**
* Property Encryption Provider configured from NiFi Application
Properties. Installations that do not configure an
* implementation class use the password-based provider, which derives a
secret key from the sensitive properties key.
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/framework/configuration/ReporterConfiguration.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/framework/configuration/ReporterConfiguration.java
new file mode 100644
index 00000000000..5b1daa64f56
--- /dev/null
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/framework/configuration/ReporterConfiguration.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.framework.configuration;
+
+import org.apache.nifi.action.FlowActionReporter;
+import org.apache.nifi.action.FlowActionReporterConfigurationContext;
+import org.apache.nifi.action.StandardFlowActionReporterConfigurationContext;
+import org.apache.nifi.controller.metrics.ComponentMetricReporter;
+import
org.apache.nifi.controller.metrics.ComponentMetricReporterConfigurationContext;
+import org.apache.nifi.controller.metrics.DefaultComponentMetricReporter;
+import
org.apache.nifi.controller.metrics.StandardComponentMetricReporterConfigurationContext;
+import org.apache.nifi.nar.ExtensionDiscoveringManager;
+import org.apache.nifi.nar.NarThreadContextClassLoader;
+import org.apache.nifi.util.NiFiProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.X509TrustManager;
+
+/**
+ * Framework Extension Reporter Configuration independent of Flow Controller
Configuration to avoid dependency resolution issues
+ */
+@Configuration
+public class ReporterConfiguration {
+
+ private static final String FLOW_ACTION_REPORTER_IMPLEMENTATION =
"nifi.flow.action.reporter.implementation";
+
+ private static final String COMPONENT_METRIC_REPORTER_IMPLEMENTATION =
"nifi.component.metric.reporter.implementation";
+
+ private NiFiProperties properties;
+
+ private ExtensionDiscoveringManager extensionManager;
+
+ private SSLContext sslContext;
+
+ private X509TrustManager trustManager;
+
+ @Autowired
+ public void setProperties(final NiFiProperties properties) {
+ this.properties = properties;
+ }
+
+ @Autowired
+ public void setExtensionManager(final ExtensionDiscoveringManager
extensionManager) {
+ this.extensionManager = extensionManager;
+ }
+
+ @Autowired(required = false)
+ public void setSslContext(final SSLContext sslContext) {
+ this.sslContext = sslContext;
+ }
+
+ @Autowired(required = false)
+ public void setTrustManager(final X509TrustManager trustManager) {
+ this.trustManager = trustManager;
+ }
+
+ /**
+ * Flow Action Reporter configured from NiFi Application Properties
+ *
+ * @return Flow Action Reporter
+ */
+ @Bean
+ public FlowActionReporter flowActionReporter() {
+ final String configuredClassName =
properties.getProperty(FLOW_ACTION_REPORTER_IMPLEMENTATION);
+ if (configuredClassName == null || configuredClassName.isBlank()) {
+ return null;
+ }
+
+ try {
+ final FlowActionReporter flowActionReporter =
NarThreadContextClassLoader.createInstance(extensionManager,
configuredClassName, FlowActionReporter.class, properties);
+ final FlowActionReporterConfigurationContext configurationContext
= new StandardFlowActionReporterConfigurationContext(sslContext, trustManager);
+ flowActionReporter.onConfigured(configurationContext);
+ return flowActionReporter;
+ } catch (final Exception e) {
+ throw new IllegalStateException("Failed to create
FlowActionReporter with class [%s]".formatted(configuredClassName), e);
+ }
+ }
+
+ /**
+ * Component Metric Reporter configured from NiFi Application Properties
+ *
+ * @return Component Metric Reporter
+ */
+ @Bean
+ public ComponentMetricReporter componentMetricReporter() {
+ final ComponentMetricReporter componentMetricReporter;
+
+ final String configuredClassName =
properties.getProperty(COMPONENT_METRIC_REPORTER_IMPLEMENTATION);
+ if (configuredClassName == null || configuredClassName.isBlank()) {
+ componentMetricReporter = new DefaultComponentMetricReporter();
+ } else {
+ try {
+ componentMetricReporter =
NarThreadContextClassLoader.createInstance(extensionManager,
configuredClassName, ComponentMetricReporter.class, properties);
+ final ComponentMetricReporterConfigurationContext
configurationContext = new
StandardComponentMetricReporterConfigurationContext(sslContext, trustManager);
+ componentMetricReporter.onConfigured(configurationContext);
+ } catch (final Exception e) {
+ throw new IllegalStateException("Failed to create
ComponentMetricReporter with class [%s]".formatted(configuredClassName), e);
+ }
+ }
+
+ return componentMetricReporter;
+ }
+}