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

java.lang.Object
  extended by org.apache.hadoop.mapred.gridmix.emulators.resourceusage.CumulativeCpuUsageEmulatorPlugin
All Implemented Interfaces:
ResourceUsageEmulatorPlugin

public class CumulativeCpuUsageEmulatorPlugin
extends Object
implements ResourceUsageEmulatorPlugin

A ResourceUsageEmulatorPlugin that emulates the cumulative CPU usage by performing certain CPU intensive operations. Performing such CPU intensive operations essentially uses up some CPU. Every ResourceUsageEmulatorPlugin is configured with a feedback module i.e a ResourceCalculatorPlugin, to monitor the resource usage.

CumulativeCpuUsageEmulatorPlugin emulates the CPU usage in steps. The frequency of emulation can be configured via CPU_EMULATION_PROGRESS_INTERVAL. CPU usage values are matched via emulation only on the interval boundaries.

CumulativeCpuUsageEmulatorPlugin is a wrapper program for managing the CPU usage emulation feature. It internally uses an emulation algorithm (called as core and described using CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore) for performing the actual emulation. Multiple calls to this core engine should use up some amount of CPU.

CumulativeCpuUsageEmulatorPlugin provides a calibration feature via initialize(Configuration, ResourceUsageMetrics, ResourceCalculatorPlugin, Progressive) to calibrate the plugin and its core for the underlying hardware. As a result of calibration, every call to the emulation engine's core should roughly use up 1% of the total usage value to be emulated. This makes sure that the underlying hardware is profiled before use and that the plugin doesn't accidently overuse the CPU. With 1% as the unit emulation target value for the core engine, there will be roughly 100 calls to the engine resulting in roughly 100 calls to the feedback (resource usage monitor) module. Excessive usage of the feedback module is discouraged as it might result into excess CPU usage resulting into no real CPU emulation.


Nested Class Summary
static interface CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore
          This is the core CPU usage emulation algorithm.
static class CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator
          This is the core engine to emulate the CPU usage.
 
Field Summary
static String CPU_EMULATION_PROGRESS_INTERVAL
           
protected  CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore emulatorCore
           
 
Constructor Summary
CumulativeCpuUsageEmulatorPlugin()
           
CumulativeCpuUsageEmulatorPlugin(CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore core)
          For testing.
 
Method Summary
 void emulate()
          Emulate the resource usage to match the usage target.
 void initialize(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.tools.rumen.ResourceUsageMetrics metrics, org.apache.hadoop.mapreduce.util.ResourceCalculatorPlugin monitor, Progressive progress)
          Initialize the plugin.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

emulatorCore

protected CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore emulatorCore

CPU_EMULATION_PROGRESS_INTERVAL

public static final String CPU_EMULATION_PROGRESS_INTERVAL
See Also:
Constant Field Values
Constructor Detail

CumulativeCpuUsageEmulatorPlugin

public CumulativeCpuUsageEmulatorPlugin()

CumulativeCpuUsageEmulatorPlugin

public CumulativeCpuUsageEmulatorPlugin(CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore core)
For testing.

Method Detail

emulate

public void emulate()
             throws IOException,
                    InterruptedException
Description copied from interface: ResourceUsageEmulatorPlugin
Emulate the resource usage to match the usage target. The plugin can use the given ResourceCalculatorPlugin to query for the current resource usage.

Specified by:
emulate in interface ResourceUsageEmulatorPlugin
Throws:
IOException
InterruptedException

initialize

public void initialize(org.apache.hadoop.conf.Configuration conf,
                       org.apache.hadoop.tools.rumen.ResourceUsageMetrics metrics,
                       org.apache.hadoop.mapreduce.util.ResourceCalculatorPlugin monitor,
                       Progressive progress)
Description copied from interface: ResourceUsageEmulatorPlugin
Initialize the plugin. This might involve - initializing the variables - calibrating the plugin

Specified by:
initialize in interface ResourceUsageEmulatorPlugin


Copyright © 2012 Apache Software Foundation. All Rights Reserved.