File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S 2.3.1 locking in non-netwok mode?

 
Michael Donley
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody!

I have just got the assignment and found this nice forum with all you discussions regarding the SJCD exam! Nice that all of you are assisting each other! Hope someone can help me with my questions.

The first thing that crossed my mind was locking in non-network mode? Can one assume that 1, and only, 1 client is assessing the DB file when they run in the same WM (i.e. no networking)? If that�s the case, no locking should be used when reading and updating the DB file, right?

Thanks in advace!
TM
 
Jethro Borsje
Ranch Hand
Posts: 100
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the 2.2.1 version of the B&S assignment, this assignment says the following on "Locking":
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above. You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server. Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available.


However, locking the data should not be a problem when you use the client / server in one JVM at the same time.
 
Michael Donley
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jethro for your answer!

I got the same description as you, but I still don�t get it. I think the sentence is misleading

"...You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server..."

What does it mean?

I mean "... at MOST one program is accessing...", what does that mean? MOST???

My plan was to ignore any locking mechanism when running in "non-network mode". I.e. The Gui is accessing some service methods which are not doing any locking (the service methods access the DBMain). I will also have service methods which accessing the DBMain in network mode but these will use locking.

So, can my system access the db methods (in DBMain) via my nonlocking service methods? That is, can I assume the non-network mode consists of only 1 client?

Thanks in advance!
TM
 
Jethro Borsje
Ranch Hand
Posts: 100
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can assume such a thing, but why would you want to do that? I mean: you might as well let the client use the "normal" locking code, because this should work fine. Locking should have no consequences when you are using just one client at a time.
 
Michael Donley
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess your right. The reason why I asked was because I did not want use locking mechanism when there is no need for it. I thought this approach is cleaner... I mean why use locking when there is no need for it... But just as you said, it does not do any harm so the same code can be used....

Thanks for you answer!
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12024
25
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"The Man",

You apparently missed our Naming Policy on the way in. Please read that page, then follow the link there to change your screen name.

Thanks
 
Michael Donley
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger: Im sorry for my name, I have changed it now...
 
Alenkhe David
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is locking in non-network mode a most? I, mean its only one JVM.
 
Jethro Borsje
Ranch Hand
Posts: 100
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not a must, but I think it is bad practice to try to avoid the locking as it should be part of you data access layer. This data access layer should be used by your client, regardless of networked or non-networked mode.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic