Class FineGrainedSlotManager
- java.lang.Object
-
- org.apache.flink.runtime.resourcemanager.slotmanager.FineGrainedSlotManager
-
- All Implemented Interfaces:
AutoCloseable,SlotManager
public class FineGrainedSlotManager extends Object implements SlotManager
Implementation ofSlotManagersupporting fine-grained resource management.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.runtime.resourcemanager.slotmanager.SlotManager
SlotManager.RegistrationResult
-
-
Constructor Summary
Constructors Constructor Description FineGrainedSlotManager(org.apache.flink.util.concurrent.ScheduledExecutor scheduledExecutor, SlotManagerConfiguration slotManagerConfiguration, SlotManagerMetricGroup slotManagerMetricGroup, ResourceTracker resourceTracker, org.apache.flink.runtime.resourcemanager.slotmanager.TaskManagerTracker taskManagerTracker, SlotStatusSyncer slotStatusSyncer, ResourceAllocationStrategy resourceAllocationStrategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearResourceRequirements(org.apache.flink.api.common.JobID jobId)Notifies the slot manager that the resource requirements for the given job should be cleared.voidclose()Closes the slot manager.voidfreeSlot(SlotID slotId, AllocationID allocationId)Free the given slot from the given allocation.Collection<SlotInfo>getAllocatedSlotsOf(InstanceID instanceID)ResourceProfilegetFreeResource()ResourceProfilegetFreeResourceOf(InstanceID instanceID)intgetNumberFreeSlots()intgetNumberFreeSlotsOf(InstanceID instanceId)intgetNumberRegisteredSlots()intgetNumberRegisteredSlotsOf(InstanceID instanceId)ResourceProfilegetRegisteredResource()ResourceProfilegetRegisteredResourceOf(InstanceID instanceID)longgetTaskManagerIdleSince(InstanceID instanceId)voidprocessResourceRequirements(ResourceRequirements resourceRequirements)Notifies the slot manager about the resource requirements of a job.SlotManager.RegistrationResultregisterTaskManager(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 newResourceEventListener, BlockedTaskManagerChecker newBlockedTaskManagerChecker)Starts the slot manager with the given leader id and resource manager actions.voidsuspend()Suspends the component.voidtriggerResourceRequirementsCheck()Trigger 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.
-
-
-
Constructor Detail
-
FineGrainedSlotManager
public FineGrainedSlotManager(org.apache.flink.util.concurrent.ScheduledExecutor scheduledExecutor, SlotManagerConfiguration slotManagerConfiguration, SlotManagerMetricGroup slotManagerMetricGroup, ResourceTracker resourceTracker, org.apache.flink.runtime.resourcemanager.slotmanager.TaskManagerTracker taskManagerTracker, SlotStatusSyncer slotStatusSyncer, ResourceAllocationStrategy resourceAllocationStrategy)
-
-
Method Detail
-
setFailUnfulfillableRequest
public void setFailUnfulfillableRequest(boolean failUnfulfillableRequest)
- Specified by:
setFailUnfulfillableRequestin interfaceSlotManager
-
triggerResourceRequirementsCheck
public void triggerResourceRequirementsCheck()
Description copied from interface:SlotManagerTrigger the resource requirement check. This method will be called when some slot statuses changed.- Specified by:
triggerResourceRequirementsCheckin interfaceSlotManager
-
start
public void start(ResourceManagerId newResourceManagerId, Executor newMainThreadExecutor, ResourceAllocator newResourceAllocator, ResourceEventListener newResourceEventListener, BlockedTaskManagerChecker newBlockedTaskManagerChecker)
Starts the slot manager with the given leader id and resource manager actions.- Specified by:
startin interfaceSlotManager- 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-)allocationsnewBlockedTaskManagerChecker- to query whether a task manager is blockednewResourceEventListener- to use for notify resource not enough
-
suspend
public void suspend()
Suspends the component. This clears the internal state of the slot manager.- Specified by:
suspendin interfaceSlotManager
-
close
public void close() throws ExceptionCloses the slot manager.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception- if the close operation fails
-
clearResourceRequirements
public void clearResourceRequirements(org.apache.flink.api.common.JobID jobId)
Description copied from interface:SlotManagerNotifies 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.- Specified by:
clearResourceRequirementsin interfaceSlotManager- Parameters:
jobId- job for which to clear the requirements
-
processResourceRequirements
public void processResourceRequirements(ResourceRequirements resourceRequirements)
Description copied from interface:SlotManagerNotifies the slot manager about the resource requirements of a job.- Specified by:
processResourceRequirementsin interfaceSlotManager- Parameters:
resourceRequirements- resource requirements of a job
-
registerTaskManager
public SlotManager.RegistrationResult registerTaskManager(TaskExecutorConnection taskExecutorConnection, SlotReport initialSlotReport, ResourceProfile totalResourceProfile, ResourceProfile defaultSlotResourceProfile)
Description copied from interface:SlotManagerRegisters a new task manager at the slot manager. This will make the task managers slots known and, thus, available for allocation.- Specified by:
registerTaskManagerin interfaceSlotManager- 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
public boolean unregisterTaskManager(InstanceID instanceId, Exception cause)
Description copied from interface:SlotManagerUnregisters the task manager identified by the given instance id and its associated slots from the slot manager.- Specified by:
unregisterTaskManagerin interfaceSlotManager- 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
public boolean reportSlotStatus(InstanceID instanceId, SlotReport slotReport)
Reports the current slot allocations for a task manager identified by the given instance id.- Specified by:
reportSlotStatusin interfaceSlotManager- 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
public void freeSlot(SlotID slotId, AllocationID allocationId)
Free the given slot from the given allocation. If the slot is still allocated by the given allocation id, then the slot will be freed.- Specified by:
freeSlotin interfaceSlotManager- Parameters:
slotId- identifying the slot to free, will be ignoredallocationId- with which the slot is presumably allocated
-
getNumberRegisteredSlots
public int getNumberRegisteredSlots()
- Specified by:
getNumberRegisteredSlotsin interfaceSlotManager
-
getNumberRegisteredSlotsOf
public int getNumberRegisteredSlotsOf(InstanceID instanceId)
- Specified by:
getNumberRegisteredSlotsOfin interfaceSlotManager
-
getNumberFreeSlots
public int getNumberFreeSlots()
- Specified by:
getNumberFreeSlotsin interfaceSlotManager
-
getNumberFreeSlotsOf
public int getNumberFreeSlotsOf(InstanceID instanceId)
- Specified by:
getNumberFreeSlotsOfin interfaceSlotManager
-
getRegisteredResource
public ResourceProfile getRegisteredResource()
- Specified by:
getRegisteredResourcein interfaceSlotManager
-
getRegisteredResourceOf
public ResourceProfile getRegisteredResourceOf(InstanceID instanceID)
- Specified by:
getRegisteredResourceOfin interfaceSlotManager
-
getFreeResource
public ResourceProfile getFreeResource()
- Specified by:
getFreeResourcein interfaceSlotManager
-
getFreeResourceOf
public ResourceProfile getFreeResourceOf(InstanceID instanceID)
- Specified by:
getFreeResourceOfin interfaceSlotManager
-
getAllocatedSlotsOf
public Collection<SlotInfo> getAllocatedSlotsOf(InstanceID instanceID)
- Specified by:
getAllocatedSlotsOfin interfaceSlotManager
-
getTaskManagerIdleSince
@VisibleForTesting public long getTaskManagerIdleSince(InstanceID instanceId)
-
-