wangyang0918 commented on code in PR #200:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/200#discussion_r872073637
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/FlinkService.java:
##########
@@ -528,6 +538,71 @@ public void triggerSavepoint(
}
}
+ public Optional<Savepoint> getLastCheckpoint(JobID jobId, Configuration
conf) throws Exception {
+ try (RestClusterClient<String> clusterClient =
+ (RestClusterClient<String>) getClusterClient(conf)) {
+
+ var headers = CustomCheckpointingStatisticsHeaders.getInstance();
+ var params = headers.getUnresolvedMessageParameters();
+ params.jobPathParameter.resolve(jobId);
+
+ CompletableFuture<CheckpointHistoryWrapper> response =
+ clusterClient.sendRequest(headers, params,
EmptyRequestBody.getInstance());
+
+ var checkpoints =
+ response.get(
+ configManager
+ .getOperatorConfiguration()
+ .getFlinkClientTimeout()
+ .getSeconds(),
+ TimeUnit.SECONDS);
+
+ var latestCheckpointOpt =
+ checkpoints.getHistory().stream()
+ .filter(
+ cp ->
+ CheckpointStatsStatus.valueOf(
+ cp.get(
+
CheckpointStatistics
+
.FIELD_NAME_STATUS)
+ .asText())
+ ==
CheckpointStatsStatus.COMPLETED)
+ .filter(
+ cp ->
+ !cp.get(
+
CheckpointStatistics
+
.CompletedCheckpointStatistics
+
.FIELD_NAME_EXTERNAL_PATH)
+ .asText()
+ .equals(
+
NonPersistentMetadataCheckpointStorageLocation
+
.EXTERNAL_POINTER))
+ .max(
+ Comparator.comparingLong(
+ cp ->
+
cp.get(CheckpointStatistics.FIELD_NAME_ID)
+ .asLong()))
+ .map(
+ cp ->
+ new Savepoint(
Review Comment:
Given that the `.status.jobStatus.savepointInfo` not the real source of
truth, it is reasonable to also store the checkpoint into this field.
It will be great if we could also describe this in the documentation :)
--
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]