|
[
Permlink
| « Hide
]
dhruba borthakur added a comment - 22/Oct/08 09:12 PM
+1. Looks good.
Minor doc suggestion:
In the documentation in hdfs.h O_WRONLY is for create not for writing to arbitrary part of a file. I just noticed that the test uses O_CREAT but the impl does not even bother checking for this (ie treats O_WRONLY as create): Unfortunately fixing this to match posix will break compatibility of apps, since truck libhdfs did not check for O_CREAT either.
Yes, open on writes should i guess be O_WRONLY + one of the following: 1. O_CREAT | O_EXCL - create new file But, as you point out hdfsOpenFile has only ever checked for O_WRONLY|O_RDONLY. And #2 cannot be done without underlying FileSystem API. But, as you point out, if someone does something like `echo hello >> foo` where foo does not exist, libhdfs will do the wrong thing probably. We need: FSDataOutputStream FileSystem.appendIfExistsElseCreate(Path p); I can open a JIRA for it. I guess that means anyone using libhdfs (e.g. fuse) would have to do a hacky check if the file exists and decide whether to pass on the append flag, which of course is not transactional. And of course, let's not even get into passing on O_TRUNCATE idea - we deprecate not having the O_CREAT flag by writing out a warning and updating the docs.
The good thing about this kind of deprecation is we can ultimately just return -ENOENT when we are ready - should be easy for users to see they have to fix something. but, should also look at O_EXCL at the same time ... added more comments to the flags param and also issue a stderr warning if O_CREAT & O_EXCL are but set.
the unit tests will not pass without fixing getPos
Anything needed to get this patch in?
Hi Craig, will it be possible for you to review and test this patch on trunk? Also, I would like to put it in 0.19, unless you think otherwise.
Hi Craig, can you pl review this patch? Thanks. Also, I see some earlier review comments from Sanjay.
Sanjay: do you want to review this patch too? Hi Dhruba,
Sorry, I'm currently traveling. I can test for end of next week at earliest. Thanks Craig. Please do let me know if this patch looks good to you.
I just committed this. Thanks Pete!
Integrated in Hadoop-trunk #756 (See http://hudson.zones.apache.org/hudson/job/Hadoop-trunk/756/
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||