org.apache.hadoop.mapred.gridmix.emulators.resourceusage
Class CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator

java.lang.Object
  extended by org.apache.hadoop.mapred.gridmix.emulators.resourceusage.CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator
All Implemented Interfaces:
CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore
Enclosing class:
CumulativeCpuUsageEmulatorPlugin

public static class CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator
extends Object
implements CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore

This is the core engine to emulate the CPU usage. The only responsibility of this class is to perform certain math intensive operations to make sure that some desired value of CPU is used.


Field Summary
protected  double returnValue
          This is to fool the JVM and make it think that we need the value stored in the unit computation i.e compute().
 
Constructor Summary
CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator()
          Initialized the CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator with default values.
 
Method Summary
 void calibrate(org.apache.hadoop.yarn.util.ResourceCalculatorPlugin monitor, long totalCpuUsage)
          This will calibrate the algorithm such that a single invocation of compute() emulates roughly 1% of the total desired resource usage value.
 void compute()
          This will consume some desired level of CPU.
protected  void performUnitComputation()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

returnValue

protected double returnValue
This is to fool the JVM and make it think that we need the value stored in the unit computation i.e compute(). This will prevent the JVM from optimizing the code.

Constructor Detail

CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator

public CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator()
Initialized the CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator with default values. Note that the CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator should be calibrated (see calibrate(ResourceCalculatorPlugin, long)) when initialized using this constructor.

Method Detail

compute

public void compute()
This will consume some desired level of CPU. This API will try to use up 'X' percent of the target cumulative CPU usage. Currently X is set to 10%.

Specified by:
compute in interface CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore

performUnitComputation

protected void performUnitComputation()

calibrate

public void calibrate(org.apache.hadoop.yarn.util.ResourceCalculatorPlugin monitor,
                      long totalCpuUsage)
This will calibrate the algorithm such that a single invocation of compute() emulates roughly 1% of the total desired resource usage value.

Specified by:
calibrate in interface CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore


Copyright © 2014 Apache Software Foundation. All Rights Reserved.