MAPREDUCE-4083. [Gridmix] NPE in cpu emulation. (amarrk via tgraves)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1461272 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b854b245ed
commit
8f43934e99
|
@ -96,6 +96,8 @@ Release 2.0.5-beta - UNRELEASED
|
|||
MAPREDUCE-3008. Improvements to cumulative CPU emulation for short running
|
||||
tasks in Gridmix. (amarrk via tgraves)
|
||||
|
||||
MAPREDUCE-4083. [Gridmix] NPE in cpu emulation. (amarrk via tgraves)
|
||||
|
||||
Release 2.0.4-alpha - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -236,7 +236,9 @@ implements ResourceUsageEmulatorPlugin {
|
|||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return Math.min(1f, ((float)getCurrentCPUUsage())/targetCpuUsage);
|
||||
return enabled
|
||||
? Math.min(1f, ((float)getCurrentCPUUsage())/targetCpuUsage)
|
||||
: 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -298,6 +300,9 @@ implements ResourceUsageEmulatorPlugin {
|
|||
public void initialize(Configuration conf, ResourceUsageMetrics metrics,
|
||||
ResourceCalculatorPlugin monitor,
|
||||
Progressive progress) {
|
||||
this.monitor = monitor;
|
||||
this.progress = progress;
|
||||
|
||||
// get the target CPU usage
|
||||
targetCpuUsage = metrics.getCumulativeCpuUsage();
|
||||
if (targetCpuUsage <= 0 ) {
|
||||
|
@ -307,8 +312,6 @@ implements ResourceUsageEmulatorPlugin {
|
|||
enabled = true;
|
||||
}
|
||||
|
||||
this.monitor = monitor;
|
||||
this.progress = progress;
|
||||
emulationInterval = conf.getFloat(CPU_EMULATION_PROGRESS_INTERVAL,
|
||||
DEFAULT_EMULATION_FREQUENCY);
|
||||
|
||||
|
|
|
@ -188,7 +188,9 @@ implements ResourceUsageEmulatorPlugin {
|
|||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return Math.min(1f, ((float)getTotalHeapUsageInMB())/targetHeapUsageInMB);
|
||||
return enabled
|
||||
? Math.min(1f, ((float)getTotalHeapUsageInMB())/targetHeapUsageInMB)
|
||||
: 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -237,6 +239,8 @@ implements ResourceUsageEmulatorPlugin {
|
|||
public void initialize(Configuration conf, ResourceUsageMetrics metrics,
|
||||
ResourceCalculatorPlugin monitor,
|
||||
Progressive progress) {
|
||||
this.progress = progress;
|
||||
|
||||
// get the target heap usage
|
||||
targetHeapUsageInMB = metrics.getHeapUsage() / ONE_MB;
|
||||
if (targetHeapUsageInMB <= 0 ) {
|
||||
|
@ -248,7 +252,6 @@ implements ResourceUsageEmulatorPlugin {
|
|||
enabled = true;
|
||||
}
|
||||
|
||||
this.progress = progress;
|
||||
emulationInterval =
|
||||
conf.getFloat(HEAP_EMULATION_PROGRESS_INTERVAL,
|
||||
DEFAULT_EMULATION_PROGRESS_INTERVAL);
|
||||
|
|
|
@ -170,6 +170,11 @@ public class TestGridmixMemoryEmulation {
|
|||
assertEquals("Disabled heap usage emulation plugin works!",
|
||||
heapUsagePre, heapUsagePost);
|
||||
|
||||
// test with get progress
|
||||
float progress = heapPlugin.getProgress();
|
||||
assertEquals("Invalid progress of disabled cumulative heap usage emulation "
|
||||
+ "plugin!", 1.0f, progress, 0f);
|
||||
|
||||
// test with wrong/invalid configuration
|
||||
Boolean failed = null;
|
||||
invalidUsage =
|
||||
|
|
|
@ -472,6 +472,11 @@ public class TestResourceUsageEmulators {
|
|||
assertEquals("Disabled cumulative CPU usage emulation plugin works!",
|
||||
cpuUsagePre, cpuUsagePost);
|
||||
|
||||
// test with get progress
|
||||
float progress = cpuPlugin.getProgress();
|
||||
assertEquals("Invalid progress of disabled cumulative CPU usage emulation "
|
||||
+ "plugin!", 1.0f, progress, 0f);
|
||||
|
||||
// test with valid resource usage value
|
||||
ResourceUsageMetrics metrics = createMetrics(targetCpuUsage);
|
||||
|
||||
|
|
Loading…
Reference in New Issue