{"record":{"id":"7f48fa368b7261ff","repo":"apache/hadoop","slug":"misconfigured-resource-usage-plugins-class-is","errorCode":null,"errorMessage":"Misconfigured resource usage plugins. Class {} is not a resource usage plugin as it does not extend {}","messagePattern":"Misconfigured resource usage plugins\\. Class (.+?) is not a resource usage plugin as it does not extend (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/emulators/resourceusage/ResourceUsageMatcher.java","lineNumber":68,"sourceCode":"   * Configure the {@link ResourceUsageMatcher} to load the configured plugins\n   * and initialize them.\n   */\n  @SuppressWarnings(\"unchecked\")\n  public void configure(Configuration conf, ResourceCalculatorPlugin monitor, \n                        ResourceUsageMetrics metrics, Progressive progress) {\n    Class[] plugins = conf.getClasses(RESOURCE_USAGE_EMULATION_PLUGINS);\n    if (plugins == null) {\n      System.out.println(\"No resource usage emulator plugins configured.\");\n    } else {\n      for (Class clazz : plugins) {\n        if (clazz != null) {\n          if (ResourceUsageEmulatorPlugin.class.isAssignableFrom(clazz)) {\n            ResourceUsageEmulatorPlugin plugin = \n              (ResourceUsageEmulatorPlugin) ReflectionUtils.newInstance(clazz, \n                                                                        conf);\n            emulationPlugins.add(plugin);\n          } else {\n            throw new RuntimeException(\"Misconfigured resource usage plugins. \" \n                + \"Class \" + clazz.getClass().getName() + \" is not a resource \"\n                + \"usage plugin as it does not extend \"\n                + ResourceUsageEmulatorPlugin.class.getName());\n          }\n        }\n      }\n    }\n\n    // initialize the emulators once all the configured emulator plugins are\n    // loaded\n    for (ResourceUsageEmulatorPlugin emulator : emulationPlugins) {\n      emulator.initialize(conf, metrics, monitor, progress);\n    }\n  }\n  \n  public void matchResourceUsage() throws IOException, InterruptedException {\n    for (ResourceUsageEmulatorPlugin emulator : emulationPlugins) {\n      // match the resource usage","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/emulators/resourceusage/ResourceUsageMatcher.java#L50-L86","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Make the offending class implement ResourceUsageEmulatorPlugin (and its initialize/compute methods) or remove it from gridmix.emulators.resource-usage.plugins","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)","Verify the FQCN has no typo and matches the class in the gridmix classpath of the version you run"],"exampleFix":"// before\npublic class MyCpuBurner { ... } // not a plugin\n// -Dgridmix.emulators.resource-usage.plugins=org.example.MyCpuBurner\n\n// after\npublic class MyCpuBurner implements ResourceUsageEmulatorPlugin {\n  public void initialize(Configuration conf, ResourceCalculatorPlugin metrics,\n                         ResourceUsageEmulatorPlugin monitor /* see interface */) { }\n  public void core... \n}\n// or use a built-in plugin:\n// -Dgridmix.emulators.resource-usage.plugins=org.apache.hadoop.mapred.gridmix.emulators.resourceusage.CumulativeCpuUsageEmulatorPlugin","handlingStrategy":"type-guard","validationCode":"// Validate plugin classes before gridmix reads them\nfor (Class<?> c : conf.getClasses(\"gridmix.emulators.resource-usage.plugins\")) {\n  if (c == null || !ResourceUsageEmulatorPlugin.class.isAssignableFrom(c)) {\n    throw new IllegalArgumentException(\"Not a resource usage plugin: \" + c);\n  }\n}","typeGuard":"static boolean isResourceUsagePlugin(Class<?> clazz) {\n  return clazz != null\n      && ResourceUsageEmulatorPlugin.class.isAssignableFrom(clazz);\n}","tryCatchPattern":"try {\n  ResourceUsageMatcher.initialize(conf, metrics, monitor, progress);\n} catch (RuntimeException e) {\n  // message prints 'java.lang.Class' (code bug); dump configured classes yourself\n  // and fix gridmix.emulators.resource-usage.plugins\n}","preventionTips":["Remember the error message is buggy — it always says 'java.lang.Class'; inspect the config value directly","Implement ResourceUsageEmulatorPlugin in every custom emulator and smoke-test assignability in a unit test"],"tags":["hadoop","gridmix","resource-emulation","plugin","configuration"],"backgroundTag":"invalid-plugin-configuration","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}