Search in sources :

Example 11 with CheckpointStatsSnapshot

use of org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot 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);
}
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) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 12 with CheckpointStatsSnapshot

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

the class ArchivedExecutionGraphTest method compareExecutionGraph.

private static void compareExecutionGraph(AccessExecutionGraph runtimeGraph, AccessExecutionGraph archivedGraph) throws IOException, ClassNotFoundException {
    assertTrue(archivedGraph.isArchived());
    // -------------------------------------------------------------------------------------------------------------
    // ExecutionGraph
    // -------------------------------------------------------------------------------------------------------------
    assertEquals(runtimeGraph.getJsonPlan(), archivedGraph.getJsonPlan());
    assertEquals(runtimeGraph.getJobID(), archivedGraph.getJobID());
    assertEquals(runtimeGraph.getJobName(), archivedGraph.getJobName());
    assertEquals(runtimeGraph.getState(), archivedGraph.getState());
    assertEquals(runtimeGraph.getFailureCauseAsString(), archivedGraph.getFailureCauseAsString());
    assertEquals(runtimeGraph.getStatusTimestamp(JobStatus.CREATED), archivedGraph.getStatusTimestamp(JobStatus.CREATED));
    assertEquals(runtimeGraph.getStatusTimestamp(JobStatus.RUNNING), archivedGraph.getStatusTimestamp(JobStatus.RUNNING));
    assertEquals(runtimeGraph.getStatusTimestamp(JobStatus.FAILING), archivedGraph.getStatusTimestamp(JobStatus.FAILING));
    assertEquals(runtimeGraph.getStatusTimestamp(JobStatus.FAILED), archivedGraph.getStatusTimestamp(JobStatus.FAILED));
    assertEquals(runtimeGraph.getStatusTimestamp(JobStatus.CANCELLING), archivedGraph.getStatusTimestamp(JobStatus.CANCELLING));
    assertEquals(runtimeGraph.getStatusTimestamp(JobStatus.CANCELED), archivedGraph.getStatusTimestamp(JobStatus.CANCELED));
    assertEquals(runtimeGraph.getStatusTimestamp(JobStatus.FINISHED), archivedGraph.getStatusTimestamp(JobStatus.FINISHED));
    assertEquals(runtimeGraph.getStatusTimestamp(JobStatus.RESTARTING), archivedGraph.getStatusTimestamp(JobStatus.RESTARTING));
    assertEquals(runtimeGraph.getStatusTimestamp(JobStatus.SUSPENDED), archivedGraph.getStatusTimestamp(JobStatus.SUSPENDED));
    assertEquals(runtimeGraph.isStoppable(), archivedGraph.isStoppable());
    // -------------------------------------------------------------------------------------------------------------
    // CheckpointStats
    // -------------------------------------------------------------------------------------------------------------
    CheckpointStatsSnapshot runtimeSnapshot = runtimeGraph.getCheckpointStatsSnapshot();
    CheckpointStatsSnapshot archivedSnapshot = archivedGraph.getCheckpointStatsSnapshot();
    assertEquals(runtimeSnapshot.getSummaryStats().getEndToEndDurationStats().getAverage(), archivedSnapshot.getSummaryStats().getEndToEndDurationStats().getAverage());
    assertEquals(runtimeSnapshot.getSummaryStats().getEndToEndDurationStats().getMinimum(), archivedSnapshot.getSummaryStats().getEndToEndDurationStats().getMinimum());
    assertEquals(runtimeSnapshot.getSummaryStats().getEndToEndDurationStats().getMaximum(), archivedSnapshot.getSummaryStats().getEndToEndDurationStats().getMaximum());
    assertEquals(runtimeSnapshot.getSummaryStats().getStateSizeStats().getAverage(), archivedSnapshot.getSummaryStats().getStateSizeStats().getAverage());
    assertEquals(runtimeSnapshot.getSummaryStats().getStateSizeStats().getMinimum(), archivedSnapshot.getSummaryStats().getStateSizeStats().getMinimum());
    assertEquals(runtimeSnapshot.getSummaryStats().getStateSizeStats().getMaximum(), archivedSnapshot.getSummaryStats().getStateSizeStats().getMaximum());
    assertEquals(runtimeSnapshot.getCounts().getTotalNumberOfCheckpoints(), archivedSnapshot.getCounts().getTotalNumberOfCheckpoints());
    assertEquals(runtimeSnapshot.getCounts().getNumberOfCompletedCheckpoints(), archivedSnapshot.getCounts().getNumberOfCompletedCheckpoints());
    assertEquals(runtimeSnapshot.getCounts().getNumberOfInProgressCheckpoints(), archivedSnapshot.getCounts().getNumberOfInProgressCheckpoints());
    // -------------------------------------------------------------------------------------------------------------
    // ArchivedExecutionConfig
    // -------------------------------------------------------------------------------------------------------------
    ArchivedExecutionConfig runtimeConfig = runtimeGraph.getArchivedExecutionConfig();
    ArchivedExecutionConfig archivedConfig = archivedGraph.getArchivedExecutionConfig();
    assertEquals(runtimeConfig.getExecutionMode(), archivedConfig.getExecutionMode());
    assertEquals(runtimeConfig.getParallelism(), archivedConfig.getParallelism());
    assertEquals(runtimeConfig.getObjectReuseEnabled(), archivedConfig.getObjectReuseEnabled());
    assertEquals(runtimeConfig.getRestartStrategyDescription(), archivedConfig.getRestartStrategyDescription());
    assertNotNull(archivedConfig.getGlobalJobParameters().get("hello"));
    assertEquals(runtimeConfig.getGlobalJobParameters().get("hello"), archivedConfig.getGlobalJobParameters().get("hello"));
    // -------------------------------------------------------------------------------------------------------------
    // StringifiedAccumulators
    // -------------------------------------------------------------------------------------------------------------
    compareStringifiedAccumulators(runtimeGraph.getAccumulatorResultsStringified(), archivedGraph.getAccumulatorResultsStringified());
    compareSerializedAccumulators(runtimeGraph.getAccumulatorsSerialized(), archivedGraph.getAccumulatorsSerialized());
    // -------------------------------------------------------------------------------------------------------------
    // JobVertices
    // -------------------------------------------------------------------------------------------------------------
    Map<JobVertexID, ? extends AccessExecutionJobVertex> runtimeVertices = runtimeGraph.getAllVertices();
    Map<JobVertexID, ? extends AccessExecutionJobVertex> archivedVertices = archivedGraph.getAllVertices();
    for (Map.Entry<JobVertexID, ? extends AccessExecutionJobVertex> vertex : runtimeVertices.entrySet()) {
        compareExecutionJobVertex(vertex.getValue(), archivedVertices.get(vertex.getKey()));
    }
    Iterator<? extends AccessExecutionJobVertex> runtimeTopologicalVertices = runtimeGraph.getVerticesTopologically().iterator();
    Iterator<? extends AccessExecutionJobVertex> archiveTopologicaldVertices = archivedGraph.getVerticesTopologically().iterator();
    while (runtimeTopologicalVertices.hasNext()) {
        assertTrue(archiveTopologicaldVertices.hasNext());
        compareExecutionJobVertex(runtimeTopologicalVertices.next(), archiveTopologicaldVertices.next());
    }
    // -------------------------------------------------------------------------------------------------------------
    // ExecutionVertices
    // -------------------------------------------------------------------------------------------------------------
    Iterator<? extends AccessExecutionVertex> runtimeExecutionVertices = runtimeGraph.getAllExecutionVertices().iterator();
    Iterator<? extends AccessExecutionVertex> archivedExecutionVertices = archivedGraph.getAllExecutionVertices().iterator();
    while (runtimeExecutionVertices.hasNext()) {
        assertTrue(archivedExecutionVertices.hasNext());
        compareExecutionVertex(runtimeExecutionVertices.next(), archivedExecutionVertices.next());
    }
}
Also used : ArchivedExecutionConfig(org.apache.flink.api.common.ArchivedExecutionConfig) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) HashMap(java.util.HashMap) Map(java.util.Map) CheckpointStatsSnapshot(org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot)

Aggregations

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