apache/hadoop · error · RuntimeException

Misconfigured resource usage plugins. Class {} is not a reso

Error message

Misconfigured resource usage plugins. Class {} is not a resource usage plugin as it does not extend {}

What it means

ResourceUsageMatcher.loadEmulatorPlugins reads class names from the config key gridmix.emulators.resource-usage.plugins and instantiates each. Any configured class that is not assignable to ResourceUsageEmulatorPlugin causes a RuntimeException at load time, before initialization. Note the message itself is buggy: it prints clazz.getClass().getName(), i.e. 'java.lang.Class', instead of clazz.getName(), so the message never names the actual bad class.

Source

Thrown at hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/emulators/resourceusage/ResourceUsageMatcher.java:68

   * Configure the {@link ResourceUsageMatcher} to load the configured plugins
   * and initialize them.
   */
  @SuppressWarnings("unchecked")
  public void configure(Configuration conf, ResourceCalculatorPlugin monitor, 
                        ResourceUsageMetrics metrics, Progressive progress) {
    Class[] plugins = conf.getClasses(RESOURCE_USAGE_EMULATION_PLUGINS);
    if (plugins == null) {
      System.out.println("No resource usage emulator plugins configured.");
    } else {
      for (Class clazz : plugins) {
        if (clazz != null) {
          if (ResourceUsageEmulatorPlugin.class.isAssignableFrom(clazz)) {
            ResourceUsageEmulatorPlugin plugin = 
              (ResourceUsageEmulatorPlugin) ReflectionUtils.newInstance(clazz, 
                                                                        conf);
            emulationPlugins.add(plugin);
          } else {
            throw new RuntimeException("Misconfigured resource usage plugins. " 
                + "Class " + clazz.getClass().getName() + " is not a resource "
                + "usage plugin as it does not extend "
                + ResourceUsageEmulatorPlugin.class.getName());
          }
        }
      }
    }

    // initialize the emulators once all the configured emulator plugins are
    // loaded
    for (ResourceUsageEmulatorPlugin emulator : emulationPlugins) {
      emulator.initialize(conf, metrics, monitor, progress);
    }
  }
  
  public void matchResourceUsage() throws IOException, InterruptedException {
    for (ResourceUsageEmulatorPlugin emulator : emulationPlugins) {
      // match the resource usage

View on GitHub (pinned to 2add963021)

Solutions

  1. Make the offending class implement ResourceUsageEmulatorPlugin (and its initialize/compute methods) or remove it from gridmix.emulators.resource-usage.plugins
  2. Because the message always prints 'java.lang.Class', debug by listing the actual configured classes: conf.getClasses("gridmix.emulators.resource-usage.plugins") and check each with ResourceUsageEmulatorPlugin.class.isAssignableFrom(clazz)
  3. Verify the FQCN has no typo and matches the class in the gridmix classpath of the version you run

Example fix

// before
public class MyCpuBurner { ... } // not a plugin
// -Dgridmix.emulators.resource-usage.plugins=org.example.MyCpuBurner

// after
public class MyCpuBurner implements ResourceUsageEmulatorPlugin {
  public void initialize(Configuration conf, ResourceCalculatorPlugin metrics,
                         ResourceUsageEmulatorPlugin monitor /* see interface */) { }
  public void core... 
}
// or use a built-in plugin:
// -Dgridmix.emulators.resource-usage.plugins=org.apache.hadoop.mapred.gridmix.emulators.resourceusage.CumulativeCpuUsageEmulatorPlugin
Defensive patterns

Strategy: type-guard

Validate before calling

// Validate plugin classes before gridmix reads them
for (Class<?> c : conf.getClasses("gridmix.emulators.resource-usage.plugins")) {
  if (c == null || !ResourceUsageEmulatorPlugin.class.isAssignableFrom(c)) {
    throw new IllegalArgumentException("Not a resource usage plugin: " + c);
  }
}

Type guard

static boolean isResourceUsagePlugin(Class<?> clazz) {
  return clazz != null
      && ResourceUsageEmulatorPlugin.class.isAssignableFrom(clazz);
}

Try / catch

try {
  ResourceUsageMatcher.initialize(conf, metrics, monitor, progress);
} catch (RuntimeException e) {
  // message prints 'java.lang.Class' (code bug); dump configured classes yourself
  // and fix gridmix.emulators.resource-usage.plugins
}

Prevention

When it happens

Trigger: Setting -Dgridmix.emulators.resource-usage.plugins=org.example.MyPlugin where MyPlugin does not extend/implement ResourceUsageEmulatorPlugin; adding a fully-qualified class name with a typo (loadClass succeeds via conf.getClasses but assignability fails); listing a ResourceUsageMonitor or unrelated plugin class by mistake.

Common situations: Configuring custom resource emulators for gridmix; copy-pasting plugin FQCNs from documentation of a different Hadoop version where the plugin interface moved; including wrapper/monitor classes (e.g. TotalMemoryUsageEmulatorPlugin's helpers) that are not plugins.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/7f48fa368b7261ff. Report an issue: GitHub.