code: public int getNumberOfFiles() throws IOException {
        DistributedFileSystem dfs = (DistributedFileSystem)fs;
        RemoteIterator<LocatedFileStatus> iter = dfs.listLocatedStatus(outputPath);
        int fn = 0;
        while (iter.hasNext()) {
          LocatedFileStatus lfs = iter.next();
          if (lfs.isDir()) 
            continue;
          if (lfs.getBlockLocations().length != 1) 
            continue;
          String curHost = rtc.cur_datanode;
          for (String host: lfs.getBlockLocations()[0].getHosts()) {
            if (curHost.equals(host)){
              fn++;
              break;
            }
          }
        }
        LOG.info(" Found " + fn + " files in " + dfs.getUri());
        return fn;
      }
docs: /*
  Look at the output directory to see how many files belong to
  the current datanode