GpuResourcePlugin implements ResourcePlugin { @Override public synchronized NMResourceInfo getNMResourceInfo() throws YarnException { final GpuDeviceInformation gpuDeviceInformation; if (gpuDiscoverer.isAutoDiscoveryEnabled()) { checkGpuResourceHandler(); checkErrorCount(); try{ gpuDeviceInformation = gpuDiscoverer.getGpuDeviceInformation(); numOfErrorExecutionSinceLastSucceed = 0; } catch (YarnException e) { LOG.error(e.getMessage(), e); numOfErrorExecutionSinceLastSucceed++; throw e; } } else { gpuDeviceInformation = null; } GpuResourceAllocator gpuResourceAllocator = gpuResourceHandler.getGpuAllocator(); List<GpuDevice> totalGpus = gpuResourceAllocator.getAllowedGpus(); List<AssignedGpuDevice> assignedGpuDevices = gpuResourceAllocator.getAssignedGpus(); return new NMGpuResourceInfo(gpuDeviceInformation, totalGpus, assignedGpuDevices); } GpuResourcePlugin(GpuNodeResourceUpdateHandler resourceDiscoverHandler,
      GpuDiscoverer gpuDiscoverer); @Override void initialize(Context context); @Override ResourceHandler createResourceHandler(
      Context context, CGroupsHandler cGroupsHandler,
      PrivilegedOperationExecutor privilegedOperationExecutor); @Override NodeResourceUpdaterPlugin getNodeResourceHandlerInstance(); @Override void cleanup(); DockerCommandPlugin getDockerCommandPluginInstance(); @Override synchronized NMResourceInfo getNMResourceInfo(); @Override String toString(); static final int MAX_REPEATED_ERROR_ALLOWED; }
@Test(expected = YarnException.class) public void testResourceHandlerNotInitialized() throws YarnException { GpuDiscoverer gpuDiscoverer = createMockDiscoverer(); GpuNodeResourceUpdateHandler gpuNodeResourceUpdateHandler = mock(GpuNodeResourceUpdateHandler.class); GpuResourcePlugin target = new GpuResourcePlugin(gpuNodeResourceUpdateHandler, gpuDiscoverer); target.getNMResourceInfo(); }