I have an application which uses several HA Singleton MBeans. It is working well when
running as a single node cluster. But when I run it on additional nodes I can't
locate the singleton MBeans. It seems that the singleton MBeans are only registered
with the MBeanServer on the initial node, and so the components which run on other
nodes can't find a MBeanServer which has the singleton Mbeans registered, and hence
can't access the required singleton MBean operations. Without these my application is
hosed and can't run in a cluster.
Below is example code which is accessing one of my singleton MBeans. It works fine in
Servlets and EJBs running on the first node, but not at all on any other nodes.
| // get a list of MBeanServers
| ArrayList mbeanServers = MBeanServerFactory.findMBeanServer(null);
|
| // find the correct MBeanServer to use for accessing the singleton
MBean
| MBeanServer mbeanServer = null;
| for (int i = 0; i < mbeanServers.size(); i++)
| {
| // see if this MBeanServer has the MBean registered
| if (((MBeanServer) mbeanServers.get(i)).isRegistered(new
ObjectName("grover.mbean:service=AllUserInfo")))
| {
| // make this the MBeanServer
| mbeanServer = (MBeanServer) mbeanServers.get(i);
|
| // break out of the loop
| break;
| }
| }
|
| if (mbeanServer != null)
| {
| // find out if the user is already in te table or not
| Boolean userInTable = (Boolean) mbeanServer.invoke(new
ObjectName("grover.mbean:service=AllUserInfo"),
| "isUserInTable",
| new
Object[]{loginId},
| new
String[]{"java.lang.String"});
|
| // if the user is in the table already then get their info
| if (userInTable.booleanValue())
| {
| // get the pre-existing user's information
| userInfo = (UserInfo) mbeanServer.invoke(new
ObjectName("grover.mbean:service=AllUserInfo"),
| "getUserInfo",
| new Object[]{loginId},
| new
String[]{"java.lang.String"});
| }
| else
| {
| // create and populate a new user information object
| userInfo = new UserInfo();
| userInfo.setLoginTime(Calendar.getInstance());
| userInfo.setUserId(loginId);
| userInfo.setUserType(0); // 0 = HIM, 1 = WEB
|
| // add this user's info to the table
| mbeanServer.invoke(new
ObjectName("grover.mbean:service=AllUserInfo"),
| "addUserInfo",
| new Object[]{userInfo},
| new
String[]{"com.hsp.grover.util.UserInfo"});
| }
| }
| else
| {
| // log the error
| m_logger.error("Unable to find an MBeanServer with a registered
AllUserInfo singleton MBean");
|
| // throw an exception
| throw new ServletException("Unable to find an MBeanServer with a
registered AllUserInfo singleton MBean");
| }
|
I put in the search for an MBeanServer where the MBean is registered but it doesn't
seem to do any good since the only MBeanServer found is the one available locally and
not the total number of MBeanServers available on the cluster, which is what I was
after.
How then does one go about this ? Should I do some sort of JNDI registration in the
singleton MBeans' startSingleton() methods and lookup the MBeans with JNDI instead of
using the MBeanServer.invoke() method of accessing the MBeans' operations ?
Thanks in advance for any help.
--James
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3851969#3851969
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3851969
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user