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