Interface SlotManager
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
FineGrainedSlotManager
The slot manager is responsible for maintaining a view on all registered task manager slots,
their allocation and all pending slot requests. Whenever a new slot is registered or an allocated
slot is freed, then it tries to fulfill another pending slot request. Whenever there are not
enough slots available the slot manager will notify the resource manager about it via
ResourceAllocator.declareResourceNeeded(java.util.Collection<org.apache.flink.runtime.resourcemanager.slotmanager.ResourceDeclaration>).
In order to free resources and avoid resource leaks, idling task managers (task managers whose slots are currently not used) and pending slot requests time out triggering their release and failure, respectively.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe result of task manager registration. -
Method Summary
Modifier and TypeMethodDescriptionvoidclearResourceRequirements(org.apache.flink.api.common.JobID jobId) Notifies the slot manager that the resource requirements for the given job should be cleared.voidfreeSlot(SlotID slotId, AllocationID allocationId) Free the given slot from the given allocation.getAllocatedSlotsOf(InstanceID instanceID) getFreeResourceOf(InstanceID instanceID) intintgetNumberFreeSlotsOf(InstanceID instanceId) intintgetNumberRegisteredSlotsOf(InstanceID instanceId) getRegisteredResourceOf(InstanceID instanceID) voidprocessResourceRequirements(ResourceRequirements resourceRequirements) Notifies the slot manager about the resource requirements of a job.registerTaskManager(TaskExecutorConnection taskExecutorConnection, SlotReport initialSlotReport, ResourceProfile totalResourceProfile, ResourceProfile defaultSlotResourceProfile) Registers a new task manager at the slot manager.booleanreportSlotStatus(InstanceID instanceId, SlotReport slotReport) Reports the current slot allocations for a task manager identified by the given instance id.voidsetFailUnfulfillableRequest(boolean failUnfulfillableRequest) voidstart(ResourceManagerId newResourceManagerId, Executor newMainThreadExecutor, ResourceAllocator newResourceAllocator, ResourceEventListener resourceEventListener, BlockedTaskManagerChecker newBlockedTaskManagerChecker) Starts the slot manager with the given leader id and resource manager actions.voidsuspend()Suspends the component.voidTrigger the resource requirement check.booleanunregisterTaskManager(InstanceID instanceId, Exception cause) Unregisters the task manager identified by the given instance id and its associated slots from the slot manager.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
getNumberRegisteredSlots
int getNumberRegisteredSlots() -
getNumberRegisteredSlotsOf
-
getNumberFreeSlots
int getNumberFreeSlots() -
getNumberFreeSlotsOf
-
getRegisteredResource
ResourceProfile getRegisteredResource() -
getRegisteredResourceOf
-
getFreeResource
ResourceProfile getFreeResource() -
getFreeResourceOf
-
getAllocatedSlotsOf
-
start
void start(ResourceManagerId newResourceManagerId, Executor newMainThreadExecutor, ResourceAllocator newResourceAllocator, ResourceEventListener resourceEventListener, BlockedTaskManagerChecker newBlockedTaskManagerChecker) Starts the slot manager with the given leader id and resource manager actions.- Parameters:
newResourceManagerId- to use for communication with the task managersnewMainThreadExecutor- to use to run code in the ResourceManager's main threadnewResourceAllocator- to use for resource (de-)allocationsresourceEventListener- to use for notify resource not enoughnewBlockedTaskManagerChecker- to query whether a task manager is blocked
-
suspend
void suspend()Suspends the component. This clears the internal state of the slot manager. -
clearResourceRequirements
void clearResourceRequirements(org.apache.flink.api.common.JobID jobId) Notifies the slot manager that the resource requirements for the given job should be cleared. The slot manager may assume that no further updates to the resource requirements will occur.- Parameters:
jobId- job for which to clear the requirements
-
processResourceRequirements
Notifies the slot manager about the resource requirements of a job.- Parameters:
resourceRequirements- resource requirements of a job
-
registerTaskManager
SlotManager.RegistrationResult registerTaskManager(TaskExecutorConnection taskExecutorConnection, SlotReport initialSlotReport, ResourceProfile totalResourceProfile, ResourceProfile defaultSlotResourceProfile) Registers a new task manager at the slot manager. This will make the task managers slots known and, thus, available for allocation.- Parameters:
taskExecutorConnection- for the new task managerinitialSlotReport- for the new task managertotalResourceProfile- for the new task managerdefaultSlotResourceProfile- for the new task manager- Returns:
- The result of task manager registration
-
unregisterTaskManager
Unregisters the task manager identified by the given instance id and its associated slots from the slot manager.- Parameters:
instanceId- identifying the task manager to unregistercause- for unregistering the TaskManager- Returns:
- True if there existed a registered task manager with the given instance id
-
reportSlotStatus
Reports the current slot allocations for a task manager identified by the given instance id.- Parameters:
instanceId- identifying the task manager for which to report the slot statusslotReport- containing the status for all of its slots- Returns:
- true if the slot status has been updated successfully, otherwise false
-
freeSlot
Free the given slot from the given allocation. If the slot is still allocated by the given allocation id, then the slot will be marked as free and will be subject to new slot requests.- Parameters:
slotId- identifying the slot to freeallocationId- with which the slot is presumably allocated
-
setFailUnfulfillableRequest
void setFailUnfulfillableRequest(boolean failUnfulfillableRequest) -
triggerResourceRequirementsCheck
void triggerResourceRequirementsCheck()Trigger the resource requirement check. This method will be called when some slot statuses changed.
-