如何设置HDFS目录时间进行单元测试

发布于 2024-12-25 12:20:01 字数 203 浏览 3 评论 0原文

我正在尝试对使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

戈亓 2025-01-01 12:20:01

看起来这确实是 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

萌无敌 2025-01-01 12:20:01

您是否正在尝试对 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文