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:
Jason Lowe 2017-12-18 14:28:27 -06:00
parent 7c648d3e72
commit f3c10beb16
2 changed files with 7 additions and 1 deletions

View File

@ -198,7 +198,7 @@ public class NodeManagerMetrics {
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,