use of org.apache.flink.runtime.jobmaster.JobMasterId 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));
}
}
Aggregations