Search in sources :

Example 6 with SlotProfile

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));
}
Also used : SlotProfile(org.apache.flink.runtime.clusterframework.types.SlotProfile) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) Test(org.junit.Test)

Example 7 with SlotProfile

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));
}
Also used : ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) SlotProfile(org.apache.flink.runtime.clusterframework.types.SlotProfile) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) Test(org.junit.Test)

Example 8 with SlotProfile

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));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) CompletableFuture(java.util.concurrent.CompletableFuture) SlotProfile(org.apache.flink.runtime.clusterframework.types.SlotProfile)

Aggregations

SlotProfile (org.apache.flink.runtime.clusterframework.types.SlotProfile)8 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)6 Test (org.junit.Test)6 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)5 InetAddress (java.net.InetAddress)2 UnknownHostException (java.net.UnknownHostException)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 ExecutionException (java.util.concurrent.ExecutionException)2 Collectors (java.util.stream.Collectors)2 IntStream (java.util.stream.IntStream)2 MemorySize (org.apache.flink.configuration.MemorySize)2 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)2 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)2