• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about RMI

 
Sam Stackly
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
How can I get the number of current user connected to Remote Component?

Thanks
Sam
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't track the number of clients using any of the "out of the box" rmi functionality provided with the JDK. You could build something from scratch, but that may be over-doing it for this project.
Maybe if you explain your design and what you are trying to do in more detail, someone will come up with a solution to your problem.
 
Sam Stackly
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my ServerGUI I have a label as a status bar and I like to show how many User are connected ,
I thought may be I could get the number of them from RMI somehow, but guess I have to build it,
Thanks
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't put too much work into this. Many folks have earned outstanding scores without a server gui.
Keep it as simple as possible, and focus your efforts on meeting the requirements.
If you want to do this, I have some ideas but they will vary depending on your server design.
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sam Stackly:
Hi Guys,
How can I get the number of current user connected to Remote Component?

Thanks
Sam

Hi Sam,
If you provide a factory the produces RMI object for each client, then it could provide exactly what you're looking for by keeping track of each request. I explain the factory concept in some detail towards the end of this thread.
HTH,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
 
Sam Stackly
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks but I guess you are right , I am gonna pass this!!!
Sam
 
Sam Stackly
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Max,
I know how to count the number of user who requested connection from connection factory , but what about when they finished their job and left? How can I trace them?
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have the ConnectionFactory maintain a reference to a ConnectionManager whose responsibility is to track the number of connections given out. Clients have to explicitly signal when they are done and you can use Unreferenced to track crashed clients.
 
Sam Stackly
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I undrestand a remote object implementation should implement the Unreferenced interface to receive notification when there are no more clients that reference that remote object.
but this is gonna be not usefull if one client crash so...?? there should be other way , I guess
Sam
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sam -
Its not perfect, but unreferenced() will eventually be called in the case of a crashed client depending on what you have java.rmi.dgc.leaseValue set to.
It is trivial when the client finsishes normally, because you have some control and can call the right methods but when a client crashes it is a different story.
I think that creating your own mechanism beyond Unreferenced for detecting crashed clients is way beyond the scope of this assignment. I would just rely on signalling the "ConnectionManager" whenever a Connection is given out or whenever a client is done with a connection. It can keep a tally of active Connections, and if you adjust java.rmi.dgc.leaseValue to a lower value you can also have reasonable, but not perfect, tracking for crashed clients also. If you change java.rmi.dgc.leaseValue make sure you set checkInterval to half of whatever java.rmi.dgc.leaseValue is. Read up on java.rmi.dgc.leaseValue before tweaking it so you understand the consequencesof setting it very low.
[ July 28, 2002: Message edited by: BJ Grau ]
 
Sam Stackly
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks BJ,
It was far away from my knowledge of java and RMI , since I was working on MS Platform in my career , well I geuss you are right, it's really far from our assignment
Thanks anyway
Sam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic