TisonKun commented on issue #10408: [FLINK-14992][client] Add job listener to 
execution environments
URL: https://github.com/apache/flink/pull/10408#issuecomment-561667687
 
 
   > > @kl0u Had a good idea: We think that the lifecycle of the client that is 
given to the listener has to be completely separate. We can do this by adding a 
`clone()` or `duplicate()` method to `ClusterClient`, which creates a new copy 
that has deep copies of all the required resources. Then we can add a 
`JobClient.duplicate()` which does the same for the `JobClient`. This way, the 
listener and the user (on the return value of `executeAsync()`) can do whatever 
they want with the client. What do you think?
   > 
   > If we create a copy of JobClient, then who take the responsibility to 
clean the resources ? JobListener ? I don't think it is JobListener's 
responsibility.
   
   It is a duplicated `JobClient` so only write code as
   
   ```java
   @Override
   public void onJobSubmitted(JobClient jobClient, Throwable throwable) {
     try {
       ...
     } finally {
       if (jobClient != null) {
         jobClient.close();
       }
     }
   }
   ```
   
   if we pass the inner `JobClient`, then `JobListener` should take care of the 
client got closed concurrently. You can think of the trade offs and give your 
opinion considering them.

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