public interface DeclarativeSlotPool
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.
Modifier and Type | Interface and Description |
---|---|
static interface |
DeclarativeSlotPool.NewSlotsListener
Listener interface for newly available slots.
|
static class |
DeclarativeSlotPool.NoOpNewSlotsListener
No-op
DeclarativeSlotPool.NewSlotsListener implementation. |
Modifier and Type | Method and Description |
---|---|
boolean |
containsFreeSlot(AllocationID allocationId)
Checks whether the slot pool contains a slot with the given
AllocationID and if it is
free. |
boolean |
containsSlots(ResourceID owner)
Returns whether the slot pool has a slot registered which is owned by the given TaskExecutor.
|
void |
decreaseResourceRequirementsBy(ResourceCounter decrement)
Decreases the resource requirements by decrement.
|
ResourceCounter |
freeReservedSlot(AllocationID allocationId,
Throwable cause,
long currentTime)
Frees the reserved slot identified by the given allocationId.
|
Collection<? extends SlotInfo> |
getAllSlotsInformation()
Returns the slot information for all slots (free and allocated slots).
|
Collection<SlotInfoWithUtilization> |
getFreeSlotsInformation()
Returns the slot information for all free slots (slots which can be allocated from the slot
pool).
|
Collection<ResourceRequirement> |
getResourceRequirements()
Returns the current resource requirements.
|
void |
increaseResourceRequirementsBy(ResourceCounter increment)
Increases the resource requirements by increment.
|
Collection<SlotOffer> |
offerSlots(Collection<? extends SlotOffer> offers,
TaskManagerLocation taskManagerLocation,
TaskManagerGateway taskManagerGateway,
long currentTime)
Offers slots to this slot pool.
|
void |
registerNewSlotsListener(DeclarativeSlotPool.NewSlotsListener listener)
Registers a listener which is called whenever new slots become available.
|
Collection<SlotOffer> |
registerSlots(Collection<? extends SlotOffer> slots,
TaskManagerLocation taskManagerLocation,
TaskManagerGateway taskManagerGateway,
long currentTime)
Registers the given set of slots at the slot pool.
|
void |
releaseIdleSlots(long currentTimeMillis)
Releases slots which have exceeded the idle slot timeout and are no longer needed to fulfill
the resource requirements.
|
ResourceCounter |
releaseSlot(AllocationID allocationId,
Exception cause)
Releases the slot specified by allocationId if one exists.
|
ResourceCounter |
releaseSlots(ResourceID owner,
Exception cause)
Releases all slots belonging to the owning TaskExecutor if it has been registered.
|
PhysicalSlot |
reserveFreeSlot(AllocationID allocationId,
ResourceProfile requiredSlotProfile)
Reserves the free slot identified by the given allocationId and maps it to the given
requiredSlotProfile.
|
void |
setResourceRequirements(ResourceCounter resourceRequirements)
Sets the resource requirements to the given resourceRequirements.
|
void increaseResourceRequirementsBy(ResourceCounter increment)
increment
- increment by which to increase the resource requirementsvoid decreaseResourceRequirementsBy(ResourceCounter decrement)
decrement
- decrement by which to decrease the resource requirementsvoid setResourceRequirements(ResourceCounter resourceRequirements)
resourceRequirements
- new resource requirementsCollection<ResourceRequirement> getResourceRequirements()
Collection<SlotOffer> offerSlots(Collection<? extends SlotOffer> offers, TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, long currentTime)
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 offeredCollection<SlotOffer> registerSlots(Collection<? extends SlotOffer> slots, TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, long currentTime)
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 the 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)
only accepts those slots that are
currently required.
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 offeredCollection<SlotInfoWithUtilization> getFreeSlotsInformation()
Collection<? extends SlotInfo> getAllSlotsInformation()
boolean containsFreeSlot(AllocationID allocationId)
AllocationID
and if it is
free.allocationId
- allocationId specifies the slot to check fortrue
if the slot pool contains a free slot registered under the given
allocation id; otherwise false
PhysicalSlot reserveFreeSlot(AllocationID allocationId, ResourceProfile requiredSlotProfile)
allocationId
- allocationId identifies the free slot to allocaterequiredSlotProfile
- requiredSlotProfile specifying the resource requirementIllegalStateException
- if no free slot with the given allocationId exists or if the
specified slot cannot fulfill the requiredSlotProfileResourceCounter freeReservedSlot(AllocationID allocationId, @Nullable Throwable cause, long currentTime)
Whether the freed slot is returned to the owning TaskExecutor is implementation dependent.
allocationId
- allocationId identifying the slot to releasecause
- cause for releasing the slot; can be null
currentTime
- currentTime when the slot was releasedResourceCounter releaseSlots(ResourceID owner, Exception cause)
owner
- owner identifying the owning TaskExecutorcause
- cause for failing the slotsResourceCounter releaseSlot(AllocationID allocationId, Exception cause)
allocationId
- allocationId identifying the slot to failcause
- cause for failing the slotboolean containsSlots(ResourceID owner)
owner
- owner identifying the TaskExecutor for which to check whether the slot pool has
some slots registeredvoid releaseIdleSlots(long currentTimeMillis)
currentTimeMillis
- current timevoid registerNewSlotsListener(DeclarativeSlotPool.NewSlotsListener listener)
listener
- which is called whenever new slots become availableCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.