Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple servers

 
Jonathan Pengelly
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I have been thinking about what my system should do if a server instance is created and then someone attempts to create a second server instance. I am worried because I have implemented my data class as a singleton and I keep thinking about problems with starting one server, stopping another and things like that. I don't know if this is even an issue but it is giving me a headache and I can't seem to clear it up in my mind.
Does anyone have any opinions on this? Is this an issue?
Jonathan
 
Xie Ruchang
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here my logic,
One server can only bind to one port. So the second server will not be successful because the port is already bind! If you are using ServerSocket.
If you are using RMI, you have to rebind the name to the registry, and back to the same point of having one instance at the registry. So there is no issue. If someone deliberately binds to another name, the client has to know the name to connect. This is beyond the concerns of the developer.
Having one instance of a class running doesn't mean you must have a Singleton design pattern. Implementing Singleton unnecessary may have impact on scalability.
2 cents and Best Regards
[ January 29, 2004: Message edited by: Frankie Cha ]
 
Jonathan Pengelly
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frankie,
Thanks for the reply.
I am using RMI and bind my Server object in the registry. However, this object contains an instance of the Data class. Thus, my worry about how to build this Data object. I used to think that this class should be a singleton however I am not so sure now because imagine if two different servers were started. How would I have to initialise the data instance?
Any further comments from anyone?
Jonathan
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jonathan,
Your singleton instance is unique inside a given JVM. So if you start two servers, you'll get two separate instances, instantiated in two separate JVM's heaps.
Regards,
Phil.
 
Jonathan Pengelly
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Phil,
Thanks heaps. I really didn't think that one through enough and probably didn't understand things quite right, but I was really confused and worrying about it, so thanks for clearing it up for me.
Cheers,
Jonathan
 
Stephen Galbraith
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
doesn't your instructions say something like
You may assume that at any moment, at most one program is accessing the database

...only needs to be concerned with multiple concurrent clients of your server

?
Hence,
...system should do if a server instance is created and then someone attempts to create a second server instance.
can assume that this situation will never happen (if that's what your instructions say).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic