[ 
https://issues.apache.org/jira/browse/FLINK-4547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15458182#comment-15458182
 ] 

ASF GitHub Bot commented on FLINK-4547:
---------------------------------------

Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2455#discussion_r77326942
  
    --- Diff: 
flink-runtime/src/test/java/org/apache/flink/runtime/rpc/akka/AkkaRpcServiceTest.java
 ---
    @@ -84,4 +89,35 @@ public void run() {
     
                assertTrue("call was not properly delayed", ((stop - start) / 
1000000) >= delay);
        }
    +
    +   /**
    +    * Test connect method
    +    * 1. Get the same result when connect the same address and same 
gateway class
    +    * 2. Failed when connect to invalid address
    +    * @throws Exception
    +    */
    +   @Test
    +   public void testConnect() throws Exception {
    +           TestingLeaderElectionService leaderElectionService = new 
TestingLeaderElectionService();
    +           TestingHighAvailabilityServices highAvailabilityServices = new 
TestingHighAvailabilityServices();
    +           
highAvailabilityServices.setResourceManagerLeaderElectionService(leaderElectionService);
    +
    +           ResourceManager rm = new ResourceManager(akkaRpcService, 
highAvailabilityServices);
    +           rm.start();
    +           String address = rm.getAddress();
    +           // verify get the same result when connect the same address and 
same gateway class
    +           Future<ResourceManagerGateway> rmGatewayFuture1 = 
akkaRpcService.connect(address, ResourceManagerGateway.class);
    +           ResourceManagerGateway rmGateway1 = 
Await.result(rmGatewayFuture1, new FiniteDuration(200, TimeUnit.MILLISECONDS));
    +
    +           Future<ResourceManagerGateway> rmGatewayFuture2 = 
akkaRpcService.connect(address, ResourceManagerGateway.class);
    +           ResourceManagerGateway rmGateway2 = 
Await.result(rmGatewayFuture2, new FiniteDuration(200, TimeUnit.MILLISECONDS));
    +
    +           Assert.assertEquals(rmGateway1, rmGateway2);
    +           Assert.assertEquals(rmGateway1.hashCode(), 
rmGateway2.hashCode());
    +
    +           // verify failed when connect to invalid address
    +           String invalidString = "abc";
    +           Future<ResourceManagerGateway> invalidRmGatewayFuture = 
akkaRpcService.connect(invalidString, ResourceManagerGateway.class);
    +           assertTrue(invalidRmGatewayFuture.failed().value().get().get() 
instanceof RuntimeException);
    --- End diff --
    
    Maybe you should check whether the future is completed. You could obtain 
the result via `Await.result(future, timeout)`.


> Return same object when call connect method in AkkaRpcService using same 
> address and same rpc gateway class
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-4547
>                 URL: https://issues.apache.org/jira/browse/FLINK-4547
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Distributed Coordination
>            Reporter: zhangjing
>            Assignee: zhangjing
>
> Now every time call connect method in AkkaRpcService class using same address 
> and same rpc gateway class, the return gateway object is totally different 
> with each other which equals and hashcode are not same. 
> Maybe it’s reasonable to have the same result (equals return true, and 
> hashcode is same) when using the same address and same Gateway class.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to