Interface Schedulable
- All Known Implementing Classes:
FSAppAttempt,FSLeafQueue,FSParentQueue,FSQueue
@Private
@Unstable
public interface Schedulable
A Schedulable represents an entity that can be scheduled such as an
application or a queue. It provides a common interface so that algorithms
such as fair sharing can be applied both within a queue and across queues.
A Schedulable is responsible for three roles:
1) Assign resources through
assignContainer(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSSchedulerNode).
2) It provides information about the app/queue to the scheduler, including:
- Demand (maximum number of tasks required)
- Minimum share (for queues)
- Job/queue weight (for fair sharing)
- Start time and priority (for FIFO)
3) It can be assigned a fair share, for use with fair scheduling.
Schedulable also contains two methods for performing scheduling computations:
- updateDemand() is called periodically to compute the demand of the various
jobs and queues, which may be expensive (e.g. jobs must iterate through all
their tasks to count failed tasks, tasks that can be speculated, etc).-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hadoop.yarn.api.records.ResourceAssign a container on this node if possible, and return the amount of resources assigned.org.apache.hadoop.yarn.api.records.ResourceMaximum number of resources required by this Schedulable.org.apache.hadoop.yarn.api.records.ResourceGet the fair share assigned to this Schedulable.org.apache.hadoop.yarn.api.records.ResourceMaximum Resource share assigned to the schedulable.org.apache.hadoop.yarn.api.records.ResourceMinimum Resource share assigned to the schedulable.getName()Name of job/queue, used for debugging as well as for breaking ties in scheduling order deterministically.org.apache.hadoop.yarn.api.records.PriorityJob priority for jobs in FIFO queues; meaningless for QueueSchedulables.org.apache.hadoop.yarn.api.records.ResourceGet the aggregate amount of resources consumed by the schedulable.longStart time for jobs in FIFO queues; meaningless for QueueSchedulables.floatJob/queue weight in fair sharing.booleanCheck whether the schedulable is preemptable.voidsetFairShare(org.apache.hadoop.yarn.api.records.Resource fairShare) Assign a fair share to this Schedulable.voidRefresh the Schedulable's demand and those of its children if any.
-
Method Details
-
getName
String getName()Name of job/queue, used for debugging as well as for breaking ties in scheduling order deterministically.- Returns:
- Name of job/queue.
-
getDemand
org.apache.hadoop.yarn.api.records.Resource getDemand()Maximum number of resources required by this Schedulable. This is defined as number of currently utilized resources + number of unlaunched resources (that are either not yet launched or need to be speculated).- Returns:
- resources required by this Schedulable.
-
getResourceUsage
org.apache.hadoop.yarn.api.records.Resource getResourceUsage()Get the aggregate amount of resources consumed by the schedulable.- Returns:
- aggregate amount of resources.
-
getWeight
float getWeight()Job/queue weight in fair sharing. Weights are only meaningful when compared. A weight of 2.0f has twice the weight of a weight of 1.0f, which has twice the weight of a weight of 0.5f. A weight of 1.0f is considered unweighted or a neutral weight. A weight of 0 is no weight.- Returns:
- the weight
-
getStartTime
long getStartTime()Start time for jobs in FIFO queues; meaningless for QueueSchedulables.- Returns:
- Start time for jobs.
-
getPriority
org.apache.hadoop.yarn.api.records.Priority getPriority()Job priority for jobs in FIFO queues; meaningless for QueueSchedulables.- Returns:
- Job priority.
-
updateDemand
void updateDemand()Refresh the Schedulable's demand and those of its children if any. -
assignContainer
Assign a container on this node if possible, and return the amount of resources assigned.- Parameters:
node- FSSchedulerNode.- Returns:
- the amount of resources assigned.
-
isPreemptable
boolean isPreemptable()Check whether the schedulable is preemptable.- Returns:
trueif the schedulable is preemptable;falseotherwise
-