Search in sources :

Example 1 with SlotInfo

use of org.apache.flink.runtime.jobmaster.SlotInfo in project flink by apache.

the class LocationPreferenceSlotSelectionStrategyTest method returnsHostLocalMatchingIfExactTMLocationCannotBeFulfilled.

@Test
public void returnsHostLocalMatchingIfExactTMLocationCannotBeFulfilled() {
    SlotProfile slotProfile = SlotProfileTestingUtils.preferredLocality(resourceProfile, Collections.singletonList(tmlX));
    Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile);
    Assert.assertTrue(match.isPresent());
    final SlotSelectionStrategy.SlotInfoAndLocality slotInfoAndLocality = match.get();
    final SlotInfo slotInfo = slotInfoAndLocality.getSlotInfo();
    assertThat(candidates, hasItem(withSlotInfo(slotInfo)));
    assertThat(slotInfoAndLocality, hasLocality(Locality.HOST_LOCAL));
}
Also used : LocationPreferenceSlotSelectionStrategy(org.apache.flink.runtime.jobmaster.slotpool.LocationPreferenceSlotSelectionStrategy) SlotSelectionStrategy(org.apache.flink.runtime.jobmaster.slotpool.SlotSelectionStrategy) SlotInfo(org.apache.flink.runtime.jobmaster.SlotInfo) Test(org.junit.Test)

Example 2 with SlotInfo

use of org.apache.flink.runtime.jobmaster.SlotInfo in project flink by apache.

the class DeclarativeSlotPoolService method createAllocatedSlotReport.

@Override
public AllocatedSlotReport createAllocatedSlotReport(ResourceID taskManagerId) {
    assertHasBeenStarted();
    final Collection<AllocatedSlotInfo> allocatedSlotInfos = new ArrayList<>();
    for (SlotInfo slotInfo : declarativeSlotPool.getAllSlotsInformation()) {
        if (slotInfo.getTaskManagerLocation().getResourceID().equals(taskManagerId)) {
            allocatedSlotInfos.add(new AllocatedSlotInfo(slotInfo.getPhysicalSlotNumber(), slotInfo.getAllocationId()));
        }
    }
    return new AllocatedSlotReport(jobId, allocatedSlotInfos);
}
Also used : AllocatedSlotReport(org.apache.flink.runtime.jobmaster.AllocatedSlotReport) ArrayList(java.util.ArrayList) AllocatedSlotInfo(org.apache.flink.runtime.jobmaster.AllocatedSlotInfo) SlotInfo(org.apache.flink.runtime.jobmaster.SlotInfo) AllocatedSlotInfo(org.apache.flink.runtime.jobmaster.AllocatedSlotInfo)

Example 3 with SlotInfo

use of org.apache.flink.runtime.jobmaster.SlotInfo in project flink by apache.

the class SlotSharingSlotAllocatorTest method testReserveAvailableResources.

@Test
public void testReserveAvailableResources() {
    final SlotSharingSlotAllocator slotAllocator = SlotSharingSlotAllocator.createSlotSharingSlotAllocator(TEST_RESERVE_SLOT_FUNCTION, TEST_FREE_SLOT_FUNCTION, TEST_IS_SLOT_FREE_FUNCTION);
    final JobInformation jobInformation = new TestJobInformation(Arrays.asList(vertex1, vertex2, vertex3));
    final VertexParallelismWithSlotSharing slotAssignments = slotAllocator.determineParallelism(jobInformation, getSlots(50)).get();
    final ReservedSlots reservedSlots = slotAllocator.tryReserveResources(slotAssignments).orElseThrow(() -> new RuntimeException("Expected that reservation succeeds."));
    final Map<ExecutionVertexID, SlotInfo> expectedAssignments = new HashMap<>();
    for (SlotSharingSlotAllocator.ExecutionSlotSharingGroupAndSlot assignment : slotAssignments.getAssignments()) {
        for (ExecutionVertexID containedExecutionVertex : assignment.getExecutionSlotSharingGroup().getContainedExecutionVertices()) {
            expectedAssignments.put(containedExecutionVertex, assignment.getSlotInfo());
        }
    }
    for (Map.Entry<ExecutionVertexID, SlotInfo> expectedAssignment : expectedAssignments.entrySet()) {
        final LogicalSlot assignedSlot = reservedSlots.getSlotFor(expectedAssignment.getKey());
        final SlotInfo backingSlot = expectedAssignment.getValue();
        assertThat(assignedSlot.getAllocationId(), is(backingSlot.getAllocationId()));
    }
}
Also used : HashMap(java.util.HashMap) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) SlotInfo(org.apache.flink.runtime.jobmaster.SlotInfo) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 4 with SlotInfo

