• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

clustered environment - Singleton class

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the clustered environment, how Singleton class behaves ?
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://forum.java.sun.com/thread.jspa?messageID=3415654
 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps, another way to do this is to designate a server within a cluster to host the singleton instance. Other servers contains just a remote proxy which access the singleton on this server. Synchronization is taken care in a single JVM.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you describe your requirements a bit more? A lot of times a single instance per JVM is fine. For example, we cache some things we get from the database. Each server has its own cache, no problem.

In one case we have to synchronize the caches so all machines have the same content. The vendor framework uses JMS pub-sub to let all machines know about changes. I gotta ask them some day how they handle a machine that joins the cluster late, like maybe we crash and restart one.

If you really, truly require one instance per cluster you'll have to get into some kind of distributed stuff, worry about a hot standby in case the one machine in the cluster that has the single instance goes away. I'd be tempted to use a database for any state with those requirements.
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic