Search in sources :

Example 1 with CheckpointStatsHistory

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

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

the class CheckpointStatsDetailsHandlerTest 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);
    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);
    assertEquals("{}", json);
    verify(history, times(1)).getCheckpointById(anyLong());
}
Also used : ExecutionGraphHolder(org.apache.flink.runtime.webmonitor.ExecutionGraphHolder) HashMap(java.util.HashMap) 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 3 with CheckpointStatsHistory

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

the class CheckpointStatsHandlerTest method createTestCheckpointStats.

private static TestCheckpointStats createTestCheckpointStats() {
    // Counts
    CheckpointStatsCounts counts = mock(CheckpointStatsCounts.class);
    when(counts.getNumberOfRestoredCheckpoints()).thenReturn(123123123L);
    when(counts.getTotalNumberOfCheckpoints()).thenReturn(12981231203L);
    when(counts.getNumberOfInProgressCheckpoints()).thenReturn(191919);
    when(counts.getNumberOfCompletedCheckpoints()).thenReturn(882828200L);
    when(counts.getNumberOfFailedCheckpoints()).thenReturn(99171510L);
    // Summary
    CompletedCheckpointStatsSummary summary = mock(CompletedCheckpointStatsSummary.class);
    MinMaxAvgStats stateSizeSummary = mock(MinMaxAvgStats.class);
    when(stateSizeSummary.getMinimum()).thenReturn(81238123L);
    when(stateSizeSummary.getMaximum()).thenReturn(19919191999L);
    when(stateSizeSummary.getAverage()).thenReturn(1133L);
    MinMaxAvgStats durationSummary = mock(MinMaxAvgStats.class);
    when(durationSummary.getMinimum()).thenReturn(1182L);
    when(durationSummary.getMaximum()).thenReturn(88654L);
    when(durationSummary.getAverage()).thenReturn(171L);
    MinMaxAvgStats alignmentBufferedSummary = mock(MinMaxAvgStats.class);
    when(alignmentBufferedSummary.getMinimum()).thenReturn(81818181899L);
    when(alignmentBufferedSummary.getMaximum()).thenReturn(89999911118654L);
    when(alignmentBufferedSummary.getAverage()).thenReturn(11203131L);
    when(summary.getStateSizeStats()).thenReturn(stateSizeSummary);
    when(summary.getEndToEndDurationStats()).thenReturn(durationSummary);
    when(summary.getAlignmentBufferedStats()).thenReturn(alignmentBufferedSummary);
    // Latest
    CompletedCheckpointStats latestCompleted = mock(CompletedCheckpointStats.class);
    when(latestCompleted.getCheckpointId()).thenReturn(1992139L);
    when(latestCompleted.getTriggerTimestamp()).thenReturn(1919191900L);
    when(latestCompleted.getLatestAckTimestamp()).thenReturn(1977791901L);
    when(latestCompleted.getStateSize()).thenReturn(111939272822L);
    when(latestCompleted.getEndToEndDuration()).thenReturn(121191L);
    when(latestCompleted.getAlignmentBuffered()).thenReturn(1L);
    when(latestCompleted.getExternalPath()).thenReturn("latest-completed-external-path");
    CompletedCheckpointStats latestSavepoint = mock(CompletedCheckpointStats.class);
    when(latestSavepoint.getCheckpointId()).thenReturn(1992140L);
    when(latestSavepoint.getTriggerTimestamp()).thenReturn(1919191900L);
    when(latestSavepoint.getLatestAckTimestamp()).thenReturn(1977791901L);
    when(latestSavepoint.getStateSize()).thenReturn(111939272822L);
    when(latestSavepoint.getEndToEndDuration()).thenReturn(121191L);
    when(latestCompleted.getAlignmentBuffered()).thenReturn(182813L);
    when(latestSavepoint.getExternalPath()).thenReturn("savepoint-external-path");
    FailedCheckpointStats latestFailed = mock(FailedCheckpointStats.class);
    when(latestFailed.getCheckpointId()).thenReturn(1112L);
    when(latestFailed.getTriggerTimestamp()).thenReturn(12828L);
    when(latestFailed.getLatestAckTimestamp()).thenReturn(1901L);
    when(latestFailed.getFailureTimestamp()).thenReturn(11999976L);
    when(latestFailed.getStateSize()).thenReturn(111L);
    when(latestFailed.getEndToEndDuration()).thenReturn(12L);
    when(latestFailed.getAlignmentBuffered()).thenReturn(2L);
    when(latestFailed.getFailureMessage()).thenReturn("expected cause");
    RestoredCheckpointStats latestRestored = mock(RestoredCheckpointStats.class);
    when(latestRestored.getCheckpointId()).thenReturn(1199L);
    when(latestRestored.getRestoreTimestamp()).thenReturn(434242L);
    when(latestRestored.getProperties()).thenReturn(CheckpointProperties.forStandardSavepoint());
    when(latestRestored.getExternalPath()).thenReturn("restored savepoint path");
    // History
    CheckpointStatsHistory history = mock(CheckpointStatsHistory.class);
    List<AbstractCheckpointStats> checkpoints = new ArrayList<>();
    PendingCheckpointStats inProgress = mock(PendingCheckpointStats.class);
    when(inProgress.getCheckpointId()).thenReturn(1992141L);
    when(inProgress.getStatus()).thenReturn(CheckpointStatsStatus.IN_PROGRESS);
    when(inProgress.getProperties()).thenReturn(CheckpointProperties.forStandardCheckpoint());
    when(inProgress.getTriggerTimestamp()).thenReturn(1919191900L);
    when(inProgress.getLatestAckTimestamp()).thenReturn(1977791901L);
    when(inProgress.getStateSize()).thenReturn(111939272822L);
    when(inProgress.getEndToEndDuration()).thenReturn(121191L);
    when(inProgress.getAlignmentBuffered()).thenReturn(1L);
    when(inProgress.getNumberOfSubtasks()).thenReturn(501);
    when(inProgress.getNumberOfAcknowledgedSubtasks()).thenReturn(101);
    CompletedCheckpointStats completedSavepoint = mock(CompletedCheckpointStats.class);
    when(completedSavepoint.getCheckpointId()).thenReturn(1322139L);
    when(completedSavepoint.getStatus()).thenReturn(CheckpointStatsStatus.COMPLETED);
    when(completedSavepoint.getProperties()).thenReturn(CheckpointProperties.forStandardSavepoint());
    when(completedSavepoint.getTriggerTimestamp()).thenReturn(191900L);
    when(completedSavepoint.getLatestAckTimestamp()).thenReturn(197791901L);
    when(completedSavepoint.getStateSize()).thenReturn(1119822L);
    when(completedSavepoint.getEndToEndDuration()).thenReturn(12191L);
    when(completedSavepoint.getAlignmentBuffered()).thenReturn(111L);
    when(completedSavepoint.getNumberOfSubtasks()).thenReturn(33501);
    when(completedSavepoint.getNumberOfAcknowledgedSubtasks()).thenReturn(211);
    when(completedSavepoint.isDiscarded()).thenReturn(true);
    when(completedSavepoint.getExternalPath()).thenReturn("completed-external-path");
    FailedCheckpointStats failed = mock(FailedCheckpointStats.class);
    when(failed.getCheckpointId()).thenReturn(110719L);
    when(failed.getStatus()).thenReturn(CheckpointStatsStatus.FAILED);
    when(failed.getProperties()).thenReturn(CheckpointProperties.forStandardCheckpoint());
    when(failed.getTriggerTimestamp()).thenReturn(191900L);
    when(failed.getLatestAckTimestamp()).thenReturn(197791901L);
    when(failed.getStateSize()).thenReturn(1119822L);
    when(failed.getEndToEndDuration()).thenReturn(12191L);
    when(failed.getAlignmentBuffered()).thenReturn(111L);
    when(failed.getNumberOfSubtasks()).thenReturn(33501);
    when(failed.getNumberOfAcknowledgedSubtasks()).thenReturn(1);
    when(failed.getFailureTimestamp()).thenReturn(119230L);
    when(failed.getFailureMessage()).thenReturn("failure message");
    checkpoints.add(inProgress);
    checkpoints.add(completedSavepoint);
    checkpoints.add(failed);
    when(history.getCheckpoints()).thenReturn(checkpoints);
    when(history.getLatestCompletedCheckpoint()).thenReturn(latestCompleted);
    when(history.getLatestSavepoint()).thenReturn(latestSavepoint);
    when(history.getLatestFailedCheckpoint()).thenReturn(latestFailed);
    CheckpointStatsSnapshot snapshot = mock(CheckpointStatsSnapshot.class);
    when(snapshot.getCounts()).thenReturn(counts);
    when(snapshot.getSummaryStats()).thenReturn(summary);
    when(snapshot.getHistory()).thenReturn(history);
    when(snapshot.getLatestRestoredCheckpoint()).thenReturn(latestRestored);
    AccessExecutionGraph graph = mock(AccessExecutionGraph.class);
    when(graph.getCheckpointStatsSnapshot()).thenReturn(snapshot);
    return new TestCheckpointStats(graph, counts, stateSizeSummary, durationSummary, alignmentBufferedSummary, summary, latestCompleted, latestSavepoint, latestFailed, latestRestored, inProgress, completedSavepoint, failed, history, snapshot);
}
Also used : CheckpointStatsCounts(org.apache.flink.runtime.checkpoint.CheckpointStatsCounts) AbstractCheckpointStats(org.apache.flink.runtime.checkpoint.AbstractCheckpointStats) CompletedCheckpointStatsSummary(org.apache.flink.runtime.checkpoint.CompletedCheckpointStatsSummary) ArrayList(java.util.ArrayList) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) MinMaxAvgStats(org.apache.flink.runtime.checkpoint.MinMaxAvgStats) PendingCheckpointStats(org.apache.flink.runtime.checkpoint.PendingCheckpointStats) RestoredCheckpointStats(org.apache.flink.runtime.checkpoint.RestoredCheckpointStats) 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)

Example 4 with CheckpointStatsHistory

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

the class CheckpointStatsSubtaskDetailsHandlerTest method testJobVertexNotFound.

/**
	 * Test lookup of not existing job vertex ID in checkpoint.
	 */
@Test
public void testJobVertexNotFound() throws Exception {
    PendingCheckpointStats inProgress = mock(PendingCheckpointStats.class);
    // not found
    when(inProgress.getTaskStateStats(any(JobVertexID.class))).thenReturn(null);
    CheckpointStatsHistory history = mock(CheckpointStatsHistory.class);
    when(history.getCheckpointById(anyLong())).thenReturn(inProgress);
    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(inProgress, times(1)).getTaskStateStats(any(JobVertexID.class));
}
Also used : PendingCheckpointStats(org.apache.flink.runtime.checkpoint.PendingCheckpointStats) 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 5 with CheckpointStatsHistory

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

Aggregations

CheckpointStatsHistory (org.apache.flink.runtime.checkpoint.CheckpointStatsHistory)9 CheckpointStatsSnapshot (org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot)9 AccessExecutionGraph (org.apache.flink.runtime.executiongraph.AccessExecutionGraph)8 HashMap (java.util.HashMap)5 ExecutionGraphHolder (org.apache.flink.runtime.webmonitor.ExecutionGraphHolder)5 Test (org.junit.Test)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 PendingCheckpointStats (org.apache.flink.runtime.checkpoint.PendingCheckpointStats)3 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)3 ArrayList (java.util.ArrayList)2 JobID (org.apache.flink.api.common.JobID)2 AbstractCheckpointStats (org.apache.flink.runtime.checkpoint.AbstractCheckpointStats)2 CompletedCheckpointStats (org.apache.flink.runtime.checkpoint.CompletedCheckpointStats)2 FailedCheckpointStats (org.apache.flink.runtime.checkpoint.FailedCheckpointStats)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 CheckpointStatsCounts (org.apache.flink.runtime.checkpoint.CheckpointStatsCounts)1