use of org.apache.flink.runtime.checkpoint.CheckpointStatsHistory 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());
}
use of org.apache.flink.runtime.checkpoint.CheckpointStatsHistory 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);
}
use of org.apache.flink.runtime.checkpoint.CheckpointStatsHistory 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()));
}
use of org.apache.flink.runtime.checkpoint.CheckpointStatsHistory in project flink by apache.
the class CheckpointStatsDetailsHandlerTest 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);
CheckpointStatsDetailsHandler handler = new CheckpointStatsDetailsHandler(mock(ExecutionGraphHolder.class), new CheckpointStatsCache(0));
Map<String, String> params = new HashMap<>();
params.put("checkpointid", "123");
String json = handler.handleRequest(graph, params);
ObjectMapper mapper = new ObjectMapper();
return mapper.readTree(json);
}
Aggregations