Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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

Clustering environment in WAS

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone clarify on following doubts:
How singleton objects are managed in clustered environment?
What does thread safe code implies in clustered environment?

Rajesh Godbole
 
author & internet detective
Posts: 41073
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rajesh,
The "singleton" is one per JVM (one per cluster.)

Similarly for thread safe, you get one set of static variables per cluster. You have to make sure the singleton/thread resources aren't controlling access to anything external. Otherwise you could have two accessing, say the database, at the same time.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeanne Boyarsky:
Rajesh,
The "singleton" is one per JVM (one per cluster.)



I'm not quite sure what you're getting at there, Jeanne. If you take a standard application (not built for clustering) that uses the singleton pattern and then deploy it in a clustered environment, then you will get one singleton per JVM, which means many per cluster. That's generally a recipe for disaster...

Could you clarify what you mean?

Kyle
 
Jeanne Boyarsky
author & internet detective
Posts: 41073
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kyle Brown:
I'm not quite sure what you're getting at there, Jeanne. If you take a standard application (not built for clustering) that uses the singleton pattern and then deploy it in a clustered environment, then you will get one singleton per JVM, which means many per cluster.


I actually meant to say one per clone, not one per cluster. Doh! So if there are two horizontal clones and two vertical clones, there are four copies of the "singleton." Right?


That's generally a recipe for disaster...


I agree!
 
Villains always have antidotes. They're funny that way. Here's an antidote disguised as a 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