use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.
the class SharedSlot method allocateLogicalSlot.
/**
* Registers an allocation request for a logical slot.
*
* @return the logical slot
*/
public LogicalSlot allocateLogicalSlot() {
LOG.debug("Allocating logical slot from shared slot ({})", physicalSlotRequestId);
Preconditions.checkState(state == State.ALLOCATED, "The shared slot has already been released.");
final LogicalSlot slot = new SingleLogicalSlot(new SlotRequestId(), physicalSlot, Locality.UNKNOWN, this, slotWillBeOccupiedIndefinitely);
allocatedLogicalSlots.put(slot.getSlotRequestId(), slot);
return slot;
}
use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.
the class SlotSharingExecutionSlotAllocator method getOrAllocateSharedSlot.
private SharedSlot getOrAllocateSharedSlot(ExecutionSlotSharingGroup executionSlotSharingGroup, SharedSlotProfileRetriever sharedSlotProfileRetriever) {
return sharedSlots.computeIfAbsent(executionSlotSharingGroup, group -> {
SlotRequestId physicalSlotRequestId = new SlotRequestId();
ResourceProfile physicalSlotResourceProfile = getPhysicalSlotResourceProfile(group);
SlotProfile slotProfile = sharedSlotProfileRetriever.getSlotProfile(group, physicalSlotResourceProfile);
PhysicalSlotRequest physicalSlotRequest = new PhysicalSlotRequest(physicalSlotRequestId, slotProfile, slotWillBeOccupiedIndefinitely);
CompletableFuture<PhysicalSlot> physicalSlotFuture = slotProvider.allocatePhysicalSlot(physicalSlotRequest).thenApply(PhysicalSlotRequest.Result::getPhysicalSlot);
return new SharedSlot(physicalSlotRequestId, physicalSlotResourceProfile, group, physicalSlotFuture, slotWillBeOccupiedIndefinitely, this::releaseSharedSlot);
});
}
use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.
the class SharedSlotTest method testConstructorFailsIfSlotAlreadyHasAssignedPayload.
@Test(expected = IllegalStateException.class)
public void testConstructorFailsIfSlotAlreadyHasAssignedPayload() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
physicalSlot.tryAssignPayload(new TestingPhysicalSlotPayload());
new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
}
use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.
the class SharedSlotTest method testReleaseAlsoReleasesLogicalSlots.
@Test
public void testReleaseAlsoReleasesLogicalSlots() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
final LogicalSlot logicalSlot = sharedSlot.allocateLogicalSlot();
sharedSlot.release(new Exception("test"));
assertThat(logicalSlot.isAlive(), is(false));
}
use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.
the class SharedSlotTest method testReturnLogicalSlotRejectsUnknownSlot.
@Test(expected = IllegalStateException.class)
public void testReturnLogicalSlotRejectsUnknownSlot() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
final LogicalSlot logicalSlot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
logicalSlot.releaseSlot(new Exception("test"));
sharedSlot.returnLogicalSlot(logicalSlot);
}
Aggregations