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


##########
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:
   `AlertException`:  notify users of some info by WeChat,DingTalk, Msg..., 
   `ApiAlertException`:  some message will be notify to user through the 
front-end pop-up window of streampark,
   so, we should use the `ApiAlertException` here, not `AlertException `



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