NIFI-16051 Propagate logging attributes down the process group tree#11372
Conversation
pvillard31
left a comment
There was a problem hiding this comment.
LGTM and happy to merge as-is but leaving two comments up for discussion
|
|
||
| for (final ProcessGroup childGroup : processGroups.values()) { | ||
| if (childGroup instanceof StandardProcessGroup standardChildGroup) { | ||
| standardChildGroup.setLoggingAttributes(); |
There was a problem hiding this comment.
Since setConnectorLoggingAttributes already recurses into every child and each child now also calls setLoggingAttributes(), each descendant gets recomputed once per ancestor level. Did you consider skipping this subtree recursion when it is invoked from the connector cascade, to avoid the repeated recomputation?
There was a problem hiding this comment.
Initially I was thinking that this happens rarely enough that added computation is not a problem, so I kept things simple, but on another thought maybe being explicit about it is a better idea. I know boolean arguments probably aren't ideal, but since similar pattern is also used for getControllerServices I added one here
|
|
||
| this.loggingAttributes = Map.copyOf(attributes); | ||
|
|
||
| for (final ProcessGroup childGroup : processGroups.values()) { |
There was a problem hiding this comment.
The sibling method setConnectorLoggingAttributes iterates getProcessGroups() (a read-locked copy) while this loop iterates processGroups.values() directly. Both are safe with a ConcurrentHashMap, but should we use getProcessGroups() here too for consistency?
pvillard31
left a comment
There was a problem hiding this comment.
LGTM and will merge assuming checks are green
Summary
NIFI-16051
Propagating the logging attributes down solves 2 issues:
Technically, the 1st issue could probably be fixed in the initialization process itself, but propagation fixes both & makes sure they are always synchronized.
Additionally moving from a mutating the map, to overriding with an immutable instance would make sure there are no partial reads.
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000VerifiedstatusPull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-check