• 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

44 points for locking, any thoughts on why?

 
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing that comes to mind for me is bit in the instructions that state at most only one program is accessing the database.
I used that assumption to my advantage when I, I'd like to think, ensured my application is threadsafe. What I didn't do is ensure that it's not possible for multiple clients to access the database, by clients I mean database clients not gui clients.
So you're running a server, and start a client in local mode accessing the same database, what behaviour can you expect? Do you allow a 2nd client to connect?
According to my instructions I shouldn't have to worry about that, but perhaps it's expected that we cater for it in some way or another such as opening the file exclusively and throwing the exception when it's open.
Has anyone actually scored 100% without catering for this scenario? Because that would rule out this possibility.
[ August 17, 2005: Message edited by: Ta Ri Ki Sun ]
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi TQ,

Have you looked at the topic "The Mysterious 44/80 Locking score"?

One of the potential areas for problems are candidates not handling deletions correctly - that is what happens to client B following these events:
  • Client A locks record 5
  • Client B attempts to lock record 5 - must wait
  • Client A deletes record 5
  • Assuming you have somehow handled that, can you take it one step further (add Client C locking record 5 between steps 2 and 3)?

    Regards, Andrew
     
    Ta Ri Ki Sun
    Ranch Hand
    Posts: 442
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks Andrew, I missed that thread.
    I'll check again sometime whether I actually had all bases covered as I thought I did.
     
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi all,
    I'm still worried about the marking of Thead-safety policy: I've read some threads here in javaranch and I allow myself to submit the template I currently use in my code.

    Obv., I adopts the DBAdaapter pattern and so no. Each time I refer to the Data instance I do something like this:



    This template ensures that each time a lock() is called, its unlock() will be called at the end of the method, whatever the exceptions raised from within the try block (which are also declared in DBAdapter method signature).

    Of course, there could be some issues if either lock or (specially) unlock would raise some exceptions, but I simplified these methods in Data to remove the RecordNotFoundException declaration, since this will be raised from other calls to Data methods (e.g.: data.read(recNo)): this allows the locking of a new recNo, for example.

    I'd appreciate any comments about this template.

    Thanks guys.
    DM
     
    Andrew Monkhouse
    author and jackaroo
    Posts: 12200
    280
    Mac IntelliJ IDE Firefox Browser Oracle C++ Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Danny,

    This sounds like it is only tangentially related to TQ's original question, so you might be better off raising it in a new topic - you may get more responses (as you can see, there were not many responses in this particular topic).

    I presume that the try...finally block is operating on the server - is that correct?

    I simplified these methods in Data to remove the RecordNotFoundException declaration

    I'm misunderstanding this somehow. I believe that if you do that, you cannot implement the interface that Sun gave you, which I understand will cause instantaneous failure.

    Regards, Andrew
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic