fsk119 commented on code in PR #21292:
URL: https://github.com/apache/flink/pull/21292#discussion_r1051520363


##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/service/operation/OperationExecutor.java:
##########
@@ -405,4 +426,115 @@ private Set<TableInfo> listViews(String catalogName, 
String databaseName) {
                                                 TableKind.VIEW))
                         .collect(Collectors.toSet()));
     }
+
+    public ResultFetcher callStopJobOperation(
+            OperationHandle operationHandle, StopJobOperation stopJobOperation)
+            throws SqlExecutionException {
+        String jobId = stopJobOperation.getJobId();
+        boolean isWithSavepoint = stopJobOperation.isWithSavepoint();
+        boolean isWithDrain = stopJobOperation.isWithDrain();
+        Duration clientTimeout =
+                Configuration.fromMap(sessionContext.getConfigMap())
+                        .get(ClientOptions.CLIENT_TIMEOUT);
+        Optional<String> savepoint;
+        try {
+            savepoint =
+                    runClusterAction(
+                            operationHandle,
+                            clusterClient -> {
+                                if (isWithSavepoint) {
+                                    // blocking get savepoint path
+                                    try {
+                                        return Optional.of(
+                                                clusterClient
+                                                        .stopWithSavepoint(
+                                                                
JobID.fromHexString(jobId),
+                                                                isWithDrain,
+                                                                
executionConfig.get(
+                                                                        
CheckpointingOptions
+                                                                               
 .SAVEPOINT_DIRECTORY),
+                                                                
SavepointFormatType.DEFAULT)
+                                                        .get(
+                                                                
clientTimeout.toMillis(),
+                                                                
TimeUnit.MILLISECONDS));
+                                    } catch (Exception e) {
+                                        throw new FlinkException(
+                                                "Could not stop job "
+                                                        + 
stopJobOperation.getJobId()
+                                                        + " in session "
+                                                        + 
operationHandle.getIdentifier()
+                                                        + ".",
+                                                e);
+                                    }

Review Comment:
   nit: It's a little trivial to catch the same exception twice with a similar 
msg. In the next PR, we can remove this.



-- 
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-unsubscr...@flink.apache.org

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

Reply via email to