aglinxinyuan commented on code in PR #6522:
URL: https://github.com/apache/texera/pull/6522#discussion_r3649815699


##########
amber/src/test/python/core/architecture/handlers/control/test_end_worker_handler.py:
##########
@@ -0,0 +1,97 @@
+# 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.
+
+import asyncio
+from types import SimpleNamespace
+
+import pytest
+
+from core.architecture.handlers.control.end_worker_handler import 
EndWorkerHandler
+from core.models.internal_queue import DCMElement, InternalQueue
+from proto.org.apache.texera.amber.core import ActorVirtualIdentity, 
ChannelIdentity
+from proto.org.apache.texera.amber.engine.architecture.rpc import (
+    EmptyRequest,
+    EmptyReturn,
+)
+from proto.org.apache.texera.amber.engine.common import 
DirectControlMessagePayloadV2
+
+
+class TestEndWorkerHandler:
+    @pytest.fixture
+    def input_queue(self):
+        return InternalQueue()
+
+    @pytest.fixture
+    def handler(self, input_queue):
+        # ControlHandler.__init__ just stashes context; bypass the protobuf
+        # base class' __init__ by constructing via __new__.
+        instance = EndWorkerHandler.__new__(EndWorkerHandler)
+        instance.context = SimpleNamespace(input_queue=input_queue)
+        return instance

Review Comment:
   Done — switched to direct construction 
(`EndWorkerHandler(SimpleNamespace(input_queue=input_queue))`) and dropped the 
stale bypass comment. You are right that there was nothing to bypass — 
`ControlHandler.__init__` just stashes `context`.



##########
amber/src/main/python/core/architecture/handlers/control/end_worker_handler.py:
##########
@@ -37,13 +37,19 @@ async def end_worker(self, req: EmptyRequest) -> 
EmptyReturn:
         has finished not only the data processing logic, but also the 
processing
         of all the control messages.
         """
-        # Ensure this is really the last message.
-        input_queue: IQueue = self.context.input_queue
-        if not input_queue.is_empty():
+        # Ensure this is really the last message. Read the queued count once 
(InternalQueue
+        # exposes size(); the base IQueue interface does not) and branch on it.
+        input_queue: InternalQueue = self.context.input_queue
+        queued_count = input_queue.size()
+        if queued_count > 0:
             logger.warning(
-                f"Received EndHandler before all messages are "
-                f"processed. Unprocessed messages: {input_queue.get()}"
+                f"Received EndWorker before all {queued_count} queued "
+                f"message(s) were processed; failing the RPC so the 
coordinator "
+                f"retries once the queue has drained."

Review Comment:
   Done — took your wording for the log, and applied the same fixed-delay 
correction to the comment below it, a comment in the test file, and the PR 
description, which all carried the "retries once/after the queue drains" 
causality.



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