YARN-7661. NodeManager metrics return wrong value after update node resource. Contributed by Yang Wang

This commit is contained in:
Jason Lowe 2017-12-18 14:28:27 -06:00
parent 35ad9b1dd2
commit 811fabdebe
2 changed files with 7 additions and 1 deletions

View File

@ -211,7 +211,7 @@ public void completeOpportunisticContainer(Resource res) {
public void addResource(Resource res) {
availableMB = availableMB + res.getMemorySize();
availableGB.incr((int)Math.floor(availableMB/1024d));
availableGB.set((int)Math.floor(availableMB/1024d));
availableVCores.incr(res.getVirtualCores());
}

View File

@ -84,6 +84,12 @@ public class TestNodeManagerMetrics {
// allocatedGB: 3.75GB allocated 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);
// 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,