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.
| Modifier and Type | Class and Description |
|---|---|
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.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
CPU_EMULATION_PROGRESS_INTERVAL |
protected CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore |
emulatorCore |
| Constructor and Description |
|---|
CumulativeCpuUsageEmulatorPlugin() |
CumulativeCpuUsageEmulatorPlugin(CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore core)
For testing.
|
| Modifier and Type | Method and Description |
|---|---|
void |
emulate()
Emulate the resource usage to match the usage target.
|
float |
getProgress() |
void |
initialize(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.tools.rumen.ResourceUsageMetrics metrics,
org.apache.hadoop.yarn.util.ResourceCalculatorPlugin monitor,
Progressive progress)
Initialize the plugin.
|
protected CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore emulatorCore
public static final String CPU_EMULATION_PROGRESS_INTERVAL
public CumulativeCpuUsageEmulatorPlugin()
public CumulativeCpuUsageEmulatorPlugin(CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore core)
public float getProgress()
getProgress in interface Progressivepublic void emulate()
throws IOException,
InterruptedException
ResourceUsageEmulatorPluginResourceCalculatorPlugin to query for the current
resource usage.emulate in interface ResourceUsageEmulatorPluginIOExceptionInterruptedExceptionpublic void initialize(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.tools.rumen.ResourceUsageMetrics metrics,
org.apache.hadoop.yarn.util.ResourceCalculatorPlugin monitor,
Progressive progress)
ResourceUsageEmulatorPlugininitialize in interface ResourceUsageEmulatorPluginCopyright © 2014 Apache Software Foundation. All Rights Reserved.