• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

B&S 2.1.1 : Data Access & Locking Mechanism

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
I am working on the design phase for the SCJD - B&S 2.1.1.

I just want to make sure that I understand something here and correct me if I am wrong.

There are two essential parts here:

1. Data Access: I usually planning on having some sort of an Access Manager that would handle data access tasks (I/O,DAO,DTO,..etc). That would make sure that multiple reads are possible and only one write for any record in the db file.


2. Locking Mechanism: That would make sure if a record is to be locked for booking or something like that, only the same client is able to unlock it .


Both of the above might be a combination of synchronized blocks and/or java.util.concurrent.locks. Is that correct ?

Thanks,
Mostafa

 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you have 2 parts in the Data class: the real data access (reads and writes to a file) and a locking mechanism which should prevent a thread from updating/deleting a record if it doesn't own the lock on that record.
 
Mostafa Radwan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Roel for your prompt reply.

One last question, Is the data access (reads/writes) have to allow concurrent access as well ? I guess the answer is Yes.

So overall, there are two layers here one for data access(I/O) and the other for concurrent record locking/unlocking.

Thanks,
Mostafa
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, reads and updates could occur concurrent
 
A day job? In an office? My worst nightmare! Comfort me tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic