• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

add, modify and delete in data class

 
Rudy Yeung
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the specification, we only need to implement the flight booking, meaning that we need to apply a write lock to the modify method provided in the data class. As the specification does not mention that we need to implement the adding and deletion, I think we just leave the add and delete methods as they are. However, I understand that these two methods also require a write lock or else the database may be corrupted. Do we really to take care of the add and delete methods in terms of locking and unlocking?
 
Sam Wong
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My opinion is that it wouldn't negatively affect your grade regardless of whether you support add/delete. Perhaps, someone who has completed their SCJD can shed some light on this.
Sam
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it's true that you will probably need lock and unlock for add and delete methods. But they are not needed for the assignment, at least not for my requirement.
Besides, if you need to implement add, delete functionalities, you should add a method similar to booking, and let that emthod call the lock and unlock.
 
Rudy Yeung
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adrian and Sam,
If that is the case, you apply a collection API, say the hash table, only to the modify() method, but not the add() and delete() methods. The hash table is for keeping trach the lock and unlock state of the records. Is that true to you?
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I use similar technique.
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see that the add/delete methods seems more like an administration tool as far as this application is concerened more than a real tool. However, I see that after adding/deleting a record, the record count is not increased or decreased by 1. It seems to be the one that is used at startup. A bit strange.
In a future scenario, User A requests lock on DB, User B request lock on DB, User C requests lock on DB. Lets assume that the locks will be served in the order A, B,C . A and C seek to modify the database while B is going to remove the same very record. How is the database going to handle this scenario???
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't touch add or delete. I think it was there for the older version of the assignment when you had to create a conversion program to put a text file of data into the db.db file.
I did not lose any points for not touching it.
Mark
 
Rudy Yeung
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kalichar,
Vow!! You replied my mail that was posted almost a year ago. Referring to the scenario you mention, I think it will never happen if your locking mechanism is in a synchronized block or method. In this way, only one client can be granted the lock and have the only access to the database or record locked at any time.
Good luck,
Rudy
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do understand that but what I am referring to is A gets lock does modification and unlocks, B gets lock does modification, releases lock, C gets lock modify??? The record it is searching for is gone, the record count is not updated...whats up....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic