public List<ContainerLogMeta> collect(
      LogAggregationFileController fileController) throws IOException {
    List<ContainerLogMeta> containersLogMeta = new ArrayList<>();
    RemoteIterator<FileStatus> appDirs = fileController.
        getApplicationDirectoriesOfUser(logsRequest.getUser());

    while (appDirs.hasNext()) {
      FileStatus currentAppDir = appDirs.next();
      if (logsRequest.getAppId() == null ||
          logsRequest.getAppId().equals(currentAppDir.getPath().getName())) {
        ApplicationId appId = ApplicationId.fromString(
            currentAppDir.getPath().getName());
        RemoteIterator<FileStatus> nodeFiles = fileController
            .getNodeFilesOfApplicationDirectory(currentAppDir);

        while (nodeFiles.hasNext()) {
          FileStatus currentNodeFile = nodeFiles.next();
          if (!logsRequest.getNodeId().match(currentNodeFile.getPath()
              .getName())) {
            continue;
          }

          if (currentNodeFile.getPath().getName().equals(
              logsRequest.getAppId() + ".har")) {
            Path p = new Path("har:///"
                + currentNodeFile.getPath().toUri().getRawPath());
            nodeFiles = HarFs.get(p.toUri(), conf).listStatusIterator(p);
            continue;
          }

          try {
            Map<String, List<ContainerLogFileInfo>> metaFiles = fileController
                .getLogMetaFilesOfNode(logsRequest, currentNodeFile, appId);
            if (metaFiles == null) {
              continue;
            }

            metaFiles.entrySet().removeIf(entry ->
                !(logsRequest.getContainerId() == null ||
                    logsRequest.getContainerId().equals(entry.getKey())));

            containersLogMeta.addAll(createContainerLogMetas(
                currentNodeFile.getPath().getName(), metaFiles));
          } catch (IOException ioe) {
            LOG.warn("Can not get log meta from the log file:"
                + currentNodeFile.getPath() + "\n" + ioe.getMessage());
          }

        }
      }

    }
    return containersLogMeta;
  }
@Test
  void testSingleNodeRequest() throws IOException {
    ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
        new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
    request.setAppId(null);
    request.setContainerId(null);
    request.setFileName(null);
    request.setFileSize(null);
    request.setModificationTime(null);
    request.setNodeId(TEST_NODE);
    request.setUser(null);

    LogAggregationMetaCollector collector = new LogAggregationMetaCollector(
        request.build(), new YarnConfiguration());
    List<ContainerLogMeta> res = collector.collect(fileController);

    List<ContainerLogFileInfo> allFile = res.stream()
        .flatMap(m -> m.getContainerLogMeta().stream())
        .collect(Collectors.toList());
    assertEquals(4, allFile.stream().
        filter(f -> f.getFileName().contains(TEST_NODE)).count());
  }