Search in sources :

Example 6 with CheckpointStatsSnapshot

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

the class CheckpointStatsHandler method createCheckpointStatsJson.

private static String createCheckpointStatsJson(AccessExecutionGraph graph) throws IOException {
    StringWriter writer = new StringWriter();
    JsonGenerator gen = JsonFactory.jacksonFactory.createGenerator(writer);
    CheckpointStatsSnapshot snapshot = graph.getCheckpointStatsSnapshot();
    if (snapshot == null) {
        return "{}";
    }
    gen.writeStartObject();
    // Counts
    writeCounts(gen, snapshot.getCounts());
    // Summary
    writeSummary(gen, snapshot.getSummaryStats());
    CheckpointStatsHistory history = snapshot.getHistory();
    // Latest
    writeLatestCheckpoints(gen, history.getLatestCompletedCheckpoint(), history.getLatestSavepoint(), history.getLatestFailedCheckpoint(), snapshot.getLatestRestoredCheckpoint());
    // History
    writeHistory(gen, snapshot.getHistory());
    gen.writeEndObject();
    gen.close();
    return writer.toString();
}
Also used : StringWriter(java.io.StringWriter) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) CheckpointStatsHistory(org.apache.flink.runtime.checkpoint.CheckpointStatsHistory) CheckpointStatsSnapshot(org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot)

Example 7 with CheckpointStatsSnapshot

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

the class CheckpointStatsSubtaskDetailsHandlerTest method testCheckpointNotFound.

/**
	 * Test lookup of not existing checkpoint in history.
	 */
@Test
public void testCheckpointNotFound() throws Exception {
    CheckpointStatsHistory history = mock(CheckpointStatsHistory.class);
    // not found
    when(history.getCheckpointById(anyLong())).thenReturn(null);
    CheckpointStatsSnapshot snapshot = mock(CheckpointStatsSnapshot.class);
    when(snapshot.getHistory()).thenReturn(history);
    AccessExecutionGraph graph = mock(AccessExecutionGraph.class);
    when(graph.getCheckpointStatsSnapshot()).thenReturn(snapshot);
    CheckpointStatsDetailsSubtasksHandler handler = new CheckpointStatsDetailsSubtasksHandler(mock(ExecutionGraphHolder.class), new CheckpointStatsCache(0));
    Map<String, String> params = new HashMap<>();
    params.put("checkpointid", "123");
    params.put("vertexid", new JobVertexID().toString());
    String json = handler.handleRequest(graph, params);
    assertEquals("{}", json);
    verify(history, times(1)).getCheckpointById(anyLong());
}
Also used : ExecutionGraphHolder(org.apache.flink.runtime.webmonitor.ExecutionGraphHolder) HashMap(java.util.HashMap) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) CheckpointStatsHistory(org.apache.flink.runtime.checkpoint.CheckpointStatsHistory) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) CheckpointStatsSnapshot(org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot) Test(org.junit.Test)

Example 8 with CheckpointStatsSnapshot

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

the class CheckpointStatsSubtaskDetailsHandlerTest method testArchiver.

