Interface DeclarativeSlotPool
- All Known Implementing Classes:
BlocklistDeclarativeSlotPool,DefaultDeclarativeSlotPool
In order to acquire new resources, users need to increase the required resources. Once they no longer need the resources, users need to decrease the required resources so that superfluous resources can be returned.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceListener interface for newly available slots.static enumNo-opDeclarativeSlotPool.NewSlotsListenerimplementation. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsFreeSlot(AllocationID allocationId) Checks whether the slot pool contains a slot with the givenAllocationIDand if it is free.booleancontainsSlots(ResourceID owner) Returns whether the slot pool has a slot registered which is owned by the given TaskExecutor.voiddecreaseResourceRequirementsBy(ResourceCounter decrement) Decreases the resource requirements by decrement.freeReservedSlot(AllocationID allocationId, Throwable cause, long currentTime) Frees the reserved slot identified by the given allocationId.Collection<? extends SlotInfo>Returns the slot information for all slots (free and allocated slots).Returns the free slot tracker.Returns the current resource requirements.voidincreaseResourceRequirementsBy(ResourceCounter increment) Increases the resource requirements by increment.offerSlots(Collection<? extends SlotOffer> offers, TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, long currentTime) Offers slots to this slot pool.voidRegisters a listener which is called whenever new slots become available.registerSlots(Collection<? extends SlotOffer> slots, TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, long currentTime) Registers the given set of slots at the slot pool.voidreleaseIdleSlots(long currentTimeMillis) Releases slots which have exceeded the idle slot timeout and are no longer needed to fulfill the resource requirements.releaseSlot(AllocationID allocationId, Exception cause) Releases the slot specified by allocationId if one exists.releaseSlots(ResourceID owner, Exception cause) Releases all slots belonging to the owning TaskExecutor if it has been registered.reserveFreeSlot(AllocationID allocationId, ResourceProfile requiredSlotProfile) Reserves the free slot identified by the given allocationId and maps it to the given requiredSlotProfile.voidsetResourceRequirements(ResourceCounter resourceRequirements) Sets the resource requirements to the given resourceRequirements.
-
Method Details
-
increaseResourceRequirementsBy
Increases the resource requirements by increment.- Parameters:
increment- increment by which to increase the resource requirements
-
decreaseResourceRequirementsBy
Decreases the resource requirements by decrement.- Parameters:
decrement- decrement by which to decrease the resource requirements
-
setResourceRequirements
Sets the resource requirements to the given resourceRequirements.- Parameters:
resourceRequirements- new resource requirements
-
getResourceRequirements
Collection<ResourceRequirement> getResourceRequirements()Returns the current resource requirements.- Returns:
- current resource requirements
-
offerSlots
Collection<SlotOffer> offerSlots(Collection<? extends SlotOffer> offers, TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, long currentTime) Offers slots to this slot pool. The slot pool is free to accept as many slots as it needs.- Parameters:
offers- offers containing the list of slots offered to this slot pooltaskManagerLocation- taskManagerLocation is the location of the offering TaskExecutortaskManagerGateway- taskManagerGateway is the gateway to talk to the offering TaskExecutorcurrentTime- currentTime is the time the slots are being offered- Returns:
- collection of accepted slots; the other slot offers are implicitly rejected
-
registerSlots
Collection<SlotOffer> registerSlots(Collection<? extends SlotOffer> slots, TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, long currentTime) Registers the given set of slots at the slot pool. The slot pool will try to accept all slots unless the slot is unavailable (for example, the TaskManger is blocked).The difference from
offerSlots(java.util.Collection<? extends org.apache.flink.runtime.taskexecutor.slot.SlotOffer>, org.apache.flink.runtime.taskmanager.TaskManagerLocation, org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway, long)is that this method allows accepting slots which exceed the currently required, but theofferSlots(java.util.Collection<? extends org.apache.flink.runtime.taskexecutor.slot.SlotOffer>, org.apache.flink.runtime.taskmanager.TaskManagerLocation, org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway, long)only accepts those slots that are currently required.- Parameters:
slots- slots to registertaskManagerLocation- taskManagerLocation is the location of the offering TaskExecutortaskManagerGateway- taskManagerGateway is the gateway to talk to the offering TaskExecutorcurrentTime- currentTime is the time the slots are being offered- Returns:
- the successfully registered slots; the other slot offers are implicitly rejected
-
getFreeSlotTracker
FreeSlotTracker getFreeSlotTracker()Returns the free slot tracker.- Returns:
- free slot tracker
-
getAllSlotsInformation
Collection<? extends SlotInfo> getAllSlotsInformation()Returns the slot information for all slots (free and allocated slots).- Returns:
- collection of slot information
-
containsFreeSlot
Checks whether the slot pool contains a slot with the givenAllocationIDand if it is free.- Parameters:
allocationId- allocationId specifies the slot to check for- Returns:
trueif the slot pool contains a free slot registered under the given allocation id; otherwisefalse
-
reserveFreeSlot
Reserves the free slot identified by the given allocationId and maps it to the given requiredSlotProfile.- Parameters:
allocationId- allocationId identifies the free slot to allocaterequiredSlotProfile- requiredSlotProfile specifying the resource requirement- Returns:
- a PhysicalSlot representing the allocated slot
- Throws:
IllegalStateException- if no free slot with the given allocationId exists or if the specified slot cannot fulfill the requiredSlotProfile
-
freeReservedSlot
ResourceCounter freeReservedSlot(AllocationID allocationId, @Nullable Throwable cause, long currentTime) Frees the reserved slot identified by the given allocationId. If no slot with allocationId exists, then the call is ignored.Whether the freed slot is returned to the owning TaskExecutor is implementation dependent.
- Parameters:
allocationId- allocationId identifying the slot to releasecause- cause for releasing the slot; can benullcurrentTime- currentTime when the slot was released- Returns:
- the resource requirements that the slot was fulfilling
-
releaseSlots
Releases all slots belonging to the owning TaskExecutor if it has been registered.- Parameters:
owner- owner identifying the owning TaskExecutorcause- cause for failing the slots- Returns:
- the resource requirements that all slots were fulfilling; empty if all slots were currently free
-
releaseSlot
Releases the slot specified by allocationId if one exists.- Parameters:
allocationId- allocationId identifying the slot to failcause- cause for failing the slot- Returns:
- the resource requirements that the slot was fulfilling; empty if the slot was currently free
-
containsSlots
Returns whether the slot pool has a slot registered which is owned by the given TaskExecutor.- Parameters:
owner- owner identifying the TaskExecutor for which to check whether the slot pool has some slots registered- Returns:
- true if the given TaskExecutor has a slot registered at the slot pool
-
releaseIdleSlots
void releaseIdleSlots(long currentTimeMillis) Releases slots which have exceeded the idle slot timeout and are no longer needed to fulfill the resource requirements.- Parameters:
currentTimeMillis- current time
-
registerNewSlotsListener
Registers a listener which is called whenever new slots become available.- Parameters:
listener- which is called whenever new slots become available
-