2015-03-25 66 views
0

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

谢谢

+0

进一步信息:有将是唯一一个接收每天的基础上,即子文件夹不能在主要的一个创建的文件夹。只有文件级别的信息必须用于了解文件是否被处理 – 2015-03-25 12:49:08

回答

0

您需要编写一个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. 

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

0

如果是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