4 Replies Latest reply on May 23, 2005 1:30 PM by paul_zm

    Requesting data from multiple servers using JMX, all give sa

    paul_zm

      We hava a small farm of servers running JBoss 4.0.1. On a certain webpage we can see how many active sessions are running on each server. Since we upgraded from JBoss 3.0.8 to 4.0.1 all servers report the same amount of sessions.

      If I run the following code from the command line all works perfectly. But if I run (roughly) the same code in a servlet or strutsaction all servers report the same amount of sessions. Does JBoss cache the RMIAdaptor? What am I doing wrong?

      public class JMXBrowser
      {
      
       public static InitialContext getContext(String serverUrl)throws NamingException
       {
       Properties props = new Properties();
       props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
       props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
       props.put(Context.PROVIDER_URL, serverUrl);
       InitialContext ic = new InitialContext(props);
       return ic;
       }
      
       /**
       * @param args the command line arguments
       */
       public static void main(String[] args) throws Exception
       {
       String[] servers = new String[2];
       servers[0] = "10.241.13.72:1099";
       servers[1] = "10.241.13.69:1099";
      
       for (int i=0; i < servers.length; i++)
       {
       InitialContext ctx = getContext(servers[ i ]);
       RMIAdaptor adaptor = (RMIAdaptor) ctx.lookup("jmx/invoker/RMIAdaptor");
       Integer count = (Integer) adaptor.getAttribute(new ObjectName("plato:service=WebAppService"), "ActiveHttpSessionCount");
       System.out.println("Server " + servers[ i ] + ": #sessions: " + count);
       }
       }
      }


        • 1. Re: Requesting data from multiple servers using JMX, all giv
          starksm64

          Its probably this optimization bug:
          http://jira.jboss.com/jira/browse/JBAS-1442

          There are workarounds described there.

          • 2. Re: Requesting data from multiple servers using JMX, all giv
            paul_zm

            I tried to use the workaround suggested bij Adrian to replace the InvokerInterceptor with the 4.0.0 version.

            The first problem I got was a NullpointerException when it tries to do: returnValue = localInvoker.invoke(invocation);
            I've put a breakpoint on the setLocal method but it never gets called? So the localInvoker object stays null.

            So I did some extra debugging and for testing purposes I made the "isLocal" method always return false so that the invoke method would always do it the remote way. Then I don't get any exceptions but I still get the same results from all servers.

            Renaming the services on all servers isn't really an option. Any other tips I could try?

            • 3. Re: Requesting data from multiple servers using JMX, all giv
              bdymek

              Warning: not sure if this applies to your version of JBoss.

              I have encountered a similar problem with the InvokerInterceptor in JBoss 3.2.7 when attempting to use JMX between 2 instances of JBoss, without clustering.

              After looking at the 3.2.7 source code, I was able to resolve the issue by commenting out the LocalInvoker in the conf/jboss-service.xml server config. (This blocks the setting of the static local invoker inside of the 3.2.7 InvokerIncerceptor.) This workaround can be used if you really do not wish to write or modify standard code. However, all JMX activity will use the RMIAdaptor (in my case), even if it exists locally on the same JVM, so you may take a performance hit.

              [omitted discussion: various isLocal() implementations, Registry (really, a registry), etc. :) ]

              Use with caution. Not sure what effects this may have on other HA components running in the same instance, so beware of this minor config change if problems occur, etc.

              • 4. Re: Requesting data from multiple servers using JMX, all giv
                paul_zm

                Yes, I also considered that option but we use mbeans very intensively so that wasn't an option. I finally solved my problem by implementing a webservice wrapper.