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));
}
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);
}
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()));
}
}
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)));
}
}
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));
}
}
Aggregations