Search in sources :

Example 31 with ExecutionJobVertex

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

the class CheckpointStatsTrackerTest method testGetSnapshottingSettings.

/**
	 * Tests access to the snapshotting settings.
	 */
@Test
public void testGetSnapshottingSettings() throws Exception {
    ExecutionJobVertex jobVertex = mock(ExecutionJobVertex.class);
    when(jobVertex.getJobVertexId()).thenReturn(new JobVertexID());
    when(jobVertex.getParallelism()).thenReturn(1);
    JobSnapshottingSettings snapshottingSettings = new JobSnapshottingSettings(Collections.singletonList(new JobVertexID()), Collections.singletonList(new JobVertexID()), Collections.singletonList(new JobVertexID()), 181238123L, 19191992L, 191929L, 123, ExternalizedCheckpointSettings.none(), null, false);
    CheckpointStatsTracker tracker = new CheckpointStatsTracker(0, Collections.singletonList(jobVertex), snapshottingSettings, new UnregisteredMetricsGroup());
    assertEquals(snapshottingSettings, tracker.getSnapshottingSettings());
}
Also used : UnregisteredMetricsGroup(org.apache.flink.metrics.groups.UnregisteredMetricsGroup) ExecutionJobVertex(org.apache.flink.runtime.executiongraph.ExecutionJobVertex) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) JobSnapshottingSettings(org.apache.flink.runtime.jobgraph.tasks.JobSnapshottingSettings) Test(org.junit.Test)

Example 32 with ExecutionJobVertex

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

the class KvStateLocationRegistryTest method testUnregisterFailures.

/**
	 * Tests failures during unregistration.
	 */
@Test
public void testUnregisterFailures() throws Exception {
    String name = "IrGnc73237TAs";
    ExecutionJobVertex[] vertices = new ExecutionJobVertex[] { createJobVertex(32), createJobVertex(13) };
    Map<JobVertexID, ExecutionJobVertex> vertexMap = new HashMap<>();
    for (ExecutionJobVertex vertex : vertices) {
        vertexMap.put(vertex.getJobVertexId(), vertex);
    }
    KvStateLocationRegistry registry = new KvStateLocationRegistry(new JobID(), vertexMap);
    // First operator registers name
    registry.notifyKvStateRegistered(vertices[0].getJobVertexId(), new KeyGroupRange(0, 0), name, new KvStateID(), mock(KvStateServerAddress.class));
    try {
        // Unregister not registered keyGroupIndex
        int notRegisteredKeyGroupIndex = 2;
        registry.notifyKvStateUnregistered(vertices[0].getJobVertexId(), new KeyGroupRange(notRegisteredKeyGroupIndex, notRegisteredKeyGroupIndex), name);
        fail("Did not throw expected Exception");
    } catch (IllegalArgumentException expected) {
    }
    try {
        // Wrong operator tries to unregister
        registry.notifyKvStateUnregistered(vertices[1].getJobVertexId(), new KeyGroupRange(0, 0), name);
        fail("Did not throw expected Exception");
    } catch (IllegalArgumentException expected) {
    }
}
Also used : HashMap(java.util.HashMap) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) KeyGroupRange(org.apache.flink.runtime.state.KeyGroupRange) ExecutionJobVertex(org.apache.flink.runtime.executiongraph.ExecutionJobVertex) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 33 with ExecutionJobVertex

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

the class KvStateLocationRegistryTest method createJobVertex.

// ------------------------------------------------------------------------
private ExecutionJobVertex createJobVertex(int maxParallelism) {
    JobVertexID id = new JobVertexID();
    ExecutionJobVertex vertex = mock(ExecutionJobVertex.class);
    when(vertex.getJobVertexId()).thenReturn(id);
    when(vertex.getMaxParallelism()).thenReturn(maxParallelism);
    return vertex;
}
Also used : ExecutionJobVertex(org.apache.flink.runtime.executiongraph.ExecutionJobVertex) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID)

Example 34 with ExecutionJobVertex

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

the class KvStateLocationRegistryTest method testUnregisterBeforeRegister.

/**
	 * Tests exception on unregistration before registration.
	 */
@Test
public void testUnregisterBeforeRegister() throws Exception {
    ExecutionJobVertex vertex = createJobVertex(4);
    Map<JobVertexID, ExecutionJobVertex> vertexMap = createVertexMap(vertex);
    KvStateLocationRegistry registry = new KvStateLocationRegistry(new JobID(), vertexMap);
    try {
        registry.notifyKvStateUnregistered(vertex.getJobVertexId(), new KeyGroupRange(0, 0), "any-name");
        fail("Did not throw expected Exception, because of missing registration");
    } catch (IllegalArgumentException ignored) {
    // Expected
    }
}
Also used : ExecutionJobVertex(org.apache.flink.runtime.executiongraph.ExecutionJobVertex) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) KeyGroupRange(org.apache.flink.runtime.state.KeyGroupRange) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 35 with ExecutionJobVertex

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

