setLastModified 不适用于 NFS 共享
我的一台 Solaris 服务器上安装了 NFS 共享。路径/appdata/anp从服务器A安装到服务器B。在共享下:
/appdata/anp
我有一个名为
/appdata/anp/ 的文件夹工厂
在上面的目录中,我放置了包含需要在数据库中导入/更新的数据的文件。在数据库中导入数据后,我根据导入数据的操作结果将文件移动到成功/失败目录中。
/appdata/anp/factory/success
/appdata/anp/factory/failure
我将文件移动到上述任一目录,并将文件的上次修改时间更新为当前系统时间使用:
file.setLastModified
,它返回一个布尔值。问题是每当我执行此更新操作时,它都无法将该文件的时间戳更新为当前系统时间。
返回失败的场景是什么
有谁知道file.setLastModified
。我什至检查了 NFS 权限,对我来说一切似乎都很好。无论如何,是否知道 setLastModified 可能返回失败的情况?
请帮帮我,我真的很纠结这个!! :(
I have an NFS share mounted on one of my Solaris server. The path /appdata/anp is mounted from Server A onto Server B. Under the share:
/appdata/anp
I have a folder named
/appdata/anp/factory
In the above directory I put files which has the data that needs to imported/updated in the database. After importing data in the database I move the file to success/failure directory based on the operation result of the imported data.
/appdata/anp/factory/success
/appdata/anp/factory/failure
I move the file to either of the above directories and update the last modified time of the file to the current system time using:
file.setLastModified
which returns a boolean value. The problem is whenever I am doing this update operation it fails to update the timestamp of that file to the current system time.
Does anyone know what are the the scenarios in which
file.setLastModified
returns failure. I have even checked the NFS permissions and everything seems okay to me. Is there anyway to know the cases where setLastModified could return failure?
Please help me out I am really pulling my hair on this one!! :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 Unix 文件系统上也遇到了类似的问题。就我而言,这是因为 unix 截断了最后修改的毫秒并将最后修改的毫秒设置为:
System.currentTimeMillis() - System.currentTimeMillis() % 1000
它影响了一个测试用例,该测试用例正在操作文件,然后通过文件检查更新.lastModified()。我只是在更新测试用例中的文件之前添加了 Thread.sleep(1100) ,一切都已解决。
希望能帮助下一个人。
I had a similar problem on a Unix file system. In my case it was because unix was truncating the last modified milliseconds and setting the last modified to:
System.currentTimeMillis() - System.currentTimeMillis() % 1000
It was affecting a test case which was manipulating a file then checking for updates via file.lastModified(). I simply added Thread.sleep(1100) before updating the file in my test case and all was resolved.
Hope that helps the next person.