@Test public void testFailedDirLogDeletion() throws Exception { File[] localLogDirs = getLocalLogDirFiles(this.getClass().getName(), 7); final List<String> localLogDirPaths = new ArrayList<String>(localLogDirs.length); for (int i = 0; i < localLogDirs.length; i++) { localLogDirPaths.add(localLogDirs[i].getAbsolutePath()); } String localLogDirsString = StringUtils.join(localLogDirPaths, ","); conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDirsString); conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, false); conf.setLong(YarnConfiguration.NM_LOG_RETAIN_SECONDS, 0l); LocalDirsHandlerService mockDirsHandler = mock(LocalDirsHandlerService.class); NonAggregatingLogHandler rawLogHandler = new NonAggregatingLogHandler(dispatcher, mockDelService, mockDirsHandler); NonAggregatingLogHandler logHandler = spy(rawLogHandler); AbstractFileSystem spylfs = spy(FileContext.getLocalFSFileContext().getDefaultFileSystem()); FileContext lfs = FileContext.getFileContext(spylfs, conf); doReturn(lfs).when(logHandler) .getLocalFileContext(isA(Configuration.class)); logHandler.init(conf); logHandler.start(); runMockedFailedDirs(logHandler, appId, user, mockDelService, mockDirsHandler, conf, spylfs, lfs, localLogDirs); logHandler.close(); }
FileContext getLocalFileContext(Configuration conf) { try { return FileContext.getLocalFSFileContext(conf); } catch (IOException e) { throw new YarnRuntimeException("Failed to access local fs"); } }
NonAggregatingLogHandler extends AbstractService implements
    LogHandler { FileContext getLocalFileContext(Configuration conf) { try { return FileContext.getLocalFSFileContext(conf); } catch (IOException e) { throw new YarnRuntimeException("Failed to access local fs"); } } }
NonAggregatingLogHandler extends AbstractService implements
    LogHandler { FileContext getLocalFileContext(Configuration conf) { try { return FileContext.getLocalFSFileContext(conf); } catch (IOException e) { throw new YarnRuntimeException("Failed to access local fs"); } } NonAggregatingLogHandler(Dispatcher dispatcher,
      DeletionService delService, LocalDirsHandlerService dirsHandler); }
NonAggregatingLogHandler extends AbstractService implements
    LogHandler { FileContext getLocalFileContext(Configuration conf) { try { return FileContext.getLocalFSFileContext(conf); } catch (IOException e) { throw new YarnRuntimeException("Failed to access local fs"); } } NonAggregatingLogHandler(Dispatcher dispatcher,
      DeletionService delService, LocalDirsHandlerService dirsHandler); @SuppressWarnings("unchecked") @Override void handle(LogHandlerEvent event); }
NonAggregatingLogHandler extends AbstractService implements
    LogHandler { FileContext getLocalFileContext(Configuration conf) { try { return FileContext.getLocalFSFileContext(conf); } catch (IOException e) { throw new YarnRuntimeException("Failed to access local fs"); } } NonAggregatingLogHandler(Dispatcher dispatcher,
      DeletionService delService, LocalDirsHandlerService dirsHandler); @SuppressWarnings("unchecked") @Override void handle(LogHandlerEvent event);  }