ResourcePluginManager { public synchronized void initialize(Context context) throws YarnException { Configuration conf = context.getConf(); String[] plugins = conf.getStrings(YarnConfiguration.NM_RESOURCE_PLUGINS); if (plugins != null) { Map<String, ResourcePlugin> pluginMap = new HashMap<>(); for (String resourceName : plugins) { resourceName = resourceName.trim(); if (!SUPPORTED_RESOURCE_PLUGINS.contains(resourceName)) { String msg = "Trying to initialize resource plugin with name=" + resourceName + ", it is not supported, list of supported plugins:" + StringUtils.join(",", SUPPORTED_RESOURCE_PLUGINS); LOG.error(msg); throw new YarnException(msg); } if (pluginMap.containsKey(resourceName)) { continue; } ResourcePlugin plugin = null; if (resourceName.equals(GPU_URI)) { plugin = new GpuResourcePlugin(); } if (resourceName.equals(FPGA_URI)) { plugin = new FpgaResourcePlugin(); } if (plugin == null) { throw new YarnException( "This shouldn't happen, plugin=" + resourceName + " should be loaded and initialized"); } plugin.initialize(context); pluginMap.put(resourceName, plugin); } configuredPlugins = Collections.unmodifiableMap(pluginMap); } }  synchronized void initialize(Context context); synchronized void cleanup(); synchronized Map<String, ResourcePlugin> getNameToPlugins();  }
@Test(timeout = 30000) public void testResourcePluginManagerInitialization() throws Exception { final ResourcePluginManager rpm = stubResourcePluginmanager(); nm = new MyMockNM(rpm); YarnConfiguration conf = createNMConfig(); nm.init(conf); verify(rpm, times(1)).initialize( any(Context.class)); }