Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RAF pool

 
Greg Molens
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This is my first post here, hence at the very beginig I'd like to say hallo to everyone!

Ok, here comes my concern. I am designing a solution for the Bodgitt project and decided to use a pool of RandomAccessFile instances, to achive concurrent reading and exclusive writting to a database file (ReadWriteLock will be used in order to synchronize different threads). My questions is, if I call the write() method on one RAF instance from the pool, how can I assure, that other RAF instances will actually "see" updated data immediately after the write ends? Since there is no flush() method defined in RandomAccessFile class, do I have to call FlieDescriptor's synch() method, each and every time the write operation is performed? Would this be enough solution?

Thanks in advance - G.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would think a RAF pool is a bit complex for this assignment. Don't forget a junior programmer should be able to understand your program and make changes to it. As far as I know you are the 1st one to (try to) implement a pool of RAFs.
Why in the 1st place would you use such a pool? What's the big benefit in this approach?
 
Greg Molens
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, it would give me controll over the number of opened FileDescriptors, which otherwise could unpredictably increase, whilst more and more clients come. Moreover I would not have to open db file, each and every time read operation occurs, if I considered concurrent reads allowed.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Greg. Welcome to our JavaRanch!

Champion, I agree with my good buddy Roel: instead of making things easier, you would unnecessarily introduce complexity in your assignment. It is never said in the assignment that you need to have such a thing, and remember that the key to succeed in this certification is to keep things as simple as possible.

Another approach you may have to avoid such complexity is to have a record cache, which is populated when the application is started. These records are written back to the database when the application finishes (this is the approach Roel and I applied). Also, I would say that you could probably lose points with this approach, because you would introduce more complexity than needed, and even more points if you don't do it correctly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic