use of org.apache.flink.runtime.checkpoint.TaskStateStats in project flink by apache.
the class CheckpointStatsDetailsSubtasksHandler method handleRequest.
@Override
public String handleRequest(AccessExecutionGraph graph, Map<String, String> params) throws Exception {
long checkpointId = CheckpointStatsDetailsHandler.parseCheckpointId(params);
if (checkpointId == -1) {
return "{}";
}
JobVertexID vertexId = AbstractJobVertexRequestHandler.parseJobVertexId(params);
if (vertexId == null) {
return "{}";
}
CheckpointStatsSnapshot snapshot = graph.getCheckpointStatsSnapshot();
if (snapshot == null) {
return "{}";
}
AbstractCheckpointStats checkpoint = snapshot.getHistory().getCheckpointById(checkpointId);
if (checkpoint != null) {
cache.tryAdd(checkpoint);
} else {
checkpoint = cache.tryGet(checkpointId);
if (checkpoint == null) {
return "{}";
}
}
TaskStateStats taskStats = checkpoint.getTaskStateStats(vertexId);
if (taskStats == null) {
return "{}";
}
return createSubtaskCheckpointDetailsJson(checkpoint, taskStats);
}
use of org.apache.flink.runtime.checkpoint.TaskStateStats in project flink by apache.
the class CheckpointStatsDetailsHandlerTest method testCheckpointDetailsRequestInProgressCheckpoint.
/**
* Tests a checkpoint details request for an in progress checkpoint.
*/
@Test
public void testCheckpointDetailsRequestInProgressCheckpoint() throws Exception {
PendingCheckpointStats checkpoint = mock(PendingCheckpointStats.class);
when(checkpoint.getCheckpointId()).thenReturn(1992139L);
when(checkpoint.getStatus()).thenReturn(CheckpointStatsStatus.IN_PROGRESS);
when(checkpoint.getProperties()).thenReturn(CheckpointProperties.forStandardCheckpoint());
when(checkpoint.getTriggerTimestamp()).thenReturn(1919191900L);
when(checkpoint.getLatestAckTimestamp()).thenReturn(1977791901L);
when(checkpoint.getStateSize()).thenReturn(111939272822L);
when(checkpoint.getEndToEndDuration()).thenReturn(121191L);
when(checkpoint.getAlignmentBuffered()).thenReturn(1L);
when(checkpoint.getNumberOfSubtasks()).thenReturn(501);
when(checkpoint.getNumberOfAcknowledgedSubtasks()).thenReturn(101);
List<TaskStateStats> taskStats = new ArrayList<>();
TaskStateStats task1 = createTaskStateStats();
TaskStateStats task2 = createTaskStateStats();
taskStats.add(task1);
taskStats.add(task2);
when(checkpoint.getAllTaskStateStats()).thenReturn(taskStats);
JsonNode rootNode = triggerRequest(checkpoint);
assertEquals(checkpoint.getCheckpointId(), rootNode.get("id").asLong());
assertEquals(checkpoint.getStatus().toString(), rootNode.get("status").asText());
assertEquals(checkpoint.getProperties().isSavepoint(), rootNode.get("is_savepoint").asBoolean());
assertEquals(checkpoint.getTriggerTimestamp(), rootNode.get("trigger_timestamp").asLong());
assertEquals(checkpoint.getLatestAckTimestamp(), rootNode.get("latest_ack_timestamp").asLong());
assertEquals(checkpoint.getStateSize(), rootNode.get("state_size").asLong());
assertEquals(checkpoint.getEndToEndDuration(), rootNode.get("end_to_end_duration").asLong());
assertEquals(checkpoint.getAlignmentBuffered(), rootNode.get("alignment_buffered").asLong());
assertEquals(checkpoint.getNumberOfSubtasks(), rootNode.get("num_subtasks").asInt());
assertEquals(checkpoint.getNumberOfAcknowledgedSubtasks(), rootNode.get("num_acknowledged_subtasks").asInt());
verifyTaskNodes(taskStats, rootNode);
}
use of org.apache.flink.runtime.checkpoint.TaskStateStats in project flink by apache.
the class CheckpointStatsDetailsHandlerTest method createCompletedCheckpoint.
// ------------------------------------------------------------------------
private static CompletedCheckpointStats createCompletedCheckpoint() {
CompletedCheckpointStats checkpoint = mock(CompletedCheckpointStats.class);
when(checkpoint.getCheckpointId()).thenReturn(1818213L);
when(checkpoint.getStatus()).thenReturn(CheckpointStatsStatus.COMPLETED);
when(checkpoint.getProperties()).thenReturn(CheckpointProperties.forStandardSavepoint());
when(checkpoint.getTriggerTimestamp()).thenReturn(1818L);
when(checkpoint.getLatestAckTimestamp()).thenReturn(11029222L);
when(checkpoint.getStateSize()).thenReturn(925281L);
when(checkpoint.getEndToEndDuration()).thenReturn(181819L);
when(checkpoint.getAlignmentBuffered()).thenReturn(1010198L);
when(checkpoint.getNumberOfSubtasks()).thenReturn(181271);
when(checkpoint.getNumberOfAcknowledgedSubtasks()).thenReturn(29821);
when(checkpoint.isDiscarded()).thenReturn(true);
when(checkpoint.getExternalPath()).thenReturn("checkpoint-external-path");
List<TaskStateStats> taskStats = new ArrayList<>();
TaskStateStats task1 = createTaskStateStats();
TaskStateStats task2 = createTaskStateStats();
taskStats.add(task1);
taskStats.add(task2);
when(checkpoint.getAllTaskStateStats()).thenReturn(taskStats);
return checkpoint;
}
use of org.apache.flink.runtime.checkpoint.TaskStateStats in project flink by apache.
the class CheckpointStatsDetailsHandlerTest method verifyTaskNodes.
private static void verifyTaskNodes(Collection<TaskStateStats> tasks, JsonNode parentNode) {
for (TaskStateStats task : tasks) {
long duration = ThreadLocalRandom.current().nextInt(128);
JsonNode taskNode = parentNode.get("tasks").get(task.getJobVertexId().toString());
assertEquals(task.getLatestAckTimestamp(), taskNode.get("latest_ack_timestamp").asLong());
assertEquals(task.getStateSize(), taskNode.get("state_size").asLong());
assertEquals(task.getEndToEndDuration(task.getLatestAckTimestamp() - duration), taskNode.get("end_to_end_duration").asLong());
assertEquals(task.getAlignmentBuffered(), taskNode.get("alignment_buffered").asLong());
assertEquals(task.getNumberOfSubtasks(), taskNode.get("num_subtasks").asInt());
assertEquals(task.getNumberOfAcknowledgedSubtasks(), taskNode.get("num_acknowledged_subtasks").asInt());
}
}
use of org.apache.flink.runtime.checkpoint.TaskStateStats in project flink by apache.
the class CheckpointStatsDetailsHandlerTest method createFailedCheckpoint.
private static FailedCheckpointStats createFailedCheckpoint() {
FailedCheckpointStats checkpoint = mock(FailedCheckpointStats.class);
when(checkpoint.getCheckpointId()).thenReturn(1818214L);
when(checkpoint.getStatus()).thenReturn(CheckpointStatsStatus.FAILED);
when(checkpoint.getProperties()).thenReturn(CheckpointProperties.forStandardSavepoint());
when(checkpoint.getTriggerTimestamp()).thenReturn(1818L);
when(checkpoint.getLatestAckTimestamp()).thenReturn(11029222L);
when(checkpoint.getStateSize()).thenReturn(925281L);
when(checkpoint.getEndToEndDuration()).thenReturn(181819L);
when(checkpoint.getAlignmentBuffered()).thenReturn(1010198L);
when(checkpoint.getNumberOfSubtasks()).thenReturn(181271);
when(checkpoint.getNumberOfAcknowledgedSubtasks()).thenReturn(29821);
when(checkpoint.getFailureTimestamp()).thenReturn(123012890312093L);
when(checkpoint.getFailureMessage()).thenReturn("failure-message");
List<TaskStateStats> taskStats = new ArrayList<>();
TaskStateStats task1 = createTaskStateStats();
TaskStateStats task2 = createTaskStateStats();
taskStats.add(task1);
taskStats.add(task2);
when(checkpoint.getAllTaskStateStats()).thenReturn(taskStats);
return checkpoint;
}
Aggregations