the class KvStateLocationRegistryTest method testRegisterAndLookup.

/**
	 * Simple test registering/unregistereing state and looking it up again.
	 */
@Test
public void testRegisterAndLookup() throws Exception {
    String[] registrationNames = new String[] { "TAsIrGnc7MULwVupNKZ0", "086133IrGn0Ii2853237" };
    ExecutionJobVertex[] vertices = new ExecutionJobVertex[] { createJobVertex(32), createJobVertex(13) };
    // IDs for each key group of each vertex
    KvStateID[][] ids = new KvStateID[vertices.length][];
    for (int i = 0; i < ids.length; i++) {
        ids[i] = new KvStateID[vertices[i].getMaxParallelism()];
        for (int j = 0; j < vertices[i].getMaxParallelism(); j++) {
            ids[i][j] = new KvStateID();
        }
    }
    KvStateServerAddress server = new KvStateServerAddress(InetAddress.getLocalHost(), 12032);
    // Create registry
    Map<JobVertexID, ExecutionJobVertex> vertexMap = createVertexMap(vertices);
    KvStateLocationRegistry registry = new KvStateLocationRegistry(new JobID(), vertexMap);
    // Register
    for (int i = 0; i < vertices.length; i++) {
        int numKeyGroups = vertices[i].getMaxParallelism();
        for (int keyGroupIndex = 0; keyGroupIndex < numKeyGroups; keyGroupIndex++) {
            // Register
            registry.notifyKvStateRegistered(vertices[i].getJobVertexId(), new KeyGroupRange(keyGroupIndex, keyGroupIndex), registrationNames[i], ids[i][keyGroupIndex], server);
        }
    }
    // Verify all registrations
    for (int i = 0; i < vertices.length; i++) {
        KvStateLocation location = registry.getKvStateLocation(registrationNames[i]);
        assertNotNull(location);
        int maxParallelism = vertices[i].getMaxParallelism();
        for (int keyGroupIndex = 0; keyGroupIndex < maxParallelism; keyGroupIndex++) {
            assertEquals(ids[i][keyGroupIndex], location.getKvStateID(keyGroupIndex));
            assertEquals(server, location.getKvStateServerAddress(keyGroupIndex));
        }
    }
    // Unregister
    for (int i = 0; i < vertices.length; i++) {
        int numKeyGroups = vertices[i].getMaxParallelism();
        JobVertexID jobVertexId = vertices[i].getJobVertexId();
        for (int keyGroupIndex = 0; keyGroupIndex < numKeyGroups; keyGroupIndex++) {
            registry.notifyKvStateUnregistered(jobVertexId, new KeyGroupRange(keyGroupIndex, keyGroupIndex), registrationNames[i]);
        }
    }
    for (int i = 0; i < registrationNames.length; i++) {
        assertNull(registry.getKvStateLocation(registrationNames[i]));
    }
}
Also used : JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) KeyGroupRange(org.apache.flink.runtime.state.KeyGroupRange) ExecutionJobVertex(org.apache.flink.runtime.executiongraph.ExecutionJobVertex) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Aggregations

ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)37 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)25 Test (org.junit.Test)25 JobID (org.apache.flink.api.common.JobID)17 HashMap (java.util.HashMap)12 ExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionVertex)12 KeyGroupRange (org.apache.flink.runtime.state.KeyGroupRange)9 AcknowledgeCheckpoint (org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint)8 UnregisteredMetricsGroup (org.apache.flink.metrics.groups.UnregisteredMetricsGroup)7 StreamStateHandle (org.apache.flink.runtime.state.StreamStateHandle)7 ArrayList (java.util.ArrayList)6 JobSnapshottingSettings (org.apache.flink.runtime.jobgraph.tasks.JobSnapshottingSettings)6 DeclineCheckpoint (org.apache.flink.runtime.messages.checkpoint.DeclineCheckpoint)6 ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)5 KeyGroupsStateHandle (org.apache.flink.runtime.state.KeyGroupsStateHandle)5 Configuration (org.apache.flink.configuration.Configuration)4 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)4 ByteStreamStateHandle (org.apache.flink.runtime.state.memory.ByteStreamStateHandle)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3