ajothomas commented on code in PR #1616:
URL: https://github.com/apache/samza/pull/1616#discussion_r927158579


##########
samza-core/src/main/java/org/apache/samza/container/RunLoop.java:
##########
@@ -805,6 +877,52 @@ private boolean checkEndOfStream() {
       return processingSspSet.isEmpty();
     }
 
+    private boolean shouldDrain() {
+      if (endOfStream) {
+        return false;
+      }
+
+      if (!pendingEnvelopeQueue.isEmpty()) {
+        PendingEnvelope pendingEnvelope = pendingEnvelopeQueue.peek();
+        IncomingMessageEnvelope envelope = pendingEnvelope.envelope;
+
+        if (envelope.isDrain()) {
+          final DrainMessage message = (DrainMessage) envelope.getMessage();
+          if (!message.getDeploymentId().equals(deploymentId)) {
+            // Removing the drain message from the pending queue as it doesn't 
match with the current deploymentId
+            // Removing it will ensure that it is not picked up by process()
+            pendingEnvelopeQueue.remove();
+          } else {
+            if (elasticityFactor <= 1) {
+              SystemStreamPartition ssp = envelope.getSystemStreamPartition();
+              processingSspSetToDrain.remove(ssp);
+            } else {
+              // if envelope contains drain message,

Review Comment:
   Added extra explanation.



-- 
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: commits-unsubscr...@samza.apache.org

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

Reply via email to