use of org.apache.flink.runtime.checkpoint.TaskStateStats 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.TaskStateStats in project flink by apache.
the class CheckpointStatsDetailsHandlerTest method createTaskStateStats.
private static TaskStateStats createTaskStateStats() {
ThreadLocalRandom rand = ThreadLocalRandom.current();
TaskStateStats task = mock(TaskStateStats.class);
when(task.getJobVertexId()).thenReturn(new JobVertexID());
when(task.getLatestAckTimestamp()).thenReturn(rand.nextLong(1024) + 1);
when(task.getStateSize()).thenReturn(rand.nextLong(1024) + 1);
when(task.getEndToEndDuration(anyLong())).thenReturn(rand.nextLong(1024) + 1);
when(task.getAlignmentBuffered()).thenReturn(rand.nextLong(1024) + 1);
when(task.getNumberOfSubtasks()).thenReturn(rand.nextInt(1024) + 1);
when(task.getNumberOfAcknowledgedSubtasks()).thenReturn(rand.nextInt(1024) + 1);
return task;
}
Aggregations