• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Singalton in distributed env

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please share view or link for some information about
Singalton in distributed env, someone asked me about this and I had no anwer.
I know Singalton, and would like to knwo if it is possible to implement Singalton in distributed env.
If yes, please drop few lines or link for same.

Thanks.

Posting same quest 3rd time, hopefuly won't get invisible because of new software.

 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Singleton pattern is not an effective object-oriented design pattern and is rarely appropriate in a distributed environment. Surely, it can be implemented but would typically become a potential bottleneck in an enterprise software system. Moreover, there are usually more effective ways to design an application without a Singleton.

Singleton is an easy thing to teach and is very simple. So, this is typically the main pattern taught in academic programs by professors who have very little practical experience in object-oriented software design.

Singletons should be avoided in object-oriented software systems. This is true whether they are used in a distributed environment or executed in an application on a single machine.
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Deepika Joshi wrote:
I know Singalton, and would like to knwo if it is possible to implement Singalton in distributed env.


It's not impossible, but do you really want it?
Machine A can have a singleton object SingA, and other machines can get remote proxy of SingA.
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not to mention he's glossing over the fault tolerance logic you have to write.
When server A goes down, who claims the resource and how will the other servers know?

You do need this from time to time, but it's really a solution of last resort.

Anyway, the short answer is you can't because you have multiple JVMs & classloaders.
Maybe there's some custom JVM out there we you can, but this certainly wouldn't be standard.

 
Ranch Hand
Posts: 449
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Distributed environments, we usually have multiple VMs running, whereas the singleton pattern normally implemented is a per-VM singleton.
 
Deepika Joshi
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to all of you for your response.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are welcome!
 
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic