Search in sources :

Example 16 with AccessExecutionGraph

use of org.apache.flink.runtime.executiongraph.AccessExecutionGraph in project flink by apache.

the class CheckpointConfigHandlerTest method testAtLeastOnce.

/**
	 * Tests the that the isExactlyOnce flag is respected.
	 */
@Test
public void testAtLeastOnce() throws Exception {
    GraphAndSettings graphAndSettings = createGraphAndSettings(false, false);
    AccessExecutionGraph graph = graphAndSettings.graph;
    CheckpointConfigHandler handler = new CheckpointConfigHandler(mock(ExecutionGraphHolder.class));
    String json = handler.handleRequest(graph, Collections.<String, String>emptyMap());
    ObjectMapper mapper = new ObjectMapper();
    JsonNode rootNode = mapper.readTree(json);
    assertEquals("at_least_once", rootNode.get("mode").asText());
}
Also used : ExecutionGraphHolder(org.apache.flink.runtime.webmonitor.ExecutionGraphHolder) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 17 with AccessExecutionGraph

use of org.apache.flink.runtime.executiongraph.AccessExecutionGraph in project flink by apache.

the class SubtasksTimesHandlerTest method testArchiver.

@Test
public void testArchiver() throws Exception {
    JsonArchivist archivist = new SubtasksTimesHandler.SubtasksTimesJsonArchivist();
    AccessExecutionGraph originalJob = ArchivedJobGenerationUtils.getTestJob();
    AccessExecutionJobVertex originalTask = ArchivedJobGenerationUtils.getTestTask();
    AccessExecution originalAttempt = ArchivedJobGenerationUtils.getTestAttempt();
    Collection<ArchivedJson> archives = archivist.archiveJsonWithPath(originalJob);
    Assert.assertEquals(1, archives.size());
    ArchivedJson archive = archives.iterator().next();
    Assert.assertEquals("/jobs/" + originalJob.getJobID() + "/vertices/" + originalTask.getJobVertexId() + "/subtasktimes", archive.getPath());
    compareSubtaskTimes(originalTask, originalAttempt, archive.getJson());
}
Also used : AccessExecutionJobVertex(org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex) JsonArchivist(org.apache.flink.runtime.webmonitor.history.JsonArchivist) AccessExecution(org.apache.flink.runtime.executiongraph.AccessExecution) ArchivedJson(org.apache.flink.runtime.webmonitor.history.ArchivedJson) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) Test(org.junit.Test)

Example 18 with AccessExecutionGraph

use of org.apache.flink.runtime.executiongraph.AccessExecutionGraph in project flink by apache.

the class CheckpointConfigHandlerTest method testSimpleConfig.

/**
	 * Tests a simple config.
	 */
@Test
public void testSimpleConfig() throws Exception {
    GraphAndSettings graphAndSettings = createGraphAndSettings(false, true);
    AccessExecutionGraph graph = graphAndSettings.graph;
    JobSnapshottingSettings settings = graphAndSettings.snapshottingSettings;
    CheckpointConfigHandler handler = new CheckpointConfigHandler(mock(ExecutionGraphHolder.class));
    String json = handler.handleRequest(graph, Collections.<String, String>emptyMap());
    ObjectMapper mapper = new ObjectMapper();
    JsonNode rootNode = mapper.readTree(json);
    assertEquals("exactly_once", rootNode.get("mode").asText());
    assertEquals(settings.getCheckpointInterval(), rootNode.get("interval").asLong());
    assertEquals(settings.getCheckpointTimeout(), rootNode.get("timeout").asLong());
    assertEquals(settings.getMinPauseBetweenCheckpoints(), rootNode.get("min_pause").asLong());
    assertEquals(settings.getMaxConcurrentCheckpoints(), rootNode.get("max_concurrent").asInt());
    JsonNode externalizedNode = rootNode.get("externalization");
    assertNotNull(externalizedNode);
    assertEquals(false, externalizedNode.get("enabled").asBoolean());
}
Also used : ExecutionGraphHolder(org.apache.flink.runtime.webmonitor.ExecutionGraphHolder) JobSnapshottingSettings(org.apache.flink.runtime.jobgraph.tasks.JobSnapshottingSettings) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 19 with AccessExecutionGraph

use of org.apache.flink.runtime.executiongraph.AccessExecutionGraph in project flink by apache.

the class CheckpointConfigHandlerTest method testEnabledExternalizedCheckpointSettings.

/**
	 * Tests that the externalized checkpoint settings are forwarded.
	 */
@Test
public void testEnabledExternalizedCheckpointSettings() throws Exception {
    GraphAndSettings graphAndSettings = createGraphAndSettings(true, false);
    AccessExecutionGraph graph = graphAndSettings.graph;
    ExternalizedCheckpointSettings externalizedSettings = graphAndSettings.externalizedSettings;
    CheckpointConfigHandler handler = new CheckpointConfigHandler(mock(ExecutionGraphHolder.class));
    String json = handler.handleRequest(graph, Collections.<String, String>emptyMap());
    ObjectMapper mapper = new ObjectMapper();
    JsonNode externalizedNode = mapper.readTree(json).get("externalization");
    assertNotNull(externalizedNode);
    assertEquals(externalizedSettings.externalizeCheckpoints(), externalizedNode.get("enabled").asBoolean());
    assertEquals(externalizedSettings.deleteOnCancellation(), externalizedNode.get("delete_on_cancellation").asBoolean());
}
Also used : ExecutionGraphHolder(org.apache.flink.runtime.webmonitor.ExecutionGraphHolder) ExternalizedCheckpointSettings(org.apache.flink.runtime.jobgraph.tasks.ExternalizedCheckpointSettings) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 20 with AccessExecutionGraph

use of org.apache.flink.runtime.executiongraph.AccessExecutionGraph in project flink by apache.

the class CheckpointConfigHandlerTest method testArchiver.

@Test
public void testArchiver() throws IOException {
    JsonArchivist archivist = new CheckpointConfigHandler.CheckpointConfigJsonArchivist();
    GraphAndSettings graphAndSettings = createGraphAndSettings(true, true);
    AccessExecutionGraph graph = graphAndSettings.graph;
    when(graph.getJobID()).thenReturn(new JobID());
    JobSnapshottingSettings settings = graphAndSettings.snapshottingSettings;
    ExternalizedCheckpointSettings externalizedSettings = graphAndSettings.externalizedSettings;
    Collection<ArchivedJson> archives = archivist.archiveJsonWithPath(graph);
    Assert.assertEquals(1, archives.size());
    ArchivedJson archive = archives.iterator().next();
    Assert.assertEquals("/jobs/" + graph.getJobID() + "/checkpoints/config", archive.getPath());
    ObjectMapper mapper = new ObjectMapper();
    JsonNode rootNode = mapper.readTree(archive.getJson());
    Assert.assertEquals("exactly_once", rootNode.get("mode").asText());
    Assert.assertEquals(settings.getCheckpointInterval(), rootNode.get("interval").asLong());
    Assert.assertEquals(settings.getCheckpointTimeout(), rootNode.get("timeout").asLong());
    Assert.assertEquals(settings.getMinPauseBetweenCheckpoints(), rootNode.get("min_pause").asLong());
    Assert.assertEquals(settings.getMaxConcurrentCheckpoints(), rootNode.get("max_concurrent").asInt());
    JsonNode externalizedNode = rootNode.get("externalization");
    Assert.assertNotNull(externalizedNode);
    Assert.assertEquals(externalizedSettings.externalizeCheckpoints(), externalizedNode.get("enabled").asBoolean());
    Assert.assertEquals(externalizedSettings.deleteOnCancellation(), externalizedNode.get("delete_on_cancellation").asBoolean());
}
Also used : JsonArchivist(org.apache.flink.runtime.webmonitor.history.JsonArchivist) ArchivedJson(org.apache.flink.runtime.webmonitor.history.ArchivedJson) ExternalizedCheckpointSettings(org.apache.flink.runtime.jobgraph.tasks.ExternalizedCheckpointSettings) JobSnapshottingSettings(org.apache.flink.runtime.jobgraph.tasks.JobSnapshottingSettings) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) JsonNode(com.fasterxml.jackson.databind.JsonNode) JobID(org.apache.flink.api.common.JobID) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

AccessExecutionGraph (org.apache.flink.runtime.executiongraph.AccessExecutionGraph)40 Test (org.junit.Test)33 ArchivedJson (org.apache.flink.runtime.webmonitor.history.ArchivedJson)16 JsonArchivist (org.apache.flink.runtime.webmonitor.history.JsonArchivist)16 ExecutionGraphHolder (org.apache.flink.runtime.webmonitor.ExecutionGraphHolder)14 HashMap (java.util.HashMap)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 CheckpointStatsHistory (org.apache.flink.runtime.checkpoint.CheckpointStatsHistory)8 CheckpointStatsSnapshot (org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot)8 AccessExecutionJobVertex (org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 JobID (org.apache.flink.api.common.JobID)4 AccessExecution (org.apache.flink.runtime.executiongraph.AccessExecution)4 PendingCheckpointStats (org.apache.flink.runtime.checkpoint.PendingCheckpointStats)3 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)3 ExternalizedCheckpointSettings (org.apache.flink.runtime.jobgraph.tasks.ExternalizedCheckpointSettings)3 JobSnapshottingSettings (org.apache.flink.runtime.jobgraph.tasks.JobSnapshottingSettings)3 ArrayList (java.util.ArrayList)2 AbstractCheckpointStats (org.apache.flink.runtime.checkpoint.AbstractCheckpointStats)2 CompletedCheckpointStats (org.apache.flink.runtime.checkpoint.CompletedCheckpointStats)2