Search in sources :

Example 1 with TaskStateStats

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);
}
Also used : AbstractCheckpointStats(org.apache.flink.runtime.checkpoint.AbstractCheckpointStats) TaskStateStats(org.apache.flink.runtime.checkpoint.TaskStateStats) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) CheckpointStatsSnapshot(org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot)

Example 2 with TaskStateStats

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);
}
Also used : PendingCheckpointStats(org.apache.flink.runtime.checkpoint.PendingCheckpointStats) TaskStateStats(org.apache.flink.runtime.checkpoint.TaskStateStats) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 3 with TaskStateStats

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;
}
Also used : TaskStateStats(org.apache.flink.runtime.checkpoint.TaskStateStats) ArrayList(java.util.ArrayList) CompletedCheckpointStats(org.apache.flink.runtime.checkpoint.CompletedCheckpointStats)

Example 4 with TaskStateStats

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());
    }
}
Also used : TaskStateStats(org.apache.flink.runtime.checkpoint.TaskStateStats) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 5 with TaskStateStats

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;
}
Also used : TaskStateStats(org.apache.flink.runtime.checkpoint.TaskStateStats) ArrayList(java.util.ArrayList) FailedCheckpointStats(org.apache.flink.runtime.checkpoint.FailedCheckpointStats)

Aggregations

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