@Test
public void testArchiver() throws Exception {
    JsonArchivist archivist = new CheckpointStatsDetailsSubtasksHandler.CheckpointStatsDetailsSubtasksJsonArchivist();
    ObjectMapper mapper = new ObjectMapper();
    PendingCheckpointStats checkpoint = mock(PendingCheckpointStats.class);
    when(checkpoint.getCheckpointId()).thenReturn(1992139L);
    when(checkpoint.getStatus()).thenReturn(CheckpointStatsStatus.IN_PROGRESS);
    // ack timestamp = duration
    when(checkpoint.getTriggerTimestamp()).thenReturn(0L);
    TaskStateStats task = createTaskStateStats(1237);
    when(checkpoint.getAllTaskStateStats()).thenReturn(Collections.singletonList(task));
    CheckpointStatsHistory history = mock(CheckpointStatsHistory.class);
    when(history.getCheckpoints()).thenReturn(Collections.<AbstractCheckpointStats>singletonList(checkpoint));
    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());
    Collection<ArchivedJson> archives = archivist.archiveJsonWithPath(graph);
    Assert.assertEquals(1, archives.size());
    ArchivedJson archive = archives.iterator().next();
    Assert.assertEquals("/jobs/" + graph.getJobID() + "/checkpoints/details/" + checkpoint.getCheckpointId() + "/subtasks/" + task.getJobVertexId(), archive.getPath());
    JsonNode rootNode = mapper.readTree(archive.getJson());
    assertEquals(checkpoint.getCheckpointId(), rootNode.get("id").asLong());
    assertEquals(checkpoint.getStatus().toString(), rootNode.get("status").asText());
    verifyTaskNode(rootNode, task, checkpoint.getTriggerTimestamp());
}
Also used : PendingCheckpointStats(org.apache.flink.runtime.checkpoint.PendingCheckpointStats) JsonArchivist(org.apache.flink.runtime.webmonitor.history.JsonArchivist) TaskStateStats(org.apache.flink.runtime.checkpoint.TaskStateStats) ArchivedJson(org.apache.flink.runtime.webmonitor.history.ArchivedJson) CheckpointStatsHistory(org.apache.flink.runtime.checkpoint.CheckpointStatsHistory) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CheckpointStatsSnapshot(org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 9 with CheckpointStatsSnapshot

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

the class CheckpointStatsSubtaskDetailsHandlerTest method triggerRequest.

// ------------------------------------------------------------------------
private static JsonNode triggerRequest(AbstractCheckpointStats checkpoint) throws Exception {
    CheckpointStatsHistory history = mock(CheckpointStatsHistory.class);
    when(history.getCheckpointById(anyLong())).thenReturn(checkpoint);
    CheckpointStatsSnapshot snapshot = mock(CheckpointStatsSnapshot.class);
    when(snapshot.getHistory()).thenReturn(history);
    AccessExecutionGraph graph = mock(AccessExecutionGraph.class);
    when(graph.getCheckpointStatsSnapshot()).thenReturn(snapshot);
    CheckpointStatsDetailsSubtasksHandler handler = new CheckpointStatsDetailsSubtasksHandler(mock(ExecutionGraphHolder.class), new CheckpointStatsCache(0));
    Map<String, String> params = new HashMap<>();
    params.put("checkpointid", "123");
    params.put("vertexid", new JobVertexID().toString());
    String json = handler.handleRequest(graph, params);
    ObjectMapper mapper = new ObjectMapper();
    return mapper.readTree(json);
}
Also used : ExecutionGraphHolder(org.apache.flink.runtime.webmonitor.ExecutionGraphHolder) HashMap(java.util.HashMap) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) CheckpointStatsHistory(org.apache.flink.runtime.checkpoint.CheckpointStatsHistory) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) CheckpointStatsSnapshot(org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 10 with CheckpointStatsSnapshot

use of org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot 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

CheckpointStatsSnapshot (org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot)12 CheckpointStatsHistory (org.apache.flink.runtime.checkpoint.CheckpointStatsHistory)9 AccessExecutionGraph (org.apache.flink.runtime.executiongraph.AccessExecutionGraph)8 HashMap (java.util.HashMap)6 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)5 ExecutionGraphHolder (org.apache.flink.runtime.webmonitor.ExecutionGraphHolder)5 Test (org.junit.Test)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 AbstractCheckpointStats (org.apache.flink.runtime.checkpoint.AbstractCheckpointStats)4 PendingCheckpointStats (org.apache.flink.runtime.checkpoint.PendingCheckpointStats)3 ArrayList (java.util.ArrayList)2 JobID (org.apache.flink.api.common.JobID)2 CompletedCheckpointStats (org.apache.flink.runtime.checkpoint.CompletedCheckpointStats)2 FailedCheckpointStats (org.apache.flink.runtime.checkpoint.FailedCheckpointStats)2 TaskStateStats (org.apache.flink.runtime.checkpoint.TaskStateStats)2 ArchivedJson (org.apache.flink.runtime.webmonitor.history.ArchivedJson)2 JsonArchivist (org.apache.flink.runtime.webmonitor.history.JsonArchivist)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 StringWriter (java.io.StringWriter)1