users@glassfish.java.net

Access cluster info from within EJB

From: <glassfish_at_javadesktop.org>
Date: Sun, 22 Feb 2009 02:48:05 PST

How do I access infomation about what cluster instance is running the ejb code?

I have code inside an ejb and I want the execution to be tailored depening on what cluster instance is running the code. I also need to know the total number of cluster instances.

My use case is something like the following:
I have a pile of work to be done by an ejb which is deployed to several cluster instances. I want to divide the work between the instances, e.g. the first 20% of work to the first instance and the following 20% to the second instance and so on. This means that I need to know the total number of instances in the cluster and also the index of the instance running the code, i.e. dynamically retrieving the information from within the code.

Is this possible? How do I do it?
[Message sent by forum member 'nilsedvardsson' (nilsedvardsson)]

http://forums.java.net/jive/thread.jspa?messageID=333237