Search in sources :

Example 1 with CheckpointStatistics

use of org.apache.flink.runtime.rest.messages.checkpoints.CheckpointStatistics 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);
    }
}
Also used : CheckpointStatsCounts(org.apache.flink.runtime.checkpoint.CheckpointStatsCounts) CheckpointStatsCounts(org.apache.flink.runtime.checkpoint.CheckpointStatsCounts) AbstractCheckpointStats(org.apache.flink.runtime.checkpoint.AbstractCheckpointStats) ArrayList(java.util.ArrayList) RestHandlerException(org.apache.flink.runtime.rest.handler.RestHandlerException) CheckpointingStatistics(org.apache.flink.runtime.rest.messages.checkpoints.CheckpointingStatistics) RestoredCheckpointStats(org.apache.flink.runtime.checkpoint.RestoredCheckpointStats) CheckpointStatsHistory(org.apache.flink.runtime.checkpoint.CheckpointStatsHistory) CompletedCheckpointStatsSummarySnapshot(org.apache.flink.runtime.checkpoint.CompletedCheckpointStatsSummarySnapshot) StatsSummaryDto(org.apache.flink.runtime.rest.messages.checkpoints.StatsSummaryDto) CheckpointStatsSnapshot(org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot) CheckpointStatistics(org.apache.flink.runtime.rest.messages.checkpoints.CheckpointStatistics)

Aggregations

ArrayList (java.util.ArrayList)1 AbstractCheckpointStats (org.apache.flink.runtime.checkpoint.AbstractCheckpointStats)1 CheckpointStatsCounts (org.apache.flink.runtime.checkpoint.CheckpointStatsCounts)1 CheckpointStatsHistory (org.apache.flink.runtime.checkpoint.CheckpointStatsHistory)1 CheckpointStatsSnapshot (org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot)1 CompletedCheckpointStatsSummarySnapshot (org.apache.flink.runtime.checkpoint.CompletedCheckpointStatsSummarySnapshot)1 RestoredCheckpointStats (org.apache.flink.runtime.checkpoint.RestoredCheckpointStats)1 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)1 CheckpointStatistics (org.apache.flink.runtime.rest.messages.checkpoints.CheckpointStatistics)1 CheckpointingStatistics (org.apache.flink.runtime.rest.messages.checkpoints.CheckpointingStatistics)1 StatsSummaryDto (org.apache.flink.runtime.rest.messages.checkpoints.StatsSummaryDto)1