Search in sources :

Example 41 with SlotSharingGroup

use of org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup in project flink by apache.

the class VertexSlotSharingTest method testAssignSlotSharingGroup.

/**
 * Test setup: - v1 is isolated, no slot sharing. - v2 and v3 (not connected) share slots. - v4
 * and v5 (connected) share slots.
 */
@Test
public void testAssignSlotSharingGroup() {
    try {
        JobVertex v1 = new JobVertex("v1");
        JobVertex v2 = new JobVertex("v2");
        JobVertex v3 = new JobVertex("v3");
        JobVertex v4 = new JobVertex("v4");
        JobVertex v5 = new JobVertex("v5");
        v1.setParallelism(4);
        v2.setParallelism(5);
        v3.setParallelism(7);
        v4.setParallelism(1);
        v5.setParallelism(11);
        v1.setInvokableClass(AbstractInvokable.class);
        v2.setInvokableClass(AbstractInvokable.class);
        v3.setInvokableClass(AbstractInvokable.class);
        v4.setInvokableClass(AbstractInvokable.class);
        v5.setInvokableClass(AbstractInvokable.class);
        v2.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
        v5.connectNewDataSetAsInput(v4, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
        SlotSharingGroup jg1 = new SlotSharingGroup();
        v2.setSlotSharingGroup(jg1);
        v3.setSlotSharingGroup(jg1);
        SlotSharingGroup jg2 = new SlotSharingGroup();
        v4.setSlotSharingGroup(jg2);
        v5.setSlotSharingGroup(jg2);
        List<JobVertex> vertices = new ArrayList<>(Arrays.asList(v1, v2, v3, v4, v5));
        ExecutionGraph eg = TestingDefaultExecutionGraphBuilder.newBuilder().setVertexParallelismStore(SchedulerBase.computeVertexParallelismStore(vertices)).build();
        eg.attachJobGraph(vertices);
        // verify that the vertices are all in the same slot sharing group
        SlotSharingGroup group1;
        SlotSharingGroup group2;
        // verify that v1 tasks are not in the same slot sharing group as v2
        assertNotEquals(eg.getJobVertex(v1.getID()).getSlotSharingGroup(), eg.getJobVertex(v2.getID()).getSlotSharingGroup());
        // v2 and v3 are shared
        group1 = eg.getJobVertex(v2.getID()).getSlotSharingGroup();
        assertNotNull(group1);
        assertEquals(group1, eg.getJobVertex(v3.getID()).getSlotSharingGroup());
        assertEquals(2, group1.getJobVertexIds().size());
        assertTrue(group1.getJobVertexIds().contains(v2.getID()));
        assertTrue(group1.getJobVertexIds().contains(v3.getID()));
        // v4 and v5 are shared
        group2 = eg.getJobVertex(v4.getID()).getSlotSharingGroup();
        assertNotNull(group2);
        assertEquals(group2, eg.getJobVertex(v5.getID()).getSlotSharingGroup());
        assertEquals(2, group1.getJobVertexIds().size());
        assertTrue(group2.getJobVertexIds().contains(v4.getID()));
        assertTrue(group2.getJobVertexIds().contains(v5.getID()));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ArrayList(java.util.ArrayList) SlotSharingGroup(org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup) Test(org.junit.Test)

Example 42 with SlotSharingGroup

use of org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup in project flink by apache.

the class AdaptiveSchedulerSlotSharingITCase method createJobGraphWithSlotSharingGroup.

/**
 * Returns a JobGraph that requires slot sharing to work in order to be able to run with a
 * single slot.
 */
private static JobGraph createJobGraphWithSlotSharingGroup() {
    final SlotSharingGroup slotSharingGroup = new SlotSharingGroup();
    final JobVertex source = new JobVertex("Source");
    source.setInvokableClass(NoOpInvokable.class);
    source.setParallelism(PARALLELISM);
    source.setSlotSharingGroup(slotSharingGroup);
    final JobVertex sink = new JobVertex("sink");
    sink.setInvokableClass(NoOpInvokable.class);
    sink.setParallelism(PARALLELISM);
    sink.setSlotSharingGroup(slotSharingGroup);
    sink.connectNewDataSetAsInput(source, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
    return JobGraphTestUtils.streamingJobGraph(source, sink);
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) SlotSharingGroup(org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup)

Example 43 with SlotSharingGroup

use of org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup in project flink by apache.

the class SsgNetworkMemoryCalculationUtilsTest method testGenerateUnknownResourceProfile.

@Test
public void testGenerateUnknownResourceProfile() throws Exception {
    SlotSharingGroup slotSharingGroup0 = new SlotSharingGroup();
    slotSharingGroup0.setResourceProfile(ResourceProfile.UNKNOWN);
    SlotSharingGroup slotSharingGroup1 = new SlotSharingGroup();
    slotSharingGroup1.setResourceProfile(ResourceProfile.UNKNOWN);
    createExecutionGraphAndEnrichNetworkMemory(Arrays.asList(slotSharingGroup0, slotSharingGroup0, slotSharingGroup1));
    assertEquals(ResourceProfile.UNKNOWN, slotSharingGroup0.getResourceProfile());
    assertEquals(ResourceProfile.UNKNOWN, slotSharingGroup1.getResourceProfile());
}
Also used : SlotSharingGroup(org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup) IntermediateResultPartitionTest(org.apache.flink.runtime.executiongraph.IntermediateResultPartitionTest) Test(org.junit.Test)

Example 44 with SlotSharingGroup

use of org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup in project flink by apache.

the class LocalInputPreferredSlotSharingStrategyTest method testVerticesInDifferentSlotSharingGroups.

@Test
public void testVerticesInDifferentSlotSharingGroups() {
    final SlotSharingGroup slotSharingGroup1 = new SlotSharingGroup();
    slotSharingGroup1.addVertexToGroup(JOB_VERTEX_ID_1);
    final SlotSharingGroup slotSharingGroup2 = new SlotSharingGroup();
    slotSharingGroup2.addVertexToGroup(JOB_VERTEX_ID_2);
    final Set<SlotSharingGroup> slotSharingGroups = new HashSet<>();
    slotSharingGroups.add(slotSharingGroup1);
    slotSharingGroups.add(slotSharingGroup2);
    final SlotSharingStrategy strategy = new LocalInputPreferredSlotSharingStrategy(topology, slotSharingGroups, Collections.emptySet());
    assertThat(strategy.getExecutionSlotSharingGroups(), hasSize(4));
    assertThat(strategy.getExecutionSlotSharingGroup(ev11.getId()).getExecutionVertexIds(), containsInAnyOrder(ev11.getId()));
    assertThat(strategy.getExecutionSlotSharingGroup(ev12.getId()).getExecutionVertexIds(), containsInAnyOrder(ev12.getId()));
    assertThat(strategy.getExecutionSlotSharingGroup(ev21.getId()).getExecutionVertexIds(), containsInAnyOrder(ev21.getId()));
    assertThat(strategy.getExecutionSlotSharingGroup(ev22.getId()).getExecutionVertexIds(), containsInAnyOrder(ev22.getId()));
}
Also used : SlotSharingGroup(org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 45 with SlotSharingGroup

use of org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup in project flink by apache.

the class LocalInputPreferredSlotSharingStrategyTest method setUp.

@Before
public void setUp() throws Exception {
    topology = new TestingSchedulingTopology();
    ev11 = topology.newExecutionVertex(JOB_VERTEX_ID_1, 0);
    ev12 = topology.newExecutionVertex(JOB_VERTEX_ID_1, 1);
    ev21 = topology.newExecutionVertex(JOB_VERTEX_ID_2, 0);
    ev22 = topology.newExecutionVertex(JOB_VERTEX_ID_2, 1);
    final SlotSharingGroup slotSharingGroup = new SlotSharingGroup();
    slotSharingGroup.addVertexToGroup(JOB_VERTEX_ID_1);
    slotSharingGroup.addVertexToGroup(JOB_VERTEX_ID_2);
    slotSharingGroups = Collections.singleton(slotSharingGroup);
}
Also used : TestingSchedulingTopology(org.apache.flink.runtime.scheduler.strategy.TestingSchedulingTopology) SlotSharingGroup(org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup) Before(org.junit.Before)

Aggregations

SlotSharingGroup (org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup)53 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)35 Test (org.junit.Test)30 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)18 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)14 JobID (org.apache.flink.api.common.JobID)11 HashMap (java.util.HashMap)8 Configuration (org.apache.flink.configuration.Configuration)8 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)6 Map (java.util.Map)6 Set (java.util.Set)6 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)6 ResultPartitionType (org.apache.flink.runtime.io.network.partition.ResultPartitionType)6 CoLocationGroup (org.apache.flink.runtime.jobmanager.scheduler.CoLocationGroup)6 IOException (java.io.IOException)5 Arrays (java.util.Arrays)5 IdentityHashMap (java.util.IdentityHashMap)5 Collections (java.util.Collections)4 Comparator (java.util.Comparator)4