jt2594838 commented on code in PR #17926:
URL: https://github.com/apache/iotdb/pull/17926#discussion_r3411768374


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingQueue.java:
##########
@@ -731,6 +710,43 @@ protected boolean onEvent() {
     return batches.onEvent(this::prefetchEvent);
   }
 
+  private synchronized boolean tryCommitCurrentTerminateEventIfPresent() {
+    if (Objects.isNull(currentTerminateEvent)) {
+      return false;
+    }
+    tryCommitCurrentTerminateEvent();
+    return true;
+  }
+
+  private synchronized boolean tryCommitCurrentTerminateEvent() {

Review Comment:
   The return value is not used?



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingQueue.java:
##########
@@ -731,6 +710,43 @@ protected boolean onEvent() {
     return batches.onEvent(this::prefetchEvent);
   }
 
+  private synchronized boolean tryCommitCurrentTerminateEventIfPresent() {
+    if (Objects.isNull(currentTerminateEvent)) {
+      return false;
+    }
+    tryCommitCurrentTerminateEvent();
+    return true;
+  }
+
+  private synchronized boolean tryCommitCurrentTerminateEvent() {
+    try {
+      batches.emitAll(this::prefetchEvent);
+    } catch (final Exception e) {
+      LOGGER.warn(
+          "Subscription: SubscriptionPrefetchingQueue {} failed to emit 
remaining events before "
+              + "committing PipeTerminateEvent {}.",
+          this,
+          currentTerminateEvent,
+          e);
+      return false;
+    }
+
+    if (!prefetchingQueue.isEmpty() || !inFlightEvents.isEmpty()) {
+      return false;
+    }
+
+    // Add mark completed hook only when all subscription events have been 
consumed.
+    currentTerminateEvent.addOnCommittedHook(this::markCompleted);
+    currentTerminateEvent.decreaseReferenceCount(
+        SubscriptionPrefetchingQueue.class.getName(), true);
+    LOGGER.info(
+        "Subscription: SubscriptionPrefetchingQueue {} commit 
PipeTerminateEvent {}",
+        this,
+        currentTerminateEvent);

Review Comment:
   i18n



-- 
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