You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@streampark.apache.org by "wolfboys (via GitHub)" <gi...@apache.org> on 2023/07/28 09:21:33 UTC

[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #2906: The YarnClientTrait add clusterClient close

wolfboys commented on code in PR #2906:
URL: https://github.com/apache/incubator-streampark/pull/2906#discussion_r1277318745


##########
streampark-flink/streampark-flink-client/streampark-flink-client-core/src/main/scala/org/apache/streampark/flink/client/trait/YarnClientTrait.scala:
##########
@@ -54,14 +52,16 @@ trait YarnClientTrait extends FlinkClientTrait {
       val clusterDescriptor = clusterClientFactory.createClusterDescriptor(flinkConf)
       clusterDescriptor.retrieve(applicationId).getClusterClient
     }
-    Try {
+    try {

Review Comment:
   this method can be further simplified as follows.
   ```
     private[this] def executeClientAction[R <: SavepointRequestTrait, O](
         request: R,
         flinkConf: Configuration,
         actionFunc: (JobID, ClusterClient[_]) => O): O = {
   
       Utils.using {
         flinkConf.safeSet(YarnConfigOptions.APPLICATION_ID, request.clusterId)
         val clusterClientFactory = new YarnClusterClientFactory
         val applicationId = clusterClientFactory.getClusterId(flinkConf)
         if (applicationId == null) {
           throw new FlinkException(
             "[StreamPark] getClusterClient error. No cluster id was specified. Please specify a cluster to which you would like to connect.")
         }
         val clusterDescriptor = clusterClientFactory.createClusterDescriptor(flinkConf)
         clusterDescriptor.retrieve(applicationId).getClusterClient
       }  { client =>
         Try(actionFunc(getJobID(request.jobId), client)).recover {
           case e =>
             throw new FlinkException(
               s"[StreamPark] Do ${request.getClass.getSimpleName} for the job ${request.jobId} failed. " +
                 s"detail: ${Utils.stringifyException(e)}");
         }.get
       }
     }
   
   ```



-- 
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: issues-unsubscribe@streampark.apache.org

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