use of org.apache.flink.runtime.clusterframework.types.SlotProfile in project flink by apache.
the class MergingSharedSlotProfileRetrieverTest method testPreferredAllocationsOfSlotProfile.
@Test
public void testPreferredAllocationsOfSlotProfile() throws ExecutionException, InterruptedException {
AllocationID prevAllocationID1 = new AllocationID();
AllocationID prevAllocationID2 = new AllocationID();
List<AllocationID> prevAllocationIDs = Arrays.asList(prevAllocationID1, prevAllocationID2, new AllocationID());
SlotProfile slotProfile = getSlotProfile(ResourceProfile.ZERO, prevAllocationIDs, 2);
assertThat(slotProfile.getPreferredAllocations(), containsInAnyOrder(prevAllocationID1, prevAllocationID2));
}
use of org.apache.flink.runtime.clusterframework.types.SlotProfile in project flink by apache.
the class MergingSharedSlotProfileRetrieverTest method testResourceProfileOfSlotProfile.
@Test
public void testResourceProfileOfSlotProfile() throws ExecutionException, InterruptedException {
ResourceProfile resourceProfile = ResourceProfile.newBuilder().setCpuCores(1.0).setTaskHeapMemory(MemorySize.ofMebiBytes(1)).build();
SlotProfile slotProfile = getSlotProfile(resourceProfile, Collections.nCopies(3, new AllocationID()), 2);
assertThat(slotProfile.getTaskResourceProfile(), is(resourceProfile));
assertThat(slotProfile.getPhysicalSlotResourceProfile(), is(resourceProfile));
}
use of org.apache.flink.runtime.clusterframework.types.SlotProfile in project flink by apache.
the class PhysicalSlotProviderImpl method allocatePhysicalSlot.
@Override
public CompletableFuture<PhysicalSlotRequest.Result> allocatePhysicalSlot(PhysicalSlotRequest physicalSlotRequest) {
SlotRequestId slotRequestId = physicalSlotRequest.getSlotRequestId();
SlotProfile slotProfile = physicalSlotRequest.getSlotProfile();
ResourceProfile resourceProfile = slotProfile.getPhysicalSlotResourceProfile();
LOG.debug("Received slot request [{}] with resource requirements: {}", slotRequestId, resourceProfile);
Optional<PhysicalSlot> availablePhysicalSlot = tryAllocateFromAvailable(slotRequestId, slotProfile);
CompletableFuture<PhysicalSlot> slotFuture;
slotFuture = availablePhysicalSlot.map(CompletableFuture::completedFuture).orElseGet(() -> requestNewSlot(slotRequestId, resourceProfile, slotProfile.getPreferredAllocations(), physicalSlotRequest.willSlotBeOccupiedIndefinitely()));
return slotFuture.thenApply(physicalSlot -> new PhysicalSlotRequest.Result(slotRequestId, physicalSlot));
}
Aggregations