while investigating single vs. multiple rafs option, I have some doubts on the latter one. Isn't each raf associated with file handle? If so, then multiple rafs solution can fail if underlying OS reaches file handles limit.
When I synchronize on this raf instance, then all that record-locking mechanism becomes quite useless, doesn't it?
Andrew, just out of curiosity, what design choice you had in your solution - single RAF or multiple instances?
And you did expose lock/unlock methods to client, right?
if I may, what scores you got on data class and locking?
And for single raf vs multiple rafs - read my post once again. I was refering to OS file handles limit. Suppose that there are thousands of active connections, and each of them get raf instance. At some point OS file handle limit nay be reached and new connections will not get their raf and will be blocked completely.
Also consider physical(low level) file I/O - I'm not so sure if multiple I/O can be performed at the same time on the same file(or different files), unless with multi-head hard drive(imo). So database(file in our case) access will always be sequential at some level and concurent requests will be blocked anyway.
"A clear design, such as will be readily understood by junior programmers, will be preferred to a complex one, even if the complex one is a little more efficient."
Does it justify using single RandomAccessFile? Or I simply don't get it at all and there is nothing wrong in using single instance of RandomAccessFile?
You do realize that when you synchronize only your create method, it means that you do not allow more than one thread to create a new record at a time but other operations are allowable, right?
So, when t1 thread is creating a new record, t2 thread is permitted to perform the search operation. Then it depends on the implementation � the search would need a file length but it can be changed by create method at any moment, so accuracy and careful analysis is needed here.
I find it quite overwhelming and time consuming for this project and this is why I have started looking again back to more simple design with just single raf (see my previous post). What do you think?