Class DefaultDeclarativeSlotPool

java.lang.Object
org.apache.flink.runtime.jobmaster.slotpool.DefaultDeclarativeSlotPool
All Implemented Interfaces:
DeclarativeSlotPool
Direct Known Subclasses:
BlocklistDeclarativeSlotPool

public class DefaultDeclarativeSlotPool extends Object implements DeclarativeSlotPool
Default DeclarativeSlotPool implementation.

The implementation collects the current resource requirements and declares them at the ResourceManager. Whenever new slots are offered, the slot pool compares the offered slots to the set of available and required resources and only accepts those slots which are required.

Slots which are released won't be returned directly to their owners. Instead, the slot pool implementation will only return them after the idleSlotTimeout has been exceeded by a free slot.

The slot pool will call newSlotsListener whenever newly offered slots are accepted or if an allocated slot should become free after it is being freed.

This class expects 1 of 2 access patterns for changing requirements, which should not be mixed:

1) the legacy approach (used by the DefaultScheduler) tightly couples requirements to reserved slots. When a slot is requested it increases the requirements, when the slot is freed they are decreased again. In the general case what happens is that requirements are increased, a free slot is reserved, (the slot is used for a bit,) the slot is freed, the requirements are reduced. To this end freeReservedSlot(org.apache.flink.runtime.clusterframework.types.AllocationID, java.lang.Throwable, long), releaseSlot(org.apache.flink.runtime.clusterframework.types.AllocationID, java.lang.Exception) and releaseSlots(org.apache.flink.runtime.clusterframework.types.ResourceID, java.lang.Exception) return a ResourceCounter describing which requirement the slot(s) were fulfilling, with the expectation that the scheduler will subsequently decrease the requirements by that amount.

2) The declarative approach (used by the AdaptiveScheduler) in contrast derives requirements exclusively based on what a given job currently requires. It may repeatedly reserve/free slots without any modifications to the requirements.