• 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

do we really need to trace lock owner in URLyBird1.3.3

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everyone:
I have read a lot posts in this forum, I know many of you use cookie or data connection object to trace the lock owner to avoid records unlocking by other client which not lock this record.
But I also know in many exam documents have the requirement to ask the developer to do this , such as it ask developer to use cookie to trace the owner, or it ask developer to ignore the unlock action if the client is not the lock owner.

But in my exam requirement , there is no any sentence to ask me to do this thing like above.

following is the lock section of my exam doc:

// Locks a record so that it can only be updated or deleted by this client.
// If the specified record is already locked, the current thread gives up
// the CPU and consumes no CPU cycles until the record is unlocked.
public void lock(int recNo) throws RecordNotFoundException;
// Releases the lock on a record.
public void unlock(int recNo) throws RecordNotFoundException;
// Determines if a record is currenly locked. Returns true if the
// record is locked, false otherwise.
public boolean isLocked(int recNo)


you can see there is no comments to ask me to trace the lock owner or distinguish the lock owner.
especially, I'm going to use 3 tier design, the client can't call lock or unlock method directly, it can only call the book(), or find() method through connection object in server side. And the lock and unlock must be called in same function together.
If I use above design , do you still think I should trace the owner? do you think clients still have the possibility to unlock a record which not be locked by it.

any suggestion? thank you very much.
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hallo,
I am in the same boat with you.

IMO you just make some serious assumption here - you presume that the clients will use the same logic, always. Maybe in the future the user decide to keep the backend and to change the frontend - if in your solution (logic/metodoligy) is not posible that one user release the record from an other maybe in other situation context is posible -and this can lead to ....

I have also a question to you, how you solve the unique client id ?

Record, Mihai
 
Wayne John
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for solving "unique client id" , you can use connection factory to create remote connection object for each client, and each connection object has their own data object(it's unique) , you can use data object to trace the lock.

but I think in urlybird1.3.3 , we don't need to use unique id to trace lock owner.
 
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 Wayne,

following is the lock section of my exam doc:

// Locks a record so that it can only be updated or deleted by this client.
// If the specified record is already locked, the current thread gives up
// the CPU and consumes no CPU cycles until the record is unlocked.
public void lock(int recNo) throws RecordNotFoundException;

you can see there is no comments to ask me to trace the lock owner or distinguish the lock owner.



Those bits that I have italicized & put into bold font make me believe that your Data class does need to track lock ownership.

Your server application may not need it, but not tracking lock owners means that you will not be implementing the specified interface - you will be implementing the parts of it that fit your server design.

In the real world, some other programmer could be simultaneously writing a program that needed to use your Data class and was relying on the locking working as specified - in which case, when they finally get your Data class they will find that their code may not work as expected.

Regards, Andrew
 
Wayne John
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Andrew:
thank you for your explanation!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic