LogAggregationFileControllerFactory { public LogAggregationFileController getFileControllerForWrite() { return controllers.getFirst(); } LogAggregationFileControllerFactory(Configuration conf); LogAggregationFileController getFileControllerForWrite(); LogAggregationFileController getFileControllerForRead(
      ApplicationId appId, String appOwner); @Private @VisibleForTesting LinkedList<LogAggregationFileController> getConfiguredLogAggregationFileControllerList();  }
@Test public void testClassConfUsed() { enableFileControllers(Collections.singletonList( LogAggregationTFileController.class), Collections.singletonList("TFile")); LogAggregationFileControllerFactory factory = new LogAggregationFileControllerFactory(getConf()); LogAggregationFileController fc = factory.getFileControllerForWrite(); assertEquals(WRONG_ROOT_LOG_DIR_MSG, "target/app-logs/TFile", fc.getRemoteRootLogDir().toString()); assertEquals(WRONG_ROOT_LOG_DIR_SUFFIX_MSG, "TFile", fc.getRemoteRootLogDirSuffix()); }
@Test public void testNodemanagerConfigurationIsUsed() { Configuration conf = getConf(); conf.set(YarnConfiguration.LOG_AGGREGATION_FILE_FORMATS, "TFile"); LogAggregationFileControllerFactory factory = new LogAggregationFileControllerFactory(conf); LogAggregationFileController fc = factory.getFileControllerForWrite(); assertEquals(WRONG_ROOT_LOG_DIR_MSG, "target/app-logs/default", fc.getRemoteRootLogDir().toString()); assertEquals(WRONG_ROOT_LOG_DIR_SUFFIX_MSG, "log-tfile", fc.getRemoteRootLogDirSuffix()); }
@Test public void testDefaultConfUsed() { Configuration conf = getConf(); conf.unset(YarnConfiguration.NM_REMOTE_APP_LOG_DIR); conf.unset(YarnConfiguration.NM_REMOTE_APP_LOG_DIR_SUFFIX); conf.set(YarnConfiguration.LOG_AGGREGATION_FILE_FORMATS, "TFile"); LogAggregationFileControllerFactory factory = new LogAggregationFileControllerFactory(getConf()); LogAggregationFileController fc = factory.getFileControllerForWrite(); assertEquals(WRONG_ROOT_LOG_DIR_MSG, "/tmp/logs", fc.getRemoteRootLogDir().toString()); assertEquals(WRONG_ROOT_LOG_DIR_SUFFIX_MSG, "logs-tfile", fc.getRemoteRootLogDirSuffix()); }