|
@@ -619,15 +619,16 @@ public class ContainersMonitorImpl extends AbstractService implements
|
|
|
}
|
|
|
|
|
|
ContainerId containerId = monitoringEvent.getContainerId();
|
|
|
- ContainerMetrics usageMetrics = ContainerMetrics
|
|
|
- .forContainer(containerId, containerMetricsPeriodMs,
|
|
|
- containerMetricsUnregisterDelayMs);
|
|
|
+ ContainerMetrics usageMetrics;
|
|
|
|
|
|
int vmemLimitMBs;
|
|
|
int pmemLimitMBs;
|
|
|
int cpuVcores;
|
|
|
switch (monitoringEvent.getType()) {
|
|
|
case START_MONITORING_CONTAINER:
|
|
|
+ usageMetrics = ContainerMetrics
|
|
|
+ .forContainer(containerId, containerMetricsPeriodMs,
|
|
|
+ containerMetricsUnregisterDelayMs);
|
|
|
ContainerStartMonitoringEvent startEvent =
|
|
|
(ContainerStartMonitoringEvent) monitoringEvent;
|
|
|
usageMetrics.recordStateChangeDurations(
|
|
@@ -640,9 +641,16 @@ public class ContainersMonitorImpl extends AbstractService implements
|
|
|
vmemLimitMBs, pmemLimitMBs, cpuVcores);
|
|
|
break;
|
|
|
case STOP_MONITORING_CONTAINER:
|
|
|
- usageMetrics.finished();
|
|
|
+ usageMetrics = ContainerMetrics.getContainerMetrics(
|
|
|
+ containerId);
|
|
|
+ if (usageMetrics != null) {
|
|
|
+ usageMetrics.finished();
|
|
|
+ }
|
|
|
break;
|
|
|
case CHANGE_MONITORING_CONTAINER_RESOURCE:
|
|
|
+ usageMetrics = ContainerMetrics
|
|
|
+ .forContainer(containerId, containerMetricsPeriodMs,
|
|
|
+ containerMetricsUnregisterDelayMs);
|
|
|
ChangeMonitoringContainerResourceEvent changeEvent =
|
|
|
(ChangeMonitoringContainerResourceEvent) monitoringEvent;
|
|
|
Resource resource = changeEvent.getResource();
|