1996fanrui commented on code in PR #2268:
URL: 
https://github.com/apache/incubator-streampark/pull/2268#discussion_r1096668226


##########
streampark-console/streampark-console-service/src/main/assembly/script/upgrade/mysql/2.1.0.sql:
##########
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+-- ISSUE-2192 DDL & DML Start
+
+alter table `t_flink_savepoint` modify column `path`  varchar(1024) collate 
utf8mb4_general_ci default null;
+
+insert into `t_menu` values (100070, 100015, 'savepoint trigger', null, null, 
'savepoint:trigger', null, '1', 1, null, now(), now());

Review Comment:
   The upgrade sql of pgsql is missed.



##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/SavePointServiceImpl.java:
##########
@@ -114,6 +127,41 @@ public SavePoint getLatest(Long id) {
     return this.getOne(queryWrapper);
   }
 
+  @Override
+  public void trigger(Long appId, @Nullable String savepointPath) {
+    log.info("Start to trigger savepoint for app {}", appId);
+    Application app = appService.getById(appId);
+    AssertUtils.notNull(app, String.format("The application %s doesn't 
exist.", appId));
+    String trackingUrl = app.getJobManagerUrl();
+    AssertUtils.state(
+        StringUtils.isNotEmpty(trackingUrl),
+        String.format("The flink trackingUrl for app[%s] isn't available.", 
appId));
+    String jobId = app.getJobId();
+    AssertUtils.state(
+        StringUtils.isNotEmpty(jobId),
+        String.format("The jobId of application[%s] is absent.", appId));
+    String triggerId = triggerSavepoint(trackingUrl, jobId, savepointPath);
+    log.info("Request savepoint successful in triggerId {}", triggerId);
+  }
+
+  private String triggerSavepoint(
+      String trackingUrl, String jobId, @Nullable String savepointPath) {
+    String response = null;
+    try {
+      String url = String.format("%s/jobs/%s/savepoints", trackingUrl, jobId);
+      String postBody =
+          OBJECT_MAPPER.writeValueAsString(new 
SavepointTriggerRequestBody(savepointPath, false));
+      response = HttpClientUtils.httpPostRequest(url, postBody);
+      TriggerResponse triggerResponse = OBJECT_MAPPER.readValue(response, 
TriggerResponse.class);
+      return triggerResponse.getTriggerId().toString();
+    } catch (Exception e) {
+      throw new RuntimeException(

Review Comment:
   Hi @wolfboys, we should use the `ApiAlertException` here, right?



##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java:
##########
@@ -1258,7 +1259,7 @@ public void cancel(Application appParam) throws Exception 
{
                 savePoint.setAppId(application.getId());
                 savePoint.setLatest(true);
                 savePoint.setType(CheckPointType.SAVEPOINT.get());
-                savePoint.setTriggerTime(now);

Review Comment:
   Could the `now` be removed?



##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/task/FlinkRESTAPIWatcher.java:
##########
@@ -357,7 +357,9 @@ private void handleCheckPoints(Application application) 
throws Exception {
     FlinkCluster flinkCluster = getFlinkCluster(application);
     CheckPoints checkPoints = httpCheckpoints(application, flinkCluster);
     if (checkPoints != null) {
-      checkpointProcessor.process(application.getId(), checkPoints);
+      checkPoints
+          .getLatestChkAndSavepointWithTimeAscOrder()

Review Comment:
   I prefer move the logic into  `checkpointProcessor`, this class is 
`FlinkRESTAPIWatcher`, it shouldn't care about these logics.
   
   Overall, don't change this file, and we still pass the `CheckPoints 
checkPoints` to `checkpointProcessor.process(application.getId(), 
checkPoints);`.



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

Reply via email to