10 Replies Latest reply on Nov 25, 2008 8:59 AM by alesj

    BeanMetaData and management

    bob.mcwhirter

      So, for the JBoss Rails deployers, I've taked the advice of Ales and Adrian, hopefully correctly, and am now deploying BeanMetaData instead of doing actual work in my deployers, where possible.

      The BMD I'm returning are my "deployments" (is that the correct term?) that represents the actual running object. A Rails app. A set of scheduler tasks.

      MC instantiates them and calls start(), everything is happy, and I've replaced a ServiceMetaData.

      http://github.com/bobmcwhirter/jboss-rails/tree/master/src%2Fmain%2Fjava%2Forg%2Fjboss%2Frails%2Fcore%2Fdeployers%2FRailsAppDeployer.java

      But I've lost my visibility of my rails app deployment in the jmx-console.

      I've attempted to add @JMX annotations, but got either a mixture of "nothing" or "already installed" errors.

      I also tried to gain a clue about Scott's @ManagementObject/ManagedObject stuff, but also never got anything visible in the jmx-console.

      Should I be looking for some other console (JOPR-embedded?), or is there some way to wire things up to automatically appear in JMX consoles?

      Thanks!

      -Bob

        • 1. Re: BeanMetaData and management
          alesj

           

          "bob.mcwhirter" wrote:

          I've attempted to add @JMX annotations, but got either a mixture of "nothing" or "already installed" errors.

          This should work.
          I don't see how you can get "nothing".
          Or what are the exact "already installed" errors?
          As mbean's ObjectName is derived from bean name,
          hence it should be unique if your bean name is unique.

          "bob.mcwhirter" wrote:

          I also tried to gain a clue about Scott's @ManagementObject/ManagedObject stuff, but also never got anything visible in the jmx-console.

          Currently you only get this visibility in ProfileService (PS).
          Then some admin console needs to use PS to show content.

          "bob.mcwhirter" wrote:

          Should I be looking for some other console (JOPR-embedded?), or is there some way to wire things up to automatically appear in JMX consoles?

          Yes, jopr/embedded is probably the only admin console that somehow knows PS,
          but even this is not yet fully implemented.
          We still have some issues in Managed/Metatype MC sub-project,
          PS attachment/MO serialization and jopr/embedded generic plugins.

          I would look into why @JMX doesn't work for you,
          as that's the easiest way to wire things up.

          • 2. Re: BeanMetaData and management
            alesj

             

            "bob.mcwhirter" wrote:
            or is there some way to wire things up to automatically appear in JMX consoles?

            And you can even add @JMX on a property.
            - http://anonsvn.jboss.org/repos/jbossas/projects/demos/microcontainer/trunk/models/src/main/java/org/jboss/demos/models/jmx/ExposePojo.java
            This requires you to add property annotation plugin that handles this:
            - http://anonsvn.jboss.org/repos/jbossas/projects/demos/microcontainer/trunk/jmx/src/main/resources/META-INF/varia-deployers-beans.xml

            • 3. Re: BeanMetaData and management
              bob.mcwhirter

              Thanks for the response Ales--

              So, my "nothing" result was me applying @JMX to the wrong class, one not instantiated by MC.

              My "already installed" error occurs when I get the @JMX annotation on the correct class, but give my object a bogus MC bean name (in this case "jboss.rails:name=oddthesis").

              The error I was getting is here, in case you're interested. "Already installed" was somewhat confusing of an error to get.

              http://oddthesis.pastebin.com/f46537bdf

              I was expecting to find a JMX object named "jboss.rails:name=oddthesis"

              Once I named it more simply "jboss.rails.oddthesis" (using unit.getSimpleName(), if that's recommended?), it deployed just fine, and I can find my mbean under "jboss.pojo" domain successfully.

              I see I can set the 'name' parameter on @JMX, but is there another way to dynamically set the JMX object-name (to include some bit of unit.getSimpleName() perhaps) like I think the @ManagementObjectID annotation supports on that side of things? Ultimately, I think I'd like to end up with "jboss.rails:name=#{unit.getSimpleName()}" or similar.

              Or should I give up, admit JMX is dead, and move on?

              Thanks!

              Bob

              • 4. Re: BeanMetaData and management
                alesj

                 

                "bob.mcwhirter" wrote:

                My "already installed" error occurs when I get the @JMX annotation on the correct class, but give my object a bogus MC bean name (in this case "jboss.rails:name=oddthesis").

                This is the code that creates the name:
                - http://anonsvn.jboss.org/repos/jbossas/trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/AbstractServiceControllerLifecycleCallback.java
                If your bean name contains ':' it's gonna be used.

                "bob.mcwhirter" wrote:

                The error I was getting is here, in case you're interested. "Already installed" was somewhat confusing of an error to get.

                http://oddthesis.pastebin.com/f46537bdf

                You have duplicated name.
                Your bean and mbean are named the same, hence MC Controller complained.

                Thinking about how we create the name, it's not very good.
                I'll raise an issue about this.

                "bob.mcwhirter" wrote:

                I see I can set the 'name' parameter on @JMX, but is there another way to dynamically set the JMX object-name (to include some bit of unit.getSimpleName() perhaps) like I think the @ManagementObjectID annotation supports on that side of things? Ultimately, I think I'd like to end up with "jboss.rails:name=#{unit.getSimpleName()}" or similar.

                The problem here is that when @JMX interceptor kicks in,
                you don't have access to DeploymentUnit, since you might even not have any DU.
                e.g. programmatic ControllerContext installation

                But I'll check what can be done,
                to make name creation as configurable as possible.
                e.g. pulling some info from CC's MetaData

                "bob.mcwhirter" wrote:

                Or should I give up, admit JMX is dead, and move on?

                It depends how much work is there.
                For now I would still use it.
                But as soon as you see some lively movement in jopr/embedded wrt PS,
                I would change to ManagedObject.

                • 5. Re: BeanMetaData and management
                  bob.mcwhirter

                  Excellent explanation, Ales, thanks!

                  I'm happy to live for jboss.pojo for now.

                  I like the @ManagementObjectID (assuming I'm understanding it correctly). Or some way to mark a method as "call this to figure out the JMX ObjectName string".

                  ie.

                  @JMXObjectName
                  public String myFancyObjectNameGeneratorOnMyMBean() {
                  return "cheese:name=" + simpleName;
                  }

                  Bob

                  • 6. Re: BeanMetaData and management
                    bob.mcwhirter

                    For what it's worth, it seems the instance-level annotation capability was the solution. I added something like:

                    builder.addAnnotation("@org.jboss.aop.microcontainer.aspects.jmx.JMX(registerDirectly=true, exposedInterface=void.class, name=\"jboss.rails.web:app=" + unit.getSimpleName() + "\")");
                    


                    And now I get no installation errors, and it appears in jmx-console as I expect it to.

                    MC FTW!

                    -Bob



                    • 7. Re: BeanMetaData and management
                      alesj

                       

                      "bob.mcwhirter" wrote:

                      @JMXObjectName
                      public String myFancyObjectNameGeneratorOnMyMBean() {
                      return "cheese:name=" + simpleName;
                      }

                      This makes sense and can be easily added.




                      • 8. Re: BeanMetaData and management
                        alesj

                         

                        "alesj" wrote:
                        "bob.mcwhirter" wrote:

                        @JMXObjectName
                        public String myFancyObjectNameGeneratorOnMyMBean() {
                        return "cheese:name=" + simpleName;
                        }

                        This makes sense and can be easily added.

                        I'll let you implement it. :-)
                        Nah, just kiddin'. I'll try to add it before we go GA.

                        • 9. Re: BeanMetaData and management
                          alesj

                           

                          "bob.mcwhirter" wrote:
                          For what it's worth, it seems the instance-level annotation capability was the solution.:

                          Nice.
                          Forgot you are 'inside' a deployer. :-)

                          "bob.mcwhirter" wrote:

                          MC FTW!

                          FTW?
                          - http://www.google.com/search?source=ig&hl=en&rlz=&=&q=define%3AFTW&btnG=Google+Search&aq=f

                          • 10. Re: BeanMetaData and management
                            alesj

                             

                            "alesj" wrote:
                            "alesj" wrote:
                            "bob.mcwhirter" wrote:

                            @JMXObjectName
                            public String myFancyObjectNameGeneratorOnMyMBean() {
                            return "cheese:name=" + simpleName;
                            }

                            This makes sense and can be easily added.

                            I'll let you implement it. :-)
                            Nah, just kiddin'. I'll try to add it before we go GA.

                            - https://jira.jboss.org/jira/browse/JBMICROCONT-390

                            But I forgot to add it with 2.0.0.GA,
                            due to frenzy with JBoss Reflect bug. ;-(

                            But it's out there, so it will get in eventually. ;-)