YARN-7661. NodeManager metrics return wrong value after update node resource. Contributed by Yang Wang
(cherry picked from commit 811fabdebe
)
This commit is contained in:
parent
da4e2f38e1
commit
31a06baca0
|
@ -198,7 +198,7 @@ public class NodeManagerMetrics {
|
||||||
|
|
||||||
public void addResource(Resource res) {
|
public void addResource(Resource res) {
|
||||||
availableMB = availableMB + res.getMemorySize();
|
availableMB = availableMB + res.getMemorySize();
|
||||||
availableGB.incr((int)Math.floor(availableMB/1024d));
|
availableGB.set((int)Math.floor(availableMB/1024d));
|
||||||
availableVCores.incr(res.getVirtualCores());
|
availableVCores.incr(res.getVirtualCores());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,12 @@ public class TestNodeManagerMetrics {
|
||||||
// allocatedGB: 3.75GB allocated memory is shown as 4GB
|
// allocatedGB: 3.75GB allocated memory is shown as 4GB
|
||||||
// availableGB: 4.25GB available memory is shown as 4GB
|
// availableGB: 4.25GB available memory is shown as 4GB
|
||||||
checkMetrics(10, 1, 1, 1, 1, 1, 4, 7, 4, 13, 3);
|
checkMetrics(10, 1, 1, 1, 1, 1, 4, 7, 4, 13, 3);
|
||||||
|
|
||||||
|
// Update resource and check available resource again
|
||||||
|
metrics.addResource(total);
|
||||||
|
MetricsRecordBuilder rb = getMetrics("NodeManagerMetrics");
|
||||||
|
assertGauge("AvailableGB", 12, rb);
|
||||||
|
assertGauge("AvailableVCores", 19, rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkMetrics(int launched, int completed, int failed, int killed,
|
private void checkMetrics(int launched, int completed, int failed, int killed,
|
||||||
|
|
Loading…
Reference in New Issue