Search in sources :

Example 6 with AbstractCheckpointStats

use of org.apache.flink.runtime.checkpoint.AbstractCheckpointStats in project flink by apache.

the class CheckpointStatsCacheTest method createCheckpoint.

private AbstractCheckpointStats createCheckpoint(long id, CheckpointStatsStatus status) {
    AbstractCheckpointStats checkpoint = mock(AbstractCheckpointStats.class);
    when(checkpoint.getCheckpointId()).thenReturn(id);
    when(checkpoint.getStatus()).thenReturn(status);
    return checkpoint;
}
Also used : AbstractCheckpointStats(org.apache.flink.runtime.checkpoint.AbstractCheckpointStats)

Example 7 with AbstractCheckpointStats

use of org.apache.flink.runtime.checkpoint.AbstractCheckpointStats in project flink by apache.

the class CheckpointStatsHandler method writeHistory.

private static void writeHistory(JsonGenerator gen, CheckpointStatsHistory history) throws IOException {
    gen.writeArrayFieldStart("history");
    for (AbstractCheckpointStats checkpoint : history.getCheckpoints()) {
        gen.writeStartObject();
        gen.writeNumberField("id", checkpoint.getCheckpointId());
        gen.writeStringField("status", checkpoint.getStatus().toString());
        gen.writeBooleanField("is_savepoint", checkpoint.getProperties().isSavepoint());
        gen.writeNumberField("trigger_timestamp", checkpoint.getTriggerTimestamp());
        gen.writeNumberField("latest_ack_timestamp", checkpoint.getLatestAckTimestamp());
        gen.writeNumberField("state_size", checkpoint.getStateSize());
        gen.writeNumberField("end_to_end_duration", checkpoint.getEndToEndDuration());
        gen.writeNumberField("alignment_buffered", checkpoint.getAlignmentBuffered());
        gen.writeNumberField("num_subtasks", checkpoint.getNumberOfSubtasks());
        gen.writeNumberField("num_acknowledged_subtasks", checkpoint.getNumberOfAcknowledgedSubtasks());
        if (checkpoint.getStatus().isCompleted()) {
            // --- Completed ---
            CompletedCheckpointStats completed = (CompletedCheckpointStats) checkpoint;
            String externalPath = completed.getExternalPath();
            if (externalPath != null) {
                gen.writeStringField("external_path", externalPath);
            }
            gen.writeBooleanField("discarded", completed.isDiscarded());
        } else if (checkpoint.getStatus().isFailed()) {
            // --- Failed ---
            FailedCheckpointStats failed = (FailedCheckpointStats) checkpoint;
            gen.writeNumberField("failure_timestamp", failed.getFailureTimestamp());
            String failureMsg = failed.getFailureMessage();
            if (failureMsg != null) {
                gen.writeStringField("failure_message", failureMsg);
            }
        }
        gen.writeEndObject();
    }
    gen.writeEndArray();
}
Also used : AbstractCheckpointStats(org.apache.flink.runtime.checkpoint.AbstractCheckpointStats) CompletedCheckpointStats(org.apache.flink.runtime.checkpoint.CompletedCheckpointStats) FailedCheckpointStats(org.apache.flink.runtime.checkpoint.FailedCheckpointStats)

Example 8 with AbstractCheckpointStats

use of org.apache.flink.runtime.checkpoint.AbstractCheckpointStats in project flink by apache.

the class CheckpointStatsDetailsHandlerTest method testArchiver.

@Test
public void testArchiver() throws IOException {
    JsonArchivist archivist = new CheckpointStatsDetailsHandler.CheckpointStatsDetailsJsonArchivist();
    CompletedCheckpointStats completedCheckpoint = createCompletedCheckpoint();
    FailedCheckpointStats failedCheckpoint = createFailedCheckpoint();
    List<AbstractCheckpointStats> checkpoints = new ArrayList<>();
    checkpoints.add(failedCheckpoint);
    checkpoints.add(completedCheckpoint);
    CheckpointStatsHistory history = mock(CheckpointStatsHistory.class);
    when(history.getCheckpoints()).thenReturn(checkpoints);
    CheckpointStatsSnapshot snapshot = mock(CheckpointStatsSnapshot.class);
    when(snapshot.getHistory()).thenReturn(history);
    AccessExecutionGraph graph = mock(AccessExecutionGraph.class);
    when(graph.getCheckpointStatsSnapshot()).thenReturn(snapshot);
    when(graph.getJobID()).thenReturn(new JobID());
    ObjectMapper mapper = new ObjectMapper();
    Collection<ArchivedJson> archives = archivist.archiveJsonWithPath(graph);
    Assert.assertEquals(2, archives.size());
    Iterator<ArchivedJson> iterator = archives.iterator();
    ArchivedJson archive1 = iterator.next();
    Assert.assertEquals("/jobs/" + graph.getJobID() + "/checkpoints/details/" + failedCheckpoint.getCheckpointId(), archive1.getPath());
    compareFailedCheckpoint(failedCheckpoint, mapper.readTree(archive1.getJson()));
    ArchivedJson archive2 = iterator.next();
    Assert.assertEquals("/jobs/" + graph.getJobID() + "/checkpoints/details/" + completedCheckpoint.getCheckpointId(), archive2.getPath());
    compareCompletedCheckpoint(completedCheckpoint, mapper.readTree(archive2.getJson()));
}
Also used : AbstractCheckpointStats(org.apache.flink.runtime.checkpoint.AbstractCheckpointStats) ArrayList(java.util.ArrayList) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) JsonArchivist(org.apache.flink.runtime.webmonitor.history.JsonArchivist) ArchivedJson(org.apache.flink.runtime.webmonitor.history.ArchivedJson) CheckpointStatsHistory(org.apache.flink.runtime.checkpoint.CheckpointStatsHistory) CompletedCheckpointStats(org.apache.flink.runtime.checkpoint.CompletedCheckpointStats) FailedCheckpointStats(org.apache.flink.runtime.checkpoint.FailedCheckpointStats) CheckpointStatsSnapshot(org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot) JobID(org.apache.flink.api.common.JobID) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

AbstractCheckpointStats (org.apache.flink.runtime.checkpoint.AbstractCheckpointStats)8 CheckpointStatsSnapshot (org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot)4 CompletedCheckpointStats (org.apache.flink.runtime.checkpoint.CompletedCheckpointStats)3 FailedCheckpointStats (org.apache.flink.runtime.checkpoint.FailedCheckpointStats)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 CheckpointStatsHistory (org.apache.flink.runtime.checkpoint.CheckpointStatsHistory)2 AccessExecutionGraph (org.apache.flink.runtime.executiongraph.AccessExecutionGraph)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JobID (org.apache.flink.api.common.JobID)1 CheckpointStatsCounts (org.apache.flink.runtime.checkpoint.CheckpointStatsCounts)1 CompletedCheckpointStatsSummary (org.apache.flink.runtime.checkpoint.CompletedCheckpointStatsSummary)1 MinMaxAvgStats (org.apache.flink.runtime.checkpoint.MinMaxAvgStats)1 PendingCheckpointStats (org.apache.flink.runtime.checkpoint.PendingCheckpointStats)1 RestoredCheckpointStats (org.apache.flink.runtime.checkpoint.RestoredCheckpointStats)1 TaskStateStats (org.apache.flink.runtime.checkpoint.TaskStateStats)1 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)1 ArchivedJson (org.apache.flink.runtime.webmonitor.history.ArchivedJson)1 JsonArchivist (org.apache.flink.runtime.webmonitor.history.JsonArchivist)1