File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes clustered environment - Singleton class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "clustered environment - Singleton class" Watch "clustered environment - Singleton class" New topic

clustered environment - Singleton class

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1432
In the clustered environment, how Singleton class behaves ?
Prasanna Ram Rambhatla

Joined: Jul 07, 2005
Posts: 10
vu lee
Ranch Hand

Joined: Apr 19, 2005
Posts: 195
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.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: clustered environment - Singleton class
It's not a secret anymore!