如何设置HDFS目录时间进行单元测试
我正在尝试对使用 Hadoop 的 HDFS 编程接口的 Java 程序进行单元测试。我需要创建目录并设置它们的时间,以确保我的程序将在正确的时间“清理”目录。但是,FileSystem.setTimes 似乎不适用于目录,仅适用于文件。有什么方法可以以编程方式设置 HDFS 目录访问/修改时间?我使用的是 Hadoop 0.20.204.0。
谢谢!
坦率
I'm trying to unit test a Java program that uses Hadoop's HDFS programmatic interface. I need to create directories and set their times to make sure that my program will "clean up" the directories at the right times. However, FileSystem.setTimes does not seem to work for directories, only for files. Is there any way I can set up HDFS directories access/modification times programmatically? I'm using Hadoop 0.20.204.0.
Thanks!
Frank
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来这确实是 HDFS bug,最近标记为已解决。如果这对您很重要,也许您需要尝试从不使用版本或快照。
HDFS-2436
Looks like this is indeed HDFS bug, which marked as resolved recently. Perhaps you need to try never version or snapshot if this is critical for you.
HDFS-2436
您是否正在尝试对 Hadoop 或您的程序进行单元测试?如果是后者,那么正确的方法是抽象任何基础设施依赖项,例如 HDFS 并在测试中使用存根/模拟。
Are you trying to unit test Hadoop or your program? If latter then the proper way to do it is to abstract any infrastructure dependencies, such as HDFS and use stub/mock in your tests.