use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.
the class DeclarativeSlotPoolBridgeTest method testNotEnoughResourcesAvailableFailsPendingRequests.
@Test
public void testNotEnoughResourcesAvailableFailsPendingRequests() throws Exception {
final SlotRequestId slotRequestId = new SlotRequestId();
final TestingDeclarativeSlotPoolFactory declarativeSlotPoolFactory = new TestingDeclarativeSlotPoolFactory(TestingDeclarativeSlotPool.builder());
try (DeclarativeSlotPoolBridge declarativeSlotPoolBridge = createDeclarativeSlotPoolBridge(declarativeSlotPoolFactory, requestSlotMatchingStrategy)) {
declarativeSlotPoolBridge.start(jobMasterId, "localhost", mainThreadExecutor);
CompletableFuture<PhysicalSlot> slotAllocationFuture = CompletableFuture.supplyAsync(() -> declarativeSlotPoolBridge.requestNewAllocatedSlot(slotRequestId, ResourceProfile.UNKNOWN, Time.minutes(5)), mainThreadExecutor).get();
mainThreadExecutor.execute(() -> declarativeSlotPoolBridge.notifyNotEnoughResourcesAvailable(Collections.emptyList()));
assertThat(slotAllocationFuture, FlinkMatchers.futureWillCompleteExceptionally(NoResourceAvailableException.class, Duration.ofSeconds(10)));
}
}
use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.
the class DeclarativeSlotPoolBridgeTest method testAcceptingOfferedSlotsWithoutResourceManagerConnected.
@Test
public void testAcceptingOfferedSlotsWithoutResourceManagerConnected() throws Exception {
try (DeclarativeSlotPoolBridge declarativeSlotPoolBridge = createDeclarativeSlotPoolBridge(new DefaultDeclarativeSlotPoolFactory(), requestSlotMatchingStrategy)) {
declarativeSlotPoolBridge.start(jobMasterId, "localhost", mainThreadExecutor);
final CompletableFuture<PhysicalSlot> slotFuture = declarativeSlotPoolBridge.requestNewAllocatedSlot(new SlotRequestId(), ResourceProfile.UNKNOWN, rpcTimeout);
final LocalTaskManagerLocation localTaskManagerLocation = new LocalTaskManagerLocation();
declarativeSlotPoolBridge.registerTaskManager(localTaskManagerLocation.getResourceID());
final AllocationID allocationId = new AllocationID();
declarativeSlotPoolBridge.offerSlots(localTaskManagerLocation, new SimpleAckingTaskManagerGateway(), Collections.singleton(new SlotOffer(allocationId, 0, ResourceProfile.ANY)));
assertThat(slotFuture.join().getAllocationId(), is(allocationId));
}
}
use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.
the class DeclarativeSlotPoolBridgeTest method testReleasingAllocatedSlot.
@Test
public void testReleasingAllocatedSlot() throws Exception {
final CompletableFuture<AllocationID> releaseSlotFuture = new CompletableFuture<>();
final AllocationID expectedAllocationId = new AllocationID();
final PhysicalSlot allocatedSlot = createAllocatedSlot(expectedAllocationId);
final TestingDeclarativeSlotPoolBuilder builder = TestingDeclarativeSlotPool.builder().setReserveFreeSlotFunction((allocationId, resourceProfile) -> {
assertThat(allocationId, is(expectedAllocationId));
return allocatedSlot;
}).setFreeReservedSlotFunction((allocationID, throwable, aLong) -> {
releaseSlotFuture.complete(allocationID);
return ResourceCounter.empty();
});
final TestingDeclarativeSlotPoolFactory declarativeSlotPoolFactory = new TestingDeclarativeSlotPoolFactory(builder);
try (DeclarativeSlotPoolBridge declarativeSlotPoolBridge = createDeclarativeSlotPoolBridge(declarativeSlotPoolFactory, requestSlotMatchingStrategy)) {
declarativeSlotPoolBridge.start(jobMasterId, "localhost", mainThreadExecutor);
final SlotRequestId slotRequestId = new SlotRequestId();
declarativeSlotPoolBridge.allocateAvailableSlot(slotRequestId, expectedAllocationId, allocatedSlot.getResourceProfile());
declarativeSlotPoolBridge.releaseSlot(slotRequestId, null);
assertThat(releaseSlotFuture.join(), is(expectedAllocationId));
}
}
use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.
the class DeclarativeSlotPoolBridgeResourceDeclarationTest method testRequirementsIncreasedOnNewAllocation.
@Test
public void testRequirementsIncreasedOnNewAllocation() throws Exception {
declarativeSlotPoolBridge.start(jobMasterId, "localhost", mainThreadExecutor);
// requesting the allocation of a new slot should increase the requirements
declarativeSlotPoolBridge.requestNewAllocatedSlot(new SlotRequestId(), ResourceProfile.UNKNOWN, Time.minutes(5));
assertThat(requirementListener.getRequirements().getResourceCount(ResourceProfile.UNKNOWN), is(1));
}
use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.
the class PhysicalSlotRequestBulkCheckerImplTest method testBulkTimeoutOnCheck.
@Test
public void testBulkTimeoutOnCheck() {
final PhysicalSlotRequestBulkWithTimestamp bulk = createPhysicalSlotRequestBulkWithTimestamp(new SlotRequestId());
clock.advanceTime(TIMEOUT.toMilliseconds() + 1L, TimeUnit.MILLISECONDS);
assertThat(checkBulkTimeout(bulk), is(PhysicalSlotRequestBulkCheckerImpl.TimeoutCheckResult.TIMEOUT));
}
Aggregations