use of org.apache.flink.runtime.jobmaster.SlotInfo in project flink by apache.

the class DeclarativeSlotPoolServiceTest method testCreateAllocatedSlotReport.

@Test
public void testCreateAllocatedSlotReport() throws Exception {
    final LocalTaskManagerLocation taskManagerLocation1 = new LocalTaskManagerLocation();
    final LocalTaskManagerLocation taskManagerLocation2 = new LocalTaskManagerLocation();
    final SimpleSlotContext simpleSlotContext2 = createSimpleSlotContext(taskManagerLocation2);
    final Collection<SlotInfo> slotInfos = Arrays.asList(createSimpleSlotContext(taskManagerLocation1), simpleSlotContext2);
    try (DeclarativeSlotPoolService declarativeSlotPoolService = createDeclarativeSlotPoolService(new TestingDeclarativeSlotPoolFactory(new TestingDeclarativeSlotPoolBuilder().setGetAllSlotsInformationSupplier(() -> slotInfos)))) {
        final AllocatedSlotReport allocatedSlotReport = declarativeSlotPoolService.createAllocatedSlotReport(taskManagerLocation2.getResourceID());
        assertThat(allocatedSlotReport.getAllocatedSlotInfos(), contains(matchesWithSlotContext(simpleSlotContext2)));
    }
}
Also used : SimpleSlotContext(org.apache.flink.runtime.instance.SimpleSlotContext) AllocatedSlotReport(org.apache.flink.runtime.jobmaster.AllocatedSlotReport) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) SlotInfo(org.apache.flink.runtime.jobmaster.SlotInfo) AllocatedSlotInfo(org.apache.flink.runtime.jobmaster.AllocatedSlotInfo) Test(org.junit.Test)

Example 5 with SlotInfo

use of org.apache.flink.runtime.jobmaster.SlotInfo in project flink by apache.

the class DefaultDeclarativeSlotPoolTest method testRegisterSlotsAcceptsAllSlots.

@Test
public void testRegisterSlotsAcceptsAllSlots() {
    final DefaultDeclarativeSlotPool declarativeSlotPool = createDefaultDeclarativeSlotPool();
    final int numberSlots = 10;
    final Collection<SlotOffer> slots = createSlotOffersForResourceRequirements(ResourceCounter.withResource(RESOURCE_PROFILE_1, numberSlots));
    declarativeSlotPool.registerSlots(slots, new LocalTaskManagerLocation(), SlotPoolTestUtils.createTaskManagerGateway(null), 0);
    final Collection<? extends SlotInfo> allSlotsInformation = declarativeSlotPool.getAllSlotsInformation();
    assertThat(allSlotsInformation, hasSize(numberSlots));
    for (SlotInfo slotInfo : allSlotsInformation) {
        assertThat(slotInfo.getResourceProfile(), is(RESOURCE_PROFILE_1));
    }
}
Also used : SlotOffer(org.apache.flink.runtime.taskexecutor.slot.SlotOffer) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) SlotInfo(org.apache.flink.runtime.jobmaster.SlotInfo) Test(org.junit.Test)

Aggregations

SlotInfo (org.apache.flink.runtime.jobmaster.SlotInfo)8 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 AllocatedSlotInfo (org.apache.flink.runtime.jobmaster.AllocatedSlotInfo)2 AllocatedSlotReport (org.apache.flink.runtime.jobmaster.AllocatedSlotReport)2 LocalTaskManagerLocation (org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation)2 Map (java.util.Map)1 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)1 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)1 SimpleSlotContext (org.apache.flink.runtime.instance.SimpleSlotContext)1 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)1 SlotSharingGroup (org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup)1 LogicalSlot (org.apache.flink.runtime.jobmaster.LogicalSlot)1 LocationPreferenceSlotSelectionStrategy (org.apache.flink.runtime.jobmaster.slotpool.LocationPreferenceSlotSelectionStrategy)1 SlotSelectionStrategy (org.apache.flink.runtime.jobmaster.slotpool.SlotSelectionStrategy)1 ExecutionVertexID (org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID)1 SlotOffer (org.apache.flink.runtime.taskexecutor.slot.SlotOffer)1 ResourceCounter (org.apache.flink.runtime.util.ResourceCounter)1