6 Replies Latest reply on Feb 25, 2011 6:45 AM by makkoca

    Discovery problem

    makkoca

      Hi there,

      Here is my custom plugin's discovery component for jboss connectors. The code below discovers 8009 and 8080 connectors succefuly but only one connector appears in the server instead of 2. I've seen metrics are collected for both resource in the agent logs.

       

           Set<ObjectInstance> beans = null;
                  try {
                      beans = mbsconn.queryMBeans(new ObjectName("jboss.web:type=Connector,*"),null);
                      for( ObjectInstance instance : beans ){
                          try{                        
                              log.info(instance.getObjectName());
                              
                              String protocol = (String)mbsconn.getAttribute(instance.getObjectName(), "protocol");
                              String port = String.valueOf(mbsconn.getAttribute(instance.getObjectName(), "port"));
                              String address = ((Inet4Address)mbsconn.getAttribute(instance.getObjectName(), "address")).getHostAddress();                                                
      
                              String resourceName = protocol.substring(0,protocol.indexOf("/")).toLowerCase() + "-" + address + "-" + port;
                              String resourceKey = resourceName; 
                                                      
                              DiscoveredResourceDetails service = new DiscoveredResourceDetails(context.getResourceType(), resourceKey, resourceName, "", "Custom plugin discovered jboss connector", null, null);
                              
                              Configuration config = service.getPluginConfiguration();
                              config.put(new PropertySimple("objectName", instance.getObjectName().toString()));
                              
                              log.info("Service adding "+resourceKey);
                              set.add(service);
                          }catch(Exception e){
                              log.error(e,e);
                          }
                      }
                      
                  } catch (Exception e) {
                      log.error("Jboss query failed!.",e);
                  }finally{
                      disconnect();
                  }

       

       

       

      This is what i expect,

      MyPlugin

         >Jboss Probe

            >http-0.0.0.0-8080

            >ajp-0.0.0.0-8009

       

      This is what i get,

      MyPlugin

         >Jboss Probe

            >http-0.0.0.0-8080

        • 1. Re: Discovery problem
          ips

          I'd try running another full discovery via the "discovery -f" Agent prompt command, then see if the service shows up.

           

          Can you attach your full discovery class along with your plugin descriptor?

          • 2. Re: Discovery problem
            makkoca

            Agent log(agent_log.png) shows both connectors are queried but i can only see http-0.0.0.0-8080 connector on server(see tree.png).

            I've tried "discovery -f" one more for you but didn't work.

            • 3. Re: Discovery problem
              makkoca

              When I type avail command on agent console i can see both resources and status are UP.

               

              UP:     http-0.0.0.0-8080
              UP:     ajp-0.0.0.0-8009

               

              If I re-inventory MyPlugin, appearing connector may change. Sometimes http-0.0.0.0-8080 sometimes ajp-0.0.0.0-8009 becomes avaliable on tree view. What should i do further?

              • 4. Re: Discovery problem
                makkoca

                I checked out skeleton-plugin project again and added a service definition to it's rhq-plugin.xml.

                 

                <service name="xxx-service" discovery="DummyDiscoveryClass" class="DummyComponentClass"
                               createDeletePolicy="neither" singleton="true">
                         <operation displayName="Reset Peak Thread Metrics" name="resetPeakThreadCount"
                                    description="Reset the peak number of threads"/>              
                </service>

                 

                I copied existing agent classes and named them DummyDiscoveryClass and DummyComponentClass.

                 

                I want to see 2 services under the "My Server" so i modified DummyDiscoveryClass.

                String key = "My Service Resource Key";
                        String name = "My Service Resource";
                        String version = "1.0";
                        String description = "This describes My Resource";

                        DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
                            version, description, null, null);
                       
                        DiscoveredResourceDetails resource2 = new DiscoveredResourceDetails(context.getResourceType(), key+1, name+1,
                                version, description, null, null);       

                        set.add(resource);
                        set.add(resource2);

                 

                 

                Then,

                 

                I was expecting this view,

                Sample Plugin Server

                     |__My Resource

                              |_____ My Service Resource

                              |_____ My Service Resource1

                 

                Bu I got this,

                Sample Plugin Server

                     |__My Resource

                               |_____ My Service Resource

                     |__My Resource

                               |_____ My Service Resource1

                 

                 

                I have read the custom plugin developmet manual I also have explored other plugins sources but I still don't know some basic rules i think.

                Isn't there anyone to give me a hint to figure out what the problem is?

                • 5. Re: Discovery problem
                  mazz

                  One thing that jumps out at me - you said you want multiple service resources under your "My Resource" server. However, in your <service> descriptor, you have the attribute 'singleton="true"'. Only use singleton set to true iff you will have a SINGLE resource. I suspect the combination of saying singleton=true along with providing multiple resources might be causing this problem.

                   

                  If you still see this after you take out singleton=true and retry it, post the full descriptor and the "My Resource" server discovery class code.

                  • 6. Re: Discovery problem
                    makkoca

                    Finally, I managed return to this project.

                    I tried your suggestion and it worked like a charm.

                     

                    BTW, I've added a useful operation to my ThreadProbe, for investigating cpu utilization of threads that running in that JVM.

                    Actually, it was the main reason of creating this custom plugin.

                     

                    Anyway, thank you for all your interest.

                     

                    last.png