public class DefaultResourceAllocationStrategy extends Object implements ResourceAllocationStrategy
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 and Description|
|Modifier and Type||Method and Description|
Try to make an allocation decision to fulfill the resource requirements.
public DefaultResourceAllocationStrategy(ResourceProfile totalResourceProfile, int numSlotsPerWorker)
public ResourceAllocationResult tryFulfillRequirements(Map<JobID,Collection<ResourceRequirement>> missingResources, org.apache.flink.runtime.resourcemanager.slotmanager.TaskManagerResourceInfoProvider taskManagerResourceInfoProvider)
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.
missingResources- resource requirements that are not yet fulfilled, indexed by jobId
taskManagerResourceInfoProvider- provide the registered/pending resources of the current cluster
ResourceAllocationResultbased on the current status, which contains whether the requirements can be fulfilled and the actions to take
Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.