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

pvillard31 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 e5f637bacb5 NIFI-15860 Added Registered Flow ID Version Path to MDC 
Attributes (#11163)
e5f637bacb5 is described below

commit e5f637bacb54956ebab77aa3538540ec2d8fd235
Author: David Handermann <[email protected]>
AuthorDate: Tue Apr 21 09:27:43 2026 -0500

    NIFI-15860 Added Registered Flow ID Version Path to MDC Attributes (#11163)
---
 .../apache/nifi/groups/StandardProcessGroup.java   | 40 ++++++++++++++++++++++
 .../nifi/groups/StandardProcessGroupTest.java      | 33 +++++++++++++++++-
 2 files changed, 72 insertions(+), 1 deletion(-)

diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
 
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
index 1dda6c26843..9f51aa82f0e 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
@@ -221,7 +221,9 @@ public final class StandardProcessGroup implements 
ProcessGroup {
     private static final String DEFAULT_BACKPRESSURE_DATA_SIZE = "1 GB";
     private static final Pattern INVALID_DIRECTORY_NAME_CHARACTERS = 
Pattern.compile("[\\s\\<\\>:\\'\\\"\\/\\\\\\|\\?\\*]");
     private static final String PATH_SEPARATOR = "/";
+    private static final String VERSION_SEPARATOR = ":";
     private static final String STANDARD_PROCESS_GROUP_NAME = 
"StandardProcessGroup";
+    private static final String UNREGISTERED_PATH_SEGMENT = "UNREGISTERED";
 
     private final Map<String, String> loggingAttributes = new 
ConcurrentHashMap<>();
     private volatile String logFileSuffix;
@@ -4660,6 +4662,10 @@ public final class StandardProcessGroup implements 
ProcessGroup {
         idPathBuilder.append(PATH_SEPARATOR);
         idPathBuilder.append(id);
 
+        final StringBuilder registeredFlowIdentifierPathBuilder = new 
StringBuilder();
+        final VersionControlInformation versionControlInformation = 
getVersionControlInformation();
+        boolean versionControlFound = 
appendRegisteredFlowIdentifierVersion(registeredFlowIdentifierPathBuilder, 
versionControlInformation);
+
         ProcessGroup parentProcessGroup = getParent();
         while (parentProcessGroup != null) {
             namePathBuilder.insert(0, PATH_SEPARATOR);
@@ -4668,6 +4674,12 @@ public final class StandardProcessGroup implements 
ProcessGroup {
             idPathBuilder.insert(0, PATH_SEPARATOR);
             idPathBuilder.insert(1, parentProcessGroup.getIdentifier());
 
+            final VersionControlInformation parentVersionControlInformation = 
parentProcessGroup.getVersionControlInformation();
+            final boolean parentVersionControlFound = 
appendRegisteredFlowIdentifierVersion(registeredFlowIdentifierPathBuilder, 
parentVersionControlInformation);
+            if (parentVersionControlFound) {
+                versionControlFound = true;
+            }
+
             parentProcessGroup = parentProcessGroup.getParent();
         }
 
@@ -4676,6 +4688,32 @@ public final class StandardProcessGroup implements 
ProcessGroup {
 
         final String namePath = namePathBuilder.toString();
         
loggingAttributes.put(LoggingAttribute.PROCESS_GROUP_NAME_PATH.attribute, 
namePath);
+
+        if (versionControlFound) {
+            final String registeredFlowIdentifierPath = 
registeredFlowIdentifierPathBuilder.toString();
+            
loggingAttributes.put(LoggingAttribute.REGISTERED_FLOW_IDENTIFIER_PATH.attribute,
 registeredFlowIdentifierPath);
+        }
+    }
+
+    private boolean appendRegisteredFlowIdentifierVersion(final StringBuilder 
pathBuilder, final VersionControlInformation versionControlInformation) {
+        final boolean versionControlFound;
+
+        pathBuilder.insert(0, PATH_SEPARATOR);
+        if (versionControlInformation == null) {
+            versionControlFound = false;
+            pathBuilder.insert(1, UNREGISTERED_PATH_SEGMENT);
+        } else {
+            versionControlFound = true;
+
+            final String version = versionControlInformation.getVersion();
+            pathBuilder.insert(1, version);
+            pathBuilder.insert(1, VERSION_SEPARATOR);
+
+            final String flowIdentifier = 
versionControlInformation.getFlowIdentifier();
+            pathBuilder.insert(1, flowIdentifier);
+        }
+
+        return versionControlFound;
     }
 
     enum LoggingAttribute {
@@ -4689,6 +4727,8 @@ public final class StandardProcessGroup implements 
ProcessGroup {
 
         REGISTERED_FLOW_IDENTIFIER("registeredFlowIdentifier"),
 
+        REGISTERED_FLOW_IDENTIFIER_PATH("registeredFlowIdentifierPath"),
+
         REGISTERED_FLOW_VERSION("registeredFlowVersion");
 
         private final String attribute;
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/groups/StandardProcessGroupTest.java
 
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/groups/StandardProcessGroupTest.java
index 0887de6c90d..3a57a120b8e 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/groups/StandardProcessGroupTest.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/groups/StandardProcessGroupTest.java
@@ -59,9 +59,11 @@ class StandardProcessGroupTest {
     private static final String PARENT_ID_PATH = 
"/87654321-1234/12345678-4321";
     private static final String PARENT_NAME = "ParentGroup";
     private static final String PARENT_NAME_PATH = "/ParentGroup/TestGroup";
+    private static final String PARENT_REGISTERED_FLOW_IDENTIFIER_PATH = 
"/87654321-4321:1.0.0/UNREGISTERED";
 
     private static final String REGISTERED_FLOW_IDENTIFIER = "87654321-4321";
     private static final String REGISTERED_FLOW_VERSION = "1.0.0";
+    private static final String REGISTERED_FLOW_IDENTIFIER_PATH = 
"/87654321-4321:1.0.0";
 
     @Mock
     private ControllerServiceProvider controllerServiceProvider;
@@ -177,6 +179,34 @@ class StandardProcessGroupTest {
         assertEquals(expected, loggingAttributes);
     }
 
+    @Test
+    void testGetLoggingAttributesWithParentVersionControlInformation() {
+        processGroup.setName(NAME);
+
+        
when(versionControlInformation.getFlowIdentifier()).thenReturn(REGISTERED_FLOW_IDENTIFIER);
+        
when(versionControlInformation.getVersion()).thenReturn(REGISTERED_FLOW_VERSION);
+
+        when(parentProcessGroup.getIdentifier()).thenReturn(PARENT_ID);
+        when(parentProcessGroup.getName()).thenReturn(PARENT_NAME);
+        
when(parentProcessGroup.getVersionControlInformation()).thenReturn(versionControlInformation);
+        processGroup.setParent(parentProcessGroup);
+
+        final Map<String, String> loggingAttributes = 
processGroup.getLoggingAttributes();
+
+        assertNotNull(loggingAttributes);
+        assertFalse(loggingAttributes.isEmpty());
+
+        final Map<String, String> expected = Map.of(
+                
StandardProcessGroup.LoggingAttribute.PROCESS_GROUP_ID.getAttribute(), ID,
+                
StandardProcessGroup.LoggingAttribute.PROCESS_GROUP_ID_PATH.getAttribute(), 
PARENT_ID_PATH,
+                
StandardProcessGroup.LoggingAttribute.PROCESS_GROUP_NAME.getAttribute(), NAME,
+                
StandardProcessGroup.LoggingAttribute.PROCESS_GROUP_NAME_PATH.getAttribute(), 
PARENT_NAME_PATH,
+                
StandardProcessGroup.LoggingAttribute.REGISTERED_FLOW_IDENTIFIER_PATH.getAttribute(),
 PARENT_REGISTERED_FLOW_IDENTIFIER_PATH
+        );
+
+        assertEquals(expected, loggingAttributes);
+    }
+
     @Test
     void testGetLoggingAttributesWithVersionControlInformation() {
         processGroup.setName(NAME);
@@ -197,7 +227,8 @@ class StandardProcessGroupTest {
                 
StandardProcessGroup.LoggingAttribute.PROCESS_GROUP_NAME.getAttribute(), NAME,
                 
StandardProcessGroup.LoggingAttribute.PROCESS_GROUP_NAME_PATH.getAttribute(), 
NAME_PATH,
                 
StandardProcessGroup.LoggingAttribute.REGISTERED_FLOW_IDENTIFIER.getAttribute(),
 REGISTERED_FLOW_IDENTIFIER,
-                
StandardProcessGroup.LoggingAttribute.REGISTERED_FLOW_VERSION.getAttribute(), 
REGISTERED_FLOW_VERSION
+                
StandardProcessGroup.LoggingAttribute.REGISTERED_FLOW_VERSION.getAttribute(), 
REGISTERED_FLOW_VERSION,
+                
StandardProcessGroup.LoggingAttribute.REGISTERED_FLOW_IDENTIFIER_PATH.getAttribute(),
 REGISTERED_FLOW_IDENTIFIER_PATH
         );
 
         assertEquals(expected, loggingAttributes);

Reply via email to