Hadoop 如何在HDFS中识别新文件

Hadoop 如何在HDFS中识别新文件,hadoop,mapreduce,hdfs,yarn,hadoop2,Hadoop,Mapreduce,Hdfs,Yarn,Hadoop2,只是想知道是否有一种方法可以识别添加到HDFS路径中的新文件?例如,如果某些文件已存在一段时间。现在我已经添加了新文件。所以我只想处理那些新文件。实现这一目标的最佳方式是什么 谢谢要做到这一点,您需要编写java代码。这些步骤可能有助于: 1. Before adding new files, fetch the last modified time (hadoop fs -ls /your-path). Lets say it as mTime. 2. Next upload new file

只是想知道是否有一种方法可以识别添加到HDFS路径中的新文件?例如,如果某些文件已存在一段时间。现在我已经添加了新文件。所以我只想处理那些新文件。实现这一目标的最佳方式是什么


谢谢

要做到这一点,您需要编写java代码。这些步骤可能有助于:

1. Before adding new files, fetch the last modified time (hadoop fs -ls /your-path). Lets say it as mTime.
2. Next upload new files into hdfs path
3. Now filter the files that are greater than mTime. These files are to be processed. Make your program to process only these files.

这只是开发代码的提示。:)

如果是Mapreduce,则可以每天创建附加时间戳的输出目录


进一步信息:只有一个文件夹接收文件,即不能每天在主文件夹下创建子文件夹。只有文件级信息才能用于了解文件是否已处理
    FileOutputFormat.setOutputPath(job, new Path(hdfsFilePath
            + timestamp_start); // start at 12 midnight for example:  1427241600 (GMT) --you can write logic to get epoch time