Search in sources :

Example 96 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.

the class SharingPhysicalSlotRequestBulkTest method testMarkFulfilled.

@Test
public void testMarkFulfilled() {
    SharingPhysicalSlotRequestBulk bulk = createBulk();
    AllocationID allocationId = new AllocationID();
    bulk.markFulfilled(SG1, allocationId);
    assertThat(bulk.getPendingRequests(), containsInAnyOrder(RP2));
    assertThat(bulk.getAllocationIdsOfFulfilledRequests(), containsInAnyOrder(allocationId));
}
Also used : AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) Test(org.junit.Test)

Example 97 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.

the class SharingPhysicalSlotRequestBulkTest method testCancel.

@Test
public void testCancel() {
    LogicalSlotRequestCanceller canceller = new LogicalSlotRequestCanceller();
    SharingPhysicalSlotRequestBulk bulk = createBulk(canceller);
    bulk.markFulfilled(SG1, new AllocationID());
    Throwable cause = new Throwable();
    bulk.cancel(cause);
    assertThat(canceller.cancellations, containsInAnyOrder(Tuple2.of(EV1, cause), Tuple2.of(EV2, cause), Tuple2.of(EV4, cause)));
}
Also used : AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) Test(org.junit.Test)

Example 98 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.

the class MergingSharedSlotProfileRetrieverTest method testGetEmptySlotProfile.

@Test
public void testGetEmptySlotProfile() throws ExecutionException, InterruptedException {
    SharedSlotProfileRetriever sharedSlotProfileRetriever = new MergingSharedSlotProfileRetrieverFactory(EMPTY_PREFERRED_LOCATIONS_RETRIEVER, executionVertexID -> Optional.of(new AllocationID()), () -> Collections.emptySet()).createFromBulk(Collections.emptySet());
    SlotProfile slotProfile = sharedSlotProfileRetriever.getSlotProfile(new ExecutionSlotSharingGroup(), ResourceProfile.ZERO);
    assertThat(slotProfile.getTaskResourceProfile(), is(ResourceProfile.ZERO));
    assertThat(slotProfile.getPhysicalSlotResourceProfile(), is(ResourceProfile.ZERO));
    assertThat(slotProfile.getPreferredLocations(), hasSize(0));
    assertThat(slotProfile.getPreferredAllocations(), hasSize(0));
    assertThat(slotProfile.getReservedAllocations(), hasSize(0));
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) HashMap(java.util.HashMap) SlotProfile(org.apache.flink.runtime.clusterframework.types.SlotProfile) MemorySize(org.apache.flink.configuration.MemorySize) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) InetAddress(java.net.InetAddress) HashSet(java.util.HashSet) Assert.assertThat(org.junit.Assert.assertThat) Map(java.util.Map) TestLogger(org.apache.flink.util.TestLogger) Matchers.hasSize(org.hamcrest.Matchers.hasSize) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) FlinkRuntimeException(org.apache.flink.util.FlinkRuntimeException) Collection(java.util.Collection) Test(org.junit.Test) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) UnknownHostException(java.net.UnknownHostException) Collectors(java.util.stream.Collectors) ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) Collections(java.util.Collections) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) SlotProfile(org.apache.flink.runtime.clusterframework.types.SlotProfile) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) Test(org.junit.Test)

Example 99 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.

the class MergingSharedSlotProfileRetrieverTest method testReservedAllocationsOfSlotProfile.

@Test
public void testReservedAllocationsOfSlotProfile() throws ExecutionException, InterruptedException {
    List<AllocationID> reservedAllocationIds = Arrays.asList(new AllocationID(), new AllocationID(), new AllocationID());
    SlotProfile slotProfile = getSlotProfile(EMPTY_PREFERRED_LOCATIONS_RETRIEVER, Collections.emptyList(), ResourceProfile.ZERO, Collections.emptyList(), reservedAllocationIds, 0);
    assertThat(slotProfile.getReservedAllocations(), containsInAnyOrder(reservedAllocationIds.toArray()));
}
Also used : SlotProfile(org.apache.flink.runtime.clusterframework.types.SlotProfile) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) Test(org.junit.Test)

Example 100 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.

the class MergingSharedSlotProfileRetrieverTest method testPreferredLocationsOfSlotProfile.

@Test
public void testPreferredLocationsOfSlotProfile() throws ExecutionException, InterruptedException {
    // preferred locations
    List<ExecutionVertexID> executions = IntStream.range(0, 3).mapToObj(i -> new ExecutionVertexID(new JobVertexID(), 0)).collect(Collectors.toList());
    List<TaskManagerLocation> allLocations = executions.stream().map(e -> createTaskManagerLocation()).collect(Collectors.toList());
    Map<ExecutionVertexID, Collection<TaskManagerLocation>> locations = new HashMap<>();
    locations.put(executions.get(0), Arrays.asList(allLocations.get(0), allLocations.get(1)));
    locations.put(executions.get(1), Arrays.asList(allLocations.get(1), allLocations.get(2)));
    List<AllocationID> prevAllocationIds = Collections.nCopies(3, new AllocationID());
    SlotProfile slotProfile = getSlotProfile((executionVertexId, producersToIgnore) -> {
        assertThat(producersToIgnore, containsInAnyOrder(executions.toArray()));
        return locations.get(executionVertexId);
    }, executions, ResourceProfile.ZERO, prevAllocationIds, prevAllocationIds, 2);
    assertThat(slotProfile.getPreferredLocations().stream().filter(allLocations.get(0)::equals).count(), is(1L));
    assertThat(slotProfile.getPreferredLocations().stream().filter(allLocations.get(1)::equals).count(), is(2L));
    assertThat(slotProfile.getPreferredLocations().stream().filter(allLocations.get(2)::equals).count(), is(1L));
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) HashMap(java.util.HashMap) SlotProfile(org.apache.flink.runtime.clusterframework.types.SlotProfile) MemorySize(org.apache.flink.configuration.MemorySize) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) InetAddress(java.net.InetAddress) HashSet(java.util.HashSet) Assert.assertThat(org.junit.Assert.assertThat) Map(java.util.Map) TestLogger(org.apache.flink.util.TestLogger) Matchers.hasSize(org.hamcrest.Matchers.hasSize) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) FlinkRuntimeException(org.apache.flink.util.FlinkRuntimeException) Collection(java.util.Collection) Test(org.junit.Test) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) UnknownHostException(java.net.UnknownHostException) Collectors(java.util.stream.Collectors) ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) Collections(java.util.Collections) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) HashMap(java.util.HashMap) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) SlotProfile(org.apache.flink.runtime.clusterframework.types.SlotProfile) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)194 Test (org.junit.Test)137 JobID (org.apache.flink.api.common.JobID)106 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)60 CompletableFuture (java.util.concurrent.CompletableFuture)56 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)56 SlotID (org.apache.flink.runtime.clusterframework.types.SlotID)53 ArrayList (java.util.ArrayList)39 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)36 Collection (java.util.Collection)35 Time (org.apache.flink.api.common.time.Time)35 Configuration (org.apache.flink.configuration.Configuration)34 Acknowledge (org.apache.flink.runtime.messages.Acknowledge)34 SlotOffer (org.apache.flink.runtime.taskexecutor.slot.SlotOffer)34 List (java.util.List)32 TestLogger (org.apache.flink.util.TestLogger)32 FlinkException (org.apache.flink.util.FlinkException)31 Matchers.is (org.hamcrest.Matchers.is)31 Assert.assertThat (org.junit.Assert.assertThat)31 Arrays (java.util.Arrays)30