YARN-589. Expose a REST API for monitoring the fair scheduler (Sandy Ryza).
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1512111 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7705d57a78
commit
5b001e1a8f
|
@ -38,6 +38,8 @@ Release 2.1.1-beta - UNRELEASED
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
|
|
||||||
|
YARN-589. Expose a REST API for monitoring the fair scheduler (Sandy Ryza).
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -52,6 +52,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppAttemptInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppAttemptInfo;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppAttemptsInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppAttemptsInfo;
|
||||||
|
@ -60,6 +61,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppsInfo;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.CapacitySchedulerInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.CapacitySchedulerInfo;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterInfo;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterMetricsInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterMetricsInfo;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerInfo;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FifoSchedulerInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FifoSchedulerInfo;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodesInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodesInfo;
|
||||||
|
@ -145,6 +147,9 @@ public class RMWebServices {
|
||||||
CapacityScheduler cs = (CapacityScheduler) rs;
|
CapacityScheduler cs = (CapacityScheduler) rs;
|
||||||
CSQueue root = cs.getRootQueue();
|
CSQueue root = cs.getRootQueue();
|
||||||
sinfo = new CapacitySchedulerInfo(root);
|
sinfo = new CapacitySchedulerInfo(root);
|
||||||
|
} else if (rs instanceof FairScheduler) {
|
||||||
|
FairScheduler fs = (FairScheduler) rs;
|
||||||
|
sinfo = new FairSchedulerInfo(fs);
|
||||||
} else if (rs instanceof FifoScheduler) {
|
} else if (rs instanceof FifoScheduler) {
|
||||||
sinfo = new FifoSchedulerInfo(this.rm);
|
sinfo = new FifoSchedulerInfo(this.rm);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -18,14 +18,31 @@
|
||||||
|
|
||||||
package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
|
package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
|
||||||
|
|
||||||
public class FairSchedulerInfo {
|
@XmlRootElement(name = "fairScheduler")
|
||||||
|
@XmlType(name = "fairScheduler")
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class FairSchedulerInfo extends SchedulerInfo {
|
||||||
|
private FairSchedulerQueueInfo rootQueue;
|
||||||
|
|
||||||
|
@XmlTransient
|
||||||
private FairScheduler scheduler;
|
private FairScheduler scheduler;
|
||||||
|
|
||||||
|
public FairSchedulerInfo() {
|
||||||
|
} // JAXB needs this
|
||||||
|
|
||||||
public FairSchedulerInfo(FairScheduler fs) {
|
public FairSchedulerInfo(FairScheduler fs) {
|
||||||
scheduler = fs;
|
scheduler = fs;
|
||||||
|
rootQueue = new FairSchedulerQueueInfo(scheduler.getQueueManager().
|
||||||
|
getRootQueue(), scheduler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAppFairShare(ApplicationAttemptId appAttemptId) {
|
public int getAppFairShare(ApplicationAttemptId appAttemptId) {
|
||||||
|
@ -34,7 +51,6 @@ public class FairSchedulerInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FairSchedulerQueueInfo getRootQueueInfo() {
|
public FairSchedulerQueueInfo getRootQueueInfo() {
|
||||||
return new FairSchedulerQueueInfo(scheduler.getQueueManager().
|
return rootQueue;
|
||||||
getRootQueue(), scheduler);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,23 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.AppSchedulable;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.AppSchedulable;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSLeafQueue;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSLeafQueue;
|
||||||
|
|
||||||
|
@XmlRootElement
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class FairSchedulerLeafQueueInfo extends FairSchedulerQueueInfo {
|
public class FairSchedulerLeafQueueInfo extends FairSchedulerQueueInfo {
|
||||||
private int numPendingApps;
|
private int numPendingApps;
|
||||||
private int numActiveApps;
|
private int numActiveApps;
|
||||||
|
|
||||||
|
public FairSchedulerLeafQueueInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
public FairSchedulerLeafQueueInfo(FSLeafQueue queue, FairScheduler scheduler) {
|
public FairSchedulerLeafQueueInfo(FSLeafQueue queue, FairScheduler scheduler) {
|
||||||
super(queue, scheduler);
|
super(queue, scheduler);
|
||||||
Collection<AppSchedulable> apps = queue.getAppSchedulables();
|
Collection<AppSchedulable> apps = queue.getAppSchedulables();
|
||||||
|
|
|
@ -22,6 +22,12 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||||
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
|
||||||
import org.apache.hadoop.yarn.api.records.Resource;
|
import org.apache.hadoop.yarn.api.records.Resource;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSLeafQueue;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSLeafQueue;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSQueue;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSQueue;
|
||||||
|
@ -29,39 +35,53 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairSchedule
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.QueueManager;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.QueueManager;
|
||||||
import org.apache.hadoop.yarn.util.resource.Resources;
|
import org.apache.hadoop.yarn.util.resource.Resources;
|
||||||
|
|
||||||
|
@XmlRootElement
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlSeeAlso({FairSchedulerLeafQueueInfo.class})
|
||||||
public class FairSchedulerQueueInfo {
|
public class FairSchedulerQueueInfo {
|
||||||
private int maxApps;
|
private int maxApps;
|
||||||
|
|
||||||
|
@XmlTransient
|
||||||
private float fractionMemUsed;
|
private float fractionMemUsed;
|
||||||
|
@XmlTransient
|
||||||
private float fractionMemFairShare;
|
private float fractionMemFairShare;
|
||||||
|
@XmlTransient
|
||||||
private float fractionMemMinShare;
|
private float fractionMemMinShare;
|
||||||
|
@XmlTransient
|
||||||
private float fractionMemMaxShare;
|
private float fractionMemMaxShare;
|
||||||
|
|
||||||
private Resource minResources;
|
private ResourceInfo minResources;
|
||||||
private Resource maxResources;
|
private ResourceInfo maxResources;
|
||||||
private Resource usedResources;
|
private ResourceInfo usedResources;
|
||||||
private Resource fairResources;
|
private ResourceInfo fairResources;
|
||||||
private Resource clusterResources;
|
private ResourceInfo clusterResources;
|
||||||
|
|
||||||
private String queueName;
|
private String queueName;
|
||||||
|
private String schedulingPolicy;
|
||||||
|
|
||||||
private Collection<FairSchedulerQueueInfo> childInfos;
|
private Collection<FairSchedulerQueueInfo> childQueues;
|
||||||
|
|
||||||
|
public FairSchedulerQueueInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
public FairSchedulerQueueInfo(FSQueue queue, FairScheduler scheduler) {
|
public FairSchedulerQueueInfo(FSQueue queue, FairScheduler scheduler) {
|
||||||
QueueManager manager = scheduler.getQueueManager();
|
QueueManager manager = scheduler.getQueueManager();
|
||||||
|
|
||||||
queueName = queue.getName();
|
queueName = queue.getName();
|
||||||
|
schedulingPolicy = queue.getPolicy().getName();
|
||||||
clusterResources = scheduler.getClusterCapacity();
|
|
||||||
|
|
||||||
usedResources = queue.getResourceUsage();
|
clusterResources = new ResourceInfo(scheduler.getClusterCapacity());
|
||||||
|
|
||||||
|
usedResources = new ResourceInfo(queue.getResourceUsage());
|
||||||
fractionMemUsed = (float)usedResources.getMemory() /
|
fractionMemUsed = (float)usedResources.getMemory() /
|
||||||
clusterResources.getMemory();
|
clusterResources.getMemory();
|
||||||
|
|
||||||
fairResources = queue.getFairShare();
|
fairResources = new ResourceInfo(queue.getFairShare());
|
||||||
minResources = queue.getMinShare();
|
minResources = new ResourceInfo(queue.getMinShare());
|
||||||
maxResources = queue.getMaxShare();
|
maxResources = new ResourceInfo(queue.getMaxShare());
|
||||||
maxResources = Resources.componentwiseMin(maxResources, clusterResources);
|
maxResources = new ResourceInfo(
|
||||||
|
Resources.componentwiseMin(queue.getMaxShare(),
|
||||||
|
scheduler.getClusterCapacity()));
|
||||||
|
|
||||||
fractionMemFairShare = (float)fairResources.getMemory() / clusterResources.getMemory();
|
fractionMemFairShare = (float)fairResources.getMemory() / clusterResources.getMemory();
|
||||||
fractionMemMinShare = (float)minResources.getMemory() / clusterResources.getMemory();
|
fractionMemMinShare = (float)minResources.getMemory() / clusterResources.getMemory();
|
||||||
|
@ -69,13 +89,13 @@ public class FairSchedulerQueueInfo {
|
||||||
|
|
||||||
maxApps = manager.getQueueMaxApps(queueName);
|
maxApps = manager.getQueueMaxApps(queueName);
|
||||||
|
|
||||||
Collection<FSQueue> childQueues = queue.getChildQueues();
|
Collection<FSQueue> children = queue.getChildQueues();
|
||||||
childInfos = new ArrayList<FairSchedulerQueueInfo>();
|
childQueues = new ArrayList<FairSchedulerQueueInfo>();
|
||||||
for (FSQueue child : childQueues) {
|
for (FSQueue child : children) {
|
||||||
if (child instanceof FSLeafQueue) {
|
if (child instanceof FSLeafQueue) {
|
||||||
childInfos.add(new FairSchedulerLeafQueueInfo((FSLeafQueue)child, scheduler));
|
childQueues.add(new FairSchedulerLeafQueueInfo((FSLeafQueue)child, scheduler));
|
||||||
} else {
|
} else {
|
||||||
childInfos.add(new FairSchedulerQueueInfo(child, scheduler));
|
childQueues.add(new FairSchedulerQueueInfo(child, scheduler));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,15 +110,15 @@ public class FairSchedulerQueueInfo {
|
||||||
/**
|
/**
|
||||||
* Returns the fair share of this queue in megabytes.
|
* Returns the fair share of this queue in megabytes.
|
||||||
*/
|
*/
|
||||||
public Resource getFairShare() {
|
public ResourceInfo getFairShare() {
|
||||||
return fairResources;
|
return fairResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Resource getMinResources() {
|
public ResourceInfo getMinResources() {
|
||||||
return minResources;
|
return minResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Resource getMaxResources() {
|
public ResourceInfo getMaxResources() {
|
||||||
return maxResources;
|
return maxResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +130,7 @@ public class FairSchedulerQueueInfo {
|
||||||
return queueName;
|
return queueName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Resource getUsedResources() {
|
public ResourceInfo getUsedResources() {
|
||||||
return usedResources;
|
return usedResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +158,14 @@ public class FairSchedulerQueueInfo {
|
||||||
return fractionMemMaxShare;
|
return fractionMemMaxShare;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the scheduling policy used by this queue.
|
||||||
|
*/
|
||||||
|
public String getSchedulingPolicy() {
|
||||||
|
return schedulingPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<FairSchedulerQueueInfo> getChildQueues() {
|
public Collection<FairSchedulerQueueInfo> getChildQueues() {
|
||||||
return childInfos;
|
return childQueues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,4 +45,9 @@ public class ResourceInfo {
|
||||||
public int getvCores() {
|
public int getvCores() {
|
||||||
return vCores;
|
return vCores;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "<memory:" + memory + ", vCores:" + vCores + ">";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,8 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||||
|
|
||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
@XmlSeeAlso({ CapacitySchedulerInfo.class, FifoSchedulerInfo.class })
|
@XmlSeeAlso({ CapacitySchedulerInfo.class, FairSchedulerInfo.class,
|
||||||
|
FifoSchedulerInfo.class })
|
||||||
public class SchedulerInfo {
|
public class SchedulerInfo {
|
||||||
|
|
||||||
public SchedulerInfo() {
|
public SchedulerInfo() {
|
||||||
|
|
Loading…
Reference in New Issue