tillrohrmann commented on a change in pull request #11549: [FLINK-16703][rpc] 
Set AkkaRpcActor state to TERMINATING when terminating
URL: https://github.com/apache/flink/pull/11549#discussion_r400797121
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/rpc/akka/AkkaRpcActorTest.java
 ##########
 @@ -395,6 +396,43 @@ public void testOnStartFails() throws Exception {
                }
        }
 
+       /**
+        * Tests that multiple termination calls won't trigger the onStop 
action multiple times.
+        * See FLINK-16703.
+        */
+       @Test
+       public void callsOnStopOnlyOnce() throws Exception {
+               final CompletableFuture<Void> onStopFuture = new 
CompletableFuture<>();
+               final OnStopCountingRpcEndpoint endpoint = new 
OnStopCountingRpcEndpoint(akkaRpcService, onStopFuture);
+
+               try {
+                       endpoint.start();
+
+                       final AkkaBasedEndpoint selfGateway = 
endpoint.getSelfGateway(AkkaBasedEndpoint.class);
+
+                       // try to terminate the actor twice
+                       
selfGateway.getActorRef().tell(ControlMessages.TERMINATE, ActorRef.noSender());
+                       
selfGateway.getActorRef().tell(ControlMessages.TERMINATE, ActorRef.noSender());
+
+                       // wait a bit so that both terminate messages can be 
processed
+                       try {
+                               endpoint.getTerminationFuture().get(10L, 
TimeUnit.MILLISECONDS);
 
 Review comment:
   I'll introduce a `CountDownLatch` in the `OnStopCountingRpcEndpoint#onStop` 
method on which I will wait.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to