use of org.apache.flink.runtime.rest.messages.checkpoints.CheckpointingStatistics in project flink by apache.
the class CheckpointingStatisticsHandler method createCheckpointingStatistics.
private static CheckpointingStatistics createCheckpointingStatistics(AccessExecutionGraph executionGraph) throws RestHandlerException {
final CheckpointStatsSnapshot checkpointStatsSnapshot = executionGraph.getCheckpointStatsSnapshot();
if (checkpointStatsSnapshot == null) {
throw new RestHandlerException("Checkpointing has not been enabled.", HttpResponseStatus.NOT_FOUND, RestHandlerException.LoggingBehavior.IGNORE);
} else {
final CheckpointStatsCounts checkpointStatsCounts = checkpointStatsSnapshot.getCounts();
final CheckpointingStatistics.Counts counts = new CheckpointingStatistics.Counts(checkpointStatsCounts.getNumberOfRestoredCheckpoints(), checkpointStatsCounts.getTotalNumberOfCheckpoints(), checkpointStatsCounts.getNumberOfInProgressCheckpoints(), checkpointStatsCounts.getNumberOfCompletedCheckpoints(), checkpointStatsCounts.getNumberOfFailedCheckpoints());
final CompletedCheckpointStatsSummarySnapshot checkpointStatsSummary = checkpointStatsSnapshot.getSummaryStats();
final CheckpointingStatistics.Summary summary = new CheckpointingStatistics.Summary(StatsSummaryDto.valueOf(checkpointStatsSummary.getCheckpointedSize()), StatsSummaryDto.valueOf(checkpointStatsSummary.getStateSizeStats()), StatsSummaryDto.valueOf(checkpointStatsSummary.getEndToEndDurationStats()), new StatsSummaryDto(0, 0, 0, 0, 0, 0, 0, 0), StatsSummaryDto.valueOf(checkpointStatsSummary.getProcessedDataStats()), StatsSummaryDto.valueOf(checkpointStatsSummary.getPersistedDataStats()));
final CheckpointStatsHistory checkpointStatsHistory = checkpointStatsSnapshot.getHistory();
final CheckpointStatistics.CompletedCheckpointStatistics completed = checkpointStatsHistory.getLatestCompletedCheckpoint() != null ? (CheckpointStatistics.CompletedCheckpointStatistics) CheckpointStatistics.generateCheckpointStatistics(checkpointStatsHistory.getLatestCompletedCheckpoint(), false) : null;
final CheckpointStatistics.CompletedCheckpointStatistics savepoint = checkpointStatsHistory.getLatestSavepoint() != null ? (CheckpointStatistics.CompletedCheckpointStatistics) CheckpointStatistics.generateCheckpointStatistics(checkpointStatsHistory.getLatestSavepoint(), false) : null;
final CheckpointStatistics.FailedCheckpointStatistics failed = checkpointStatsHistory.getLatestFailedCheckpoint() != null ? (CheckpointStatistics.FailedCheckpointStatistics) CheckpointStatistics.generateCheckpointStatistics(checkpointStatsHistory.getLatestFailedCheckpoint(), false) : null;
final RestoredCheckpointStats restoredCheckpointStats = checkpointStatsSnapshot.getLatestRestoredCheckpoint();
final CheckpointingStatistics.RestoredCheckpointStatistics restored;
if (restoredCheckpointStats == null) {
restored = null;
} else {
restored = new CheckpointingStatistics.RestoredCheckpointStatistics(restoredCheckpointStats.getCheckpointId(), restoredCheckpointStats.getRestoreTimestamp(), restoredCheckpointStats.getProperties().isSavepoint(), restoredCheckpointStats.getExternalPath());
}
final CheckpointingStatistics.LatestCheckpoints latestCheckpoints = new CheckpointingStatistics.LatestCheckpoints(completed, savepoint, failed, restored);
final List<CheckpointStatistics> history = new ArrayList<>(16);
for (AbstractCheckpointStats abstractCheckpointStats : checkpointStatsSnapshot.getHistory().getCheckpoints()) {
history.add(CheckpointStatistics.generateCheckpointStatistics(abstractCheckpointStats, false));
}
return new CheckpointingStatistics(counts, summary, latestCheckpoints, history);
}
}
use of org.apache.flink.runtime.rest.messages.checkpoints.CheckpointingStatistics in project flink by apache.
the class LocalRecoveryITCase method waitUntilCheckpointCompleted.
private void waitUntilCheckpointCompleted(Configuration configuration, int restPort, JobID jobId, Deadline deadline) throws Exception {
final RestClient restClient = new RestClient(configuration, Executors.directExecutor());
final JobMessageParameters messageParameters = new JobMessageParameters();
messageParameters.jobPathParameter.resolve(jobId);
CommonTestUtils.waitUntilCondition(() -> {
final CheckpointingStatistics checkpointingStatistics = restClient.sendRequest("localhost", restPort, CheckpointingStatisticsHeaders.getInstance(), messageParameters, EmptyRequestBody.getInstance()).join();
return checkpointingStatistics.getCounts().getNumberCompletedCheckpoints() > 0;
}, deadline);
}
Aggregations