Class DefaultResourceAllocationStrategy
- java.lang.Object
-
- org.apache.flink.runtime.resourcemanager.slotmanager.DefaultResourceAllocationStrategy
-
- All Implemented Interfaces:
ResourceAllocationStrategy
public class DefaultResourceAllocationStrategy extends Object implements ResourceAllocationStrategy
The default implementation ofResourceAllocationStrategy.For each requirement, this strategy tries to fulfill it with any registered or pending resources (registered is prioritized). If a requirement cannot be fulfilled by any registered or pending resources, it allocates a new pending resource, with the pre-defined total and default slot resource profiles, thus all new pending resources should have the same profiles. A requirement is considered unfulfillable if it is not fulfilled by any registered or pending resources and cannot fit into the pre-defined total resource profile.
Note: This strategy tries to find a feasible allocation result, rather than an optimal one (in term of resource utilization). It also does not guarantee always finding a feasible solution when exist.
Note: The current implementation of this strategy is non-optimal, in terms of computation efficiency. In the worst case, for each distinctly profiled requirement it checks all registered and pending resources. Further optimization requires complex data structures for ordering multi-dimensional resource profiles. The complexity is not necessary.
-
-
Constructor Summary
Constructors Constructor Description DefaultResourceAllocationStrategy(ResourceProfile totalResourceProfile, int numSlotsPerWorker, boolean evenlySpreadOutSlots, org.apache.flink.api.common.time.Time taskManagerTimeout, int redundantTaskManagerNum)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourceAllocationResulttryFulfillRequirements(Map<org.apache.flink.api.common.JobID,Collection<ResourceRequirement>> missingResources, org.apache.flink.runtime.resourcemanager.slotmanager.TaskManagerResourceInfoProvider taskManagerResourceInfoProvider, BlockedTaskManagerChecker blockedTaskManagerChecker)Try to make an allocation decision to fulfill the resource requirements.ResourceReconcileResulttryReconcileClusterResources(org.apache.flink.runtime.resourcemanager.slotmanager.TaskManagerResourceInfoProvider taskManagerResourceInfoProvider)Try to make a decision to reconcile the cluster resources.
-
-
-
Constructor Detail
-
DefaultResourceAllocationStrategy
public DefaultResourceAllocationStrategy(ResourceProfile totalResourceProfile, int numSlotsPerWorker, boolean evenlySpreadOutSlots, org.apache.flink.api.common.time.Time taskManagerTimeout, int redundantTaskManagerNum)
-
-
Method Detail
-
tryFulfillRequirements
public ResourceAllocationResult tryFulfillRequirements(Map<org.apache.flink.api.common.JobID,Collection<ResourceRequirement>> missingResources, org.apache.flink.runtime.resourcemanager.slotmanager.TaskManagerResourceInfoProvider taskManagerResourceInfoProvider, BlockedTaskManagerChecker blockedTaskManagerChecker)
Description copied from interface:ResourceAllocationStrategyTry to make an allocation decision to fulfill the resource requirements. The strategy generates a series of actions to take, based on the current status.Notice: For performance considerations, modifications might be performed directly on the input arguments. If the arguments are reused elsewhere, please make a deep copy in advance.
- Specified by:
tryFulfillRequirementsin interfaceResourceAllocationStrategy- Parameters:
missingResources- resource requirements that are not yet fulfilled, indexed by jobIdtaskManagerResourceInfoProvider- provide the registered/pending resources of the current clusterblockedTaskManagerChecker- blocked task manager checker- Returns:
- a
ResourceAllocationResultbased on the current status, which contains whether the requirements can be fulfilled and the actions to take
-
tryReconcileClusterResources
public ResourceReconcileResult tryReconcileClusterResources(org.apache.flink.runtime.resourcemanager.slotmanager.TaskManagerResourceInfoProvider taskManagerResourceInfoProvider)
Description copied from interface:ResourceAllocationStrategyTry to make a decision to reconcile the cluster resources. This is more light weighted thanResourceAllocationStrategy.tryFulfillRequirements(java.util.Map<org.apache.flink.api.common.JobID, java.util.Collection<org.apache.flink.runtime.slots.ResourceRequirement>>, org.apache.flink.runtime.resourcemanager.slotmanager.TaskManagerResourceInfoProvider, org.apache.flink.runtime.blocklist.BlockedTaskManagerChecker), only consider empty registered / pending workers and assume all requirements are fulfilled by registered / pending workers.- Specified by:
tryReconcileClusterResourcesin interfaceResourceAllocationStrategy- Parameters:
taskManagerResourceInfoProvider- provide the registered/pending resources of the current cluster- Returns:
- a
ResourceReconcileResultbased on the current status, which contains the actions to take
-
-