• 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

how can I know client died from server class??

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can I know client died from server class??
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ilwyvd illtvd:
how can I know client died from server class??


Immplement the unreferenced interface ,which has a method that u need to implement for ur unlocking of unlocked records of crashed clients.
VikasSood
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vikas,
I did a test and found unferenced method only would be called when there were no client connection.If one client lock a record and down without unlock and another client want to lock the same one, but it would be blocked.And because there is one clinet connection exist, unreferenced method would be called.Then the client will always wait.How to slove this problem?Somebody can give me a hint?
 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Daniel,
You are right about the blocking. Since you are not allowed to change the wait time from 15 mins to say 1 min via command line parameters, I suggest you look in to writing cleanup thread which you have full control in the server. Also it is not required for you to implement the cleanup thread to pass the exam. Simple implementing Unreferenced() is good enough.
 
Daniel Chen
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sai,
Thank you for your reply.And I have another question.I found many topic said to use a hashset/hashmap to store record number as key and clientid as value.However I only used a Vector to store record number.What is the diffient?Why store a clientid, how to get the unique clientid and what is the advantage of this solution?
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Daniel,
When you design your server side, you need to make sure no updates are made on a stale data from any client. Also you need to take care of multiple clients trying to update the record at the exact same moment of time. You need to infer these requirements from the Sun documentation. Cleary you have to identify the clients in the server side with respect to the row being locked.
Think about this scenario:
1) Client A locks record 10 for update
2) Client B now tries to lock record 10 for update
At this time, you need to ask client B to wait until Client A releases the lock on the record 10. You can achieve this using a LockManager class which doesn't have to extend any other class. The Data remote class can associate itself to this LockManager. It is the responsibility of the LockManager to handle concurrency. Hope that helps.
 
Vikas Sood
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Daniel,

Originally posted by Sai Prasad:
Daniel,
You are right about the blocking. Since you are not allowed to change the wait time from 15 mins to say 1 min via command line parameters, I suggest you look in to writing cleanup thread which you have full control in the server. Also it is not required for you to implement the cleanup thread to pass the exam. Simple implementing Unreferenced() is good enough.


I also agree with Sai that when u are implementing unreferenced u are not required to implement any clean up thread(This is not required or can be said is beyond the scope of this assignment.)
VikasSood
 
Daniel Chen
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sai & Vikas,
Yes I implement the unreference method to unlock whole db.But I only used a Vector to store reocrd number that is locked without store client id.I don't know why many do it.I found some article said when call unlock method, they would compare the client id want to unlock the record to stored in hashmap's client id.If they are not same, do nothing.And I cannot think out any else advantage than using a Vector only store record number.Is it right?
If I am right, I doubt the worthty to do.When a client unlock the record that it isn't locked by itself?I don't think it will happen in my design.
If I am wrong, anything else I missed?
 
Vikas Sood
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Originally posted by Daniel Chen:
Hi Sai & Vikas,
Yes I implement the unreference method to unlock whole db.But I only used a Vector to store reocrd number that is locked without store client id.I don't know why many do it.I found some article said when call unlock method, they would compare the client id want to unlock the record to stored in hashmap's client id.If they are not same, do nothing.And I cannot think out any else advantage than using a Vector only store record number.Is it right?
If I am right, I doubt the worthty to do.When a client unlock the record that it isn't locked by itself?I don't think it will happen in my design.
If I am wrong, anything else I missed?



I cant tell u much this way,untill u explain how u are doing ur locking.As much as i have understood from the specs and the various discussions i have had is that a client locking a record should be the one unlocking it.For having an insight to how i have done it check out my thread about locking Design by the name of
My lock Design!
I have used a clientid to represent a client asking for a lock.
Hope it helps
VikasSood
 
ilwyvd illtvd
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my server provide different remote object including unreferenced method to different client. when one client crash,the associated remote object would invoke the unreferenced method to search the hashtable to remove all
the record with the remote object,by the way
in my lock/unlock method ,I use record as key
remoteobject as value
 
His brain is the size of a cherry pit! About the size of this ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic