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