MAPREDUCE-3238. Small cleanup in SchedulerApp. (Todd Lipcon via mahadev)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1206921 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
64b5a70a53
commit
7f0f8cb7b0
|
@ -114,6 +114,8 @@ Release 0.23.1 - Unreleased
|
||||||
MAPREDUCE-3371. Review and improve the yarn-api javadocs. (Ravi Prakash
|
MAPREDUCE-3371. Review and improve the yarn-api javadocs. (Ravi Prakash
|
||||||
via mahadev)
|
via mahadev)
|
||||||
|
|
||||||
|
MAPREDUCE-3238. Small cleanup in SchedulerApp. (Todd Lipcon via mahadev)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -53,6 +53,14 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerReservedEvent;
|
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerReservedEvent;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
|
import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
|
||||||
|
|
||||||
|
import com.google.common.collect.HashMultiset;
|
||||||
|
import com.google.common.collect.Multiset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an Application from the viewpoint of the scheduler.
|
||||||
|
* Each running Application in the RM corresponds to one instance
|
||||||
|
* of this class.
|
||||||
|
*/
|
||||||
public class SchedulerApp {
|
public class SchedulerApp {
|
||||||
|
|
||||||
private static final Log LOG = LogFactory.getLog(SchedulerApp.class);
|
private static final Log LOG = LogFactory.getLog(SchedulerApp.class);
|
||||||
|
@ -76,11 +84,16 @@ public class SchedulerApp {
|
||||||
final Map<Priority, Map<NodeId, RMContainer>> reservedContainers =
|
final Map<Priority, Map<NodeId, RMContainer>> reservedContainers =
|
||||||
new HashMap<Priority, Map<NodeId, RMContainer>>();
|
new HashMap<Priority, Map<NodeId, RMContainer>>();
|
||||||
|
|
||||||
Map<Priority, Integer> schedulingOpportunities =
|
/**
|
||||||
new HashMap<Priority, Integer>();
|
* Count how many times the application has been given an opportunity
|
||||||
|
* to schedule a task at each priority. Each time the scheduler
|
||||||
|
* asks the application for a task at this priority, it is incremented,
|
||||||
|
* and each time the application successfully schedules a task, it
|
||||||
|
* is reset to 0.
|
||||||
|
*/
|
||||||
|
Multiset<Priority> schedulingOpportunities = HashMultiset.create();
|
||||||
|
|
||||||
Map<Priority, Integer> reReservations =
|
Multiset<Priority> reReservations = HashMultiset.create();
|
||||||
new HashMap<Priority, Integer>();
|
|
||||||
|
|
||||||
Resource currentReservation = recordFactory
|
Resource currentReservation = recordFactory
|
||||||
.newRecordInstance(Resource.class);
|
.newRecordInstance(Resource.class);
|
||||||
|
@ -282,49 +295,33 @@ public class SchedulerApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void resetSchedulingOpportunities(Priority priority) {
|
synchronized public void resetSchedulingOpportunities(Priority priority) {
|
||||||
this.schedulingOpportunities.put(priority, Integer.valueOf(0));
|
this.schedulingOpportunities.setCount(priority, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void addSchedulingOpportunity(Priority priority) {
|
synchronized public void addSchedulingOpportunity(Priority priority) {
|
||||||
Integer schedulingOpportunities =
|
this.schedulingOpportunities.setCount(priority,
|
||||||
this.schedulingOpportunities.get(priority);
|
schedulingOpportunities.count(priority) + 1);
|
||||||
if (schedulingOpportunities == null) {
|
|
||||||
schedulingOpportunities = 0;
|
|
||||||
}
|
|
||||||
++schedulingOpportunities;
|
|
||||||
this.schedulingOpportunities.put(priority, schedulingOpportunities);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the number of times the application has been given an opportunity
|
||||||
|
* to schedule a task at the given priority since the last time it
|
||||||
|
* successfully did so.
|
||||||
|
*/
|
||||||
synchronized public int getSchedulingOpportunities(Priority priority) {
|
synchronized public int getSchedulingOpportunities(Priority priority) {
|
||||||
Integer schedulingOpportunities =
|
return this.schedulingOpportunities.count(priority);
|
||||||
this.schedulingOpportunities.get(priority);
|
|
||||||
if (schedulingOpportunities == null) {
|
|
||||||
schedulingOpportunities = 0;
|
|
||||||
this.schedulingOpportunities.put(priority, schedulingOpportunities);
|
|
||||||
}
|
|
||||||
return schedulingOpportunities;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void resetReReservations(Priority priority) {
|
synchronized void resetReReservations(Priority priority) {
|
||||||
this.reReservations.put(priority, Integer.valueOf(0));
|
this.reReservations.setCount(priority, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void addReReservation(Priority priority) {
|
synchronized void addReReservation(Priority priority) {
|
||||||
Integer reReservations = this.reReservations.get(priority);
|
this.reReservations.add(priority);
|
||||||
if (reReservations == null) {
|
|
||||||
reReservations = 0;
|
|
||||||
}
|
|
||||||
++reReservations;
|
|
||||||
this.reReservations.put(priority, reReservations);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public int getReReservations(Priority priority) {
|
synchronized public int getReReservations(Priority priority) {
|
||||||
Integer reReservations = this.reReservations.get(priority);
|
return this.reReservations.count(priority);
|
||||||
if (reReservations == null) {
|
|
||||||
reReservations = 0;
|
|
||||||
this.reReservations.put(priority, reReservations);
|
|
||||||
}
|
|
||||||
return reReservations;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized int getNumReservedContainers(Priority priority) {
|
public synchronized int getNumReservedContainers(Priority priority) {
|
||||||
|
|
Loading…
Reference in New Issue