|
@@ -35,6 +35,7 @@ import org.apache.hadoop.yarn.api.records.ContainerId;
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
import org.apache.hadoop.yarn.event.AsyncDispatcher;
|
|
import org.apache.hadoop.yarn.event.AsyncDispatcher;
|
|
import org.apache.hadoop.yarn.event.Dispatcher;
|
|
import org.apache.hadoop.yarn.event.Dispatcher;
|
|
|
|
+import org.apache.hadoop.yarn.server.api.records.ResourceUtilization;
|
|
import org.apache.hadoop.yarn.server.nodemanager.ContainerExecutor;
|
|
import org.apache.hadoop.yarn.server.nodemanager.ContainerExecutor;
|
|
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
|
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerKillEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerKillEvent;
|
|
@@ -78,6 +79,8 @@ public class ContainersMonitorImpl extends AbstractService implements
|
|
private static final long UNKNOWN_MEMORY_LIMIT = -1L;
|
|
private static final long UNKNOWN_MEMORY_LIMIT = -1L;
|
|
private int nodeCpuPercentageForYARN;
|
|
private int nodeCpuPercentageForYARN;
|
|
|
|
|
|
|
|
+ private ResourceUtilization containersUtilization;
|
|
|
|
+
|
|
public ContainersMonitorImpl(ContainerExecutor exec,
|
|
public ContainersMonitorImpl(ContainerExecutor exec,
|
|
AsyncDispatcher dispatcher, Context context) {
|
|
AsyncDispatcher dispatcher, Context context) {
|
|
super("containers-monitor");
|
|
super("containers-monitor");
|
|
@@ -89,6 +92,8 @@ public class ContainersMonitorImpl extends AbstractService implements
|
|
this.containersToBeAdded = new HashMap<ContainerId, ProcessTreeInfo>();
|
|
this.containersToBeAdded = new HashMap<ContainerId, ProcessTreeInfo>();
|
|
this.containersToBeRemoved = new ArrayList<ContainerId>();
|
|
this.containersToBeRemoved = new ArrayList<ContainerId>();
|
|
this.monitoringThread = new MonitoringThread();
|
|
this.monitoringThread = new MonitoringThread();
|
|
|
|
+
|
|
|
|
+ this.containersUtilization = ResourceUtilization.newInstance(0, 0, 0.0f);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -384,6 +389,11 @@ public class ContainersMonitorImpl extends AbstractService implements
|
|
containersToBeRemoved.clear();
|
|
containersToBeRemoved.clear();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Temporary structure to calculate the total resource utilization of
|
|
|
|
+ // the containers
|
|
|
|
+ ResourceUtilization trackedContainersUtilization =
|
|
|
|
+ ResourceUtilization.newInstance(0, 0, 0.0f);
|
|
|
|
+
|
|
// Now do the monitoring for the trackingContainers
|
|
// Now do the monitoring for the trackingContainers
|
|
// Check memory usage and kill any overflowing containers
|
|
// Check memory usage and kill any overflowing containers
|
|
long vmemUsageByAllContainers = 0;
|
|
long vmemUsageByAllContainers = 0;
|
|
@@ -463,6 +473,12 @@ public class ContainersMonitorImpl extends AbstractService implements
|
|
currentPmemUsage, pmemLimit));
|
|
currentPmemUsage, pmemLimit));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Add resource utilization for this container
|
|
|
|
+ trackedContainersUtilization.addTo(
|
|
|
|
+ (int) (currentPmemUsage >> 20),
|
|
|
|
+ (int) (currentVmemUsage >> 20),
|
|
|
|
+ milliVcoresUsed / 1000.0f);
|
|
|
|
+
|
|
// Add usage to container metrics
|
|
// Add usage to container metrics
|
|
if (containerMetricsEnabled) {
|
|
if (containerMetricsEnabled) {
|
|
ContainerMetrics.forContainer(
|
|
ContainerMetrics.forContainer(
|
|
@@ -542,6 +558,9 @@ public class ContainersMonitorImpl extends AbstractService implements
|
|
+ cpuUsagePercentPerCoreByAllContainers);
|
|
+ cpuUsagePercentPerCoreByAllContainers);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Save the aggregated utilization of the containers
|
|
|
|
+ setContainersUtilization(trackedContainersUtilization);
|
|
|
|
+
|
|
try {
|
|
try {
|
|
Thread.sleep(monitoringInterval);
|
|
Thread.sleep(monitoringInterval);
|
|
} catch (InterruptedException e) {
|
|
} catch (InterruptedException e) {
|
|
@@ -613,6 +632,15 @@ public class ContainersMonitorImpl extends AbstractService implements
|
|
return this.vmemCheckEnabled;
|
|
return this.vmemCheckEnabled;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public ResourceUtilization getContainersUtilization() {
|
|
|
|
+ return this.containersUtilization;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setContainersUtilization(ResourceUtilization utilization) {
|
|
|
|
+ this.containersUtilization = utilization;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void handle(ContainersMonitorEvent monitoringEvent) {
|
|
public void handle(ContainersMonitorEvent monitoringEvent) {
|
|
|
|
|