• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Client id in locking

 
Pawel Poltorak
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I've been reading through posts today and I have some doubts about my implementation of locking. I assumed that thread id is enough to identify the client. However, RMI does not guarantee that every client will have a separate thread assigned. On the other hand all locking I have is in the book() method in business layer, in which I use Data class in lock - read - update - unlock manner.

I'm wondering if this is valid. book() is a single remote method, so RMI should process it without thread switching.

Best regards,
Pawel
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pawel,

You are correct - the same thread should be used within an individual call to a remote method. You should make note in both your design decisions document and in your implementation comments (and probably in Data's Javadoc comments) that it relies on the lock, update, and unlock methods all being run within the one method call on the server.

Regards, Andrew
 
Pawel Poltorak
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Andrew.

I've been thinking about client id for a few days and I am planning to change my approach to Data class instance for every client. I think it may be better solution, since in my assignment I don't have cookies, and thread id is not a best way to identify client.

Best Wishes,
Pawel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic