Originally posted by shanmugam soundrapandian:
how to do lock method with client ID using RMI. i have finished lock method without client ID.most recent threads are talking about client ID.
can you please kindly help me how to find Client ID and what is the use of that?
regards
soundar
I would also like to know this too. I have seen recent posts of people using Client ID successfully, but they were not using RMI. Some people were saying that they were placing the
thread object in their locking array and using that to compare it with the person who is trying to do the unlock. But I have also read in other threads where it is not guaranteed that the client will use the same connection.
My instructions are "If an attempt is made to unlock a record that has not been locked by this connection, then no action is to be taken".
Thinking about this again, I implemented a singleton class to contain a list of all the locks (in a syncronized HashMap), what if I also maintained another list of locks that this connection has? I think that is what I will do.
Ok, so I will be maintaining one global list in a singleton class containing a list of all locks, and a list for each client that lists their current locks. Then when unlock is called, I will first look in the client's personal list to see is they locked it before allowing them to unlock the global one. Since my instructions clearly state that it must occur within the same connection.
The caveat is, if the client dies before calling unlock, then the record will remain locked. I think that I might put a "time to expire" value in my global list. So that if a client dies, then eventually it will be unlocked by the first client that wishes to lock the file after the time out period.
Does this make sense?