exceptionfactory commented on code in PR #9995:
URL: https://github.com/apache/nifi/pull/9995#discussion_r2139057374


##########
nifi-extension-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/kinesis/stream/pause/StandardRecordProcessorBlocker.java:
##########
@@ -17,19 +17,57 @@
 package org.apache.nifi.processors.aws.kinesis.stream.pause;
 
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
 
+/**
+ * Standard implementation of {@link RecordProcessorBlocker} that allows 
blocking calls to {@link #await()} by:
+ * <ul>
+ *     <li>explicit call to {@link #block()}</li>
+ *     <li>timeout since last call to {@link #unblock()}</li>
+ * </ul>
+ * Unblocking is done by calling {@link #unblock()} or {@link 
#unblockAndDisableTimeout()}. The latter is used to disable the timeout 
mechanism to allow shutdown of background threads that could
+ * otherwise block indefinitely due to no calls to {@link #unblock()}.
+ */
 public class StandardRecordProcessorBlocker implements RecordProcessorBlocker {
 
     private CountDownLatch blocker = new CountDownLatch(0);
 
+    static final long BLOCK_AFTER_TIMEOUT_MILLIS = 
TimeUnit.SECONDS.toMillis(2);
+    private final Supplier<Long> timestampProvider;
+    private long timeoutAnchor = 0L;

Review Comment:
   The naming of this property is unclear, it should be renamed to something 
that more clearly describes its purpose.



##########
nifi-extension-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/kinesis/stream/pause/StandardRecordProcessorBlocker.java:
##########
@@ -38,7 +76,17 @@ public synchronized void block() {
                 : new CountDownLatch(1);
     }
 
-    public synchronized void unblock() {
+    public void unblock() {
+        unblockPrivate(timestampProvider.get());
+    }
+
+    public void unblockAndDisableTimeout() {
+        unblockPrivate(Long.MAX_VALUE);
+    }
+
+    private synchronized void unblockPrivate(final long newTimeoutAnchor) {

Review Comment:
   Use of `Private` in the method name should be avoided. `Internal` could 
work, but better to be more descriptive, such as `countDown()` based on what 
the method is doing.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to