You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "nandorsoma (via GitHub)" <gi...@apache.org> on 2023/03/10 12:12:53 UTC

[GitHub] [nifi] nandorsoma opened a new pull request, #7027: NIFI-11264 Improve logging in list processors and fix ListFile's description

nandorsoma opened a new pull request, #7027:
URL: https://github.com/apache/nifi/pull/7027

   <!-- 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. -->
   
   # Summary
   
   [NIFI-11264](https://issues.apache.org/jira/browse/NIFI-11264)
   
   There were a few cases where the ListFile processor yielded, and it was hard to guess the reason without additional logs. I added those missing logs and fixed the description of the ListFile processor.
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [x] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### Pull Request Tracking
   
   - [x] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
   - [x] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
   
   ### Pull Request Formatting
   
   - [x] Pull Request based on current revision of the `main` branch
   - [x] Pull Request refers to a feature branch with one commit containing changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request creation.
   
   ### Build
   
   - [x] Build completed using `mvn clean install -P contrib-check`
     - [x] JDK 11
     - [ ] JDK 17
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [x] Documentation formatting appears as expected in rendered files
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] nandorsoma commented on pull request #7027: NIFI-11264 Improve logging in list processors and fix ListFile's description

Posted by "nandorsoma (via GitHub)" <gi...@apache.org>.
nandorsoma commented on PR #7027:
URL: https://github.com/apache/nifi/pull/7027#issuecomment-1477021310

   Thank you for the review @Lehel44 and @exceptionfactory!
   I tend to agree that ending log messages with `.` is not a best practice. In my defense, I did that because it was a pattern in this file. I've changed the logs as requested and changed two more previously existing logs to be in sync. I found it reasonable in the other cases, so I didn't change them.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] Lehel44 commented on pull request #7027: NIFI-11264 Improve logging in list processors and fix ListFile's description

Posted by "Lehel44 (via GitHub)" <gi...@apache.org>.
Lehel44 commented on PR #7027:
URL: https://github.com/apache/nifi/pull/7027#issuecomment-1464112488

   Thanks for the contribution @nandorsoma. Reviewing.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory closed pull request #7027: NIFI-11264 Improve logging in list processors and fix ListFile's description

Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory closed pull request #7027: NIFI-11264 Improve logging in list processors and fix ListFile's description
URL: https://github.com/apache/nifi/pull/7027


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] Lehel44 commented on a diff in pull request #7027: NIFI-11264 Improve logging in list processors and fix ListFile's description

Posted by "Lehel44 (via GitHub)" <gi...@apache.org>.
Lehel44 commented on code in PR #7027:
URL: https://github.com/apache/nifi/pull/7027#discussion_r1138661819


##########
nifi-nar-bundles/nifi-extension-utils/nifi-listed-entity/src/main/java/org/apache/nifi/processor/util/list/AbstractListProcessor.java:
##########
@@ -761,6 +763,7 @@ public void listByTrackingTimestamps(final ProcessContext context, final Process
         }
 
         if (entityList == null || entityList.isEmpty()) {
+            getLogger().debug(String.format("There is no data to list with the criteria minTimestampToListMillis=%d. Yielding.", minTimestampToListMillis));

Review Comment:
   slf4j's api provides parameterized logging which can be used here instead of String::format.
   
   ```suggestion
               getLogger().debug("There is no data to list with the criteria minTimestampToListMillis={}. Yielding.", minTimestampToListMillis);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory commented on a diff in pull request #7027: NIFI-11264 Improve logging in list processors and fix ListFile's description

Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #7027:
URL: https://github.com/apache/nifi/pull/7027#discussion_r1139517753


##########
nifi-nar-bundles/nifi-extension-utils/nifi-listed-entity/src/main/java/org/apache/nifi/processor/util/list/AbstractListProcessor.java:
##########
@@ -761,6 +763,7 @@ public void listByTrackingTimestamps(final ProcessContext context, final Process
         }
 
         if (entityList == null || entityList.isEmpty()) {
+            getLogger().debug(String.format("There is no data to list with the criteria minTimestampToListMillis=%d. Yielding.", minTimestampToListMillis));

Review Comment:
   ```suggestion
               getLogger().debug("No data found matching minimum timestamp [{}]: yielding", minTimestampToListMillis));
   ```



##########
nifi-nar-bundles/nifi-extension-utils/nifi-listed-entity/src/main/java/org/apache/nifi/processor/util/list/AbstractListProcessor.java:
##########
@@ -571,6 +571,7 @@ public void listByNoTracking(final ProcessContext context, final ProcessSession
         }
 
         if (entityList == null || entityList.isEmpty()) {
+            getLogger().debug("There is no data to list. Yielding.");

Review Comment:
   ```suggestion
               getLogger().debug("No data found: yielding");
   ```



##########
nifi-nar-bundles/nifi-extension-utils/nifi-listed-entity/src/main/java/org/apache/nifi/processor/util/list/AbstractListProcessor.java:
##########
@@ -817,11 +820,20 @@ public void listByTrackingTimestamps(final ProcessContext context, final Process
                  *   - If we have not eclipsed the minimal listing lag needed due to being triggered too soon after the last run
                  *   - The latest listed entity timestamp is equal to the last processed time, meaning we handled those items originally passed over. No need to process it again.
                  */
-                final long  listingLagNanos = TimeUnit.MILLISECONDS.toNanos(listingLagMillis);
-                if (currentRunTimeNanos - lastRunTimeNanos < listingLagNanos
-                        || (latestListedEntryTimestampThisCycleMillis.equals(lastProcessedLatestEntryTimestampMillis)
-                        && orderedEntries.get(latestListedEntryTimestampThisCycleMillis).stream()
-                                .allMatch(entity -> latestIdentifiersProcessed.contains(entity.getIdentifier())))) {
+                final long listingLagNanos = TimeUnit.MILLISECONDS.toNanos(listingLagMillis);
+                final boolean minimalListingLagNotPassed = currentRunTimeNanos - lastRunTimeNanos < listingLagNanos;
+
+                if (minimalListingLagNotPassed) {
+                    getLogger().debug("Minimal listing lag has not passed. Yielding.");

Review Comment:
   ```suggestion
                       getLogger().debug("Minimal listing lag not passed: yielding");
   ```



##########
nifi-nar-bundles/nifi-extension-utils/nifi-listed-entity/src/main/java/org/apache/nifi/processor/util/list/AbstractListProcessor.java:
##########
@@ -738,6 +739,7 @@ public void listByTrackingTimestamps(final ProcessContext context, final Process
                 }
                 justElectedPrimaryNode = false;
                 if (noUpdateRequired) {
+                    getLogger().debug("Updating the timestamp of the last listed entry is not required. Yielding.");

Review Comment:
   ```suggestion
                       getLogger().debug("No update required for last listed entity: yielding");
   ```



##########
nifi-nar-bundles/nifi-extension-utils/nifi-listed-entity/src/main/java/org/apache/nifi/processor/util/list/AbstractListProcessor.java:
##########
@@ -817,11 +820,20 @@ public void listByTrackingTimestamps(final ProcessContext context, final Process
                  *   - If we have not eclipsed the minimal listing lag needed due to being triggered too soon after the last run
                  *   - The latest listed entity timestamp is equal to the last processed time, meaning we handled those items originally passed over. No need to process it again.
                  */
-                final long  listingLagNanos = TimeUnit.MILLISECONDS.toNanos(listingLagMillis);
-                if (currentRunTimeNanos - lastRunTimeNanos < listingLagNanos
-                        || (latestListedEntryTimestampThisCycleMillis.equals(lastProcessedLatestEntryTimestampMillis)
-                        && orderedEntries.get(latestListedEntryTimestampThisCycleMillis).stream()
-                                .allMatch(entity -> latestIdentifiersProcessed.contains(entity.getIdentifier())))) {
+                final long listingLagNanos = TimeUnit.MILLISECONDS.toNanos(listingLagMillis);
+                final boolean minimalListingLagNotPassed = currentRunTimeNanos - lastRunTimeNanos < listingLagNanos;
+
+                if (minimalListingLagNotPassed) {
+                    getLogger().debug("Minimal listing lag has not passed. Yielding.");
+                    context.yield();
+                    return;
+                }
+
+                final boolean latestListedEntryIsUpToDate = latestListedEntryTimestampThisCycleMillis.equals(lastProcessedLatestEntryTimestampMillis)
+                        && orderedEntries.get(latestListedEntryTimestampThisCycleMillis).stream().allMatch(entity -> latestIdentifiersProcessed.contains(entity.getIdentifier()));
+
+                if (latestListedEntryIsUpToDate) {
+                    getLogger().debug("Already listed the latest entry. Yielding.");

Review Comment:
   ```suggestion
                       getLogger().debug("Latest entry already listed with timestamp [{}]: yielding", latestListedEntryTimestampThisCycleMillis);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org