3 Replies Latest reply on Sep 29, 2003 8:49 PM by juha

    JMX Instrumentation - Help Please

    ravisshankar

      I am building a JMXService which acts as a generic agent and uses ModelMBeanInfo object generated through XMLPreferences to register the managed objects in MBEanServer. I have to make a design which is Appserver neutral & should work when JSR 77 is not supported completely/ supports partially in an appserver.

      Here, I have couple of question -

      Lets say a class named a.b.c.JCAConnection.class need to be managed you have management attributes,operations defined in this and in xml you have metadata defined about this class, my JMXService takes care of Creating / caching the ModelMbeanInfo object and reusing by cloning it for different objects of the same instance.

      1) I am Trying an example where a connector application running in a non-managed environment should be manageable. I am not sure whether I am doing in the right way. A better suggestion is much appreciated.

      JCAManagedConnectionFactory implements javax.resource.spi.ManagedConnectionFactory-> JCAManagedConnection implements ManagedConnection->1:1->JCAClient ->1:* -> JCAConnection

      JCACLient forms a pool of JCAConnection when the ConnectionFactory/JCACLient initializes. Now to register my connectin objects as managed objects in the MBeanServer for stats/operations from any client(thru RMI,HTTP) I register that something like this in JCAClient -

      for (int i=0;i<poolsize;i++) {

      JmxService.registerMBean("name=connection."+i+",type=Client");
      }
      }... that is a piece of code . Its something like that.

      Now as you can see I am changing the JCACLient to register the connection object with the MBEanServer.

      Is there a better design that somebody can suggest without touching the actual code but making the JCA objects managed?

      2) When an appserver supports JSR 77 can the JCA implementations become automatically managed though any of the connectors? Here how does the Server intelligently choose the objectname for same objects of same classes(in case of modelmbean)

      3) If I representing my mbeans though a JSP and making the JSP query the mbeanserver and do the operation and retrive info/ values about MBean(s), How do I group the mbeans related to the connector object that I mentioned earlier, can I query based on *,type=Client,*..?


      Eager to hear from somebody who can say I am wrong.. you can do better this way :-)

      Thanks,
      Ravi.

        • 1. Re: JMX Instrumentation - Help Please

          &gt; 2) When an appserver supports JSR 77 can the JCA
          &gt; implementations become automatically managed though
          &gt; any of the connectors? Here how does the Server
          &gt; intelligently choose the objectname for same objects
          &gt; of same classes(in case of modelmbean)

          Check the JSR-77 spec, it should define a naming convention for the managed resources it exposes. This naming convention should be such that it guarantees unique names for connectors.

          &gt; 3) If I representing my mbeans though a JSP and
          &gt; making the JSP query the mbeanserver and do the
          &gt; operation and retrive info/ values about MBean(s),
          &gt; How do I group the mbeans related to the connector
          &gt; object that I mentioned earlier, can I query based on
          &gt; *,type=Client,*..?

          You can query based on an object name pattern. However, the patterns supported are pretty limited in at least JMX 1.0 and 1.1 specifications.

          For more specific queries it is better idea to query based on the MBean attribute values rather than its object names (or a combination of the two).

          -- Juha


          • 2. Re: JMX Instrumentation - Help Please
            ravisshankar

            Thanks Juha, I read your book in safari, oreilly's online site. It was of great help and very good book.

            on my question # 1, I am not sure whether I explained what I wanted to. I am trying to make a connector which is running in a non- managed environment (appserver doesnot maintain the connections,but handled by the user defined objects) administered thru JMX.

            So in this case what I am doing is - I have a registerMBean method in my JMXservice which takes care of creating a RequiredMOdelMBEan with the managed resource set as the connection object like


            TniClient.java -
            ..
            for (int i = 0; i < numOfConnections; i++) {
            connections = new TniConnection(this, i, metaData);
            connections
            .connect();
            JmxService jmxService = (JmxService) ServiceFactory.getManager().getService("service.core.JmxManagementService");
            jmxService.registerMBean("name=MXClient.connection." + i + ",type=connector", connections);
            }
            ..
            Basically my service acts like an agent to create MBeanInfo,register,etc. I use preference to create my ModelMBeanInfo object.

            Is there a better way in which I can avoid changing the connector code but make it managable by JMX. i.e. how can I make the individual connections manageable when I dont register the individual connection objects with the MBEanServer with different object names (I am not sure whether I am right or wrong making this statement) incase the server doesnot support JSR 77 or JMX (Only I introduce JMX in my application)?

            On Question #2 I understand that the server gives a different names for different connectors in an appserver. But inside each connector if I have connection objects like the one that I have stated above. How does the server take care of that?

            Please solve my problems, I am trying to understand wht I can do with JMX & JSR 77.

            Thanks Again,
            Ravi.

            • 3. Re: JMX Instrumentation - Help Please

              There isn't a very good solution to this, it is a same issue as with trying to expose different threads to management. At some point there was a discussion of adding something called 'virtual mbeans' to the spec to address this but I cannot remember what happened with that.

              The best you can do is register a manager (connectionmanager) that exposes a collection of connections to management or try to create scheme where you dynamically create an mbean per request for a single connection instance.

              -- Juha