5 Replies Latest reply on Mar 15, 2013 5:48 AM by Lukas Krejci

    My rhq plugin error, reason of resource type duplicate

    udayatom Newbie

         If i am using multiple server in my plugin as following, how to mention the resource type. Because i used only ResourceType resourceType = context.getResourceType(); all my java files. i dont know how to change the resource type value in each file. please help me where to am change

       

      <server>

                  <server>

                        <service>

                        </service>

       

       

                         <service>

                        </service>

       

                 </server>

       

            <server>

                        <service>

                        </service>

       

       

                         <service>

                        </service>

       

            </server>

       

      </server>

       

                              Is the structure is right

       

       

       

      Error

      ====

       

       

      org.rhq.core.clientapi.agent.metadata.InvalidPluginDescriptorException: Type [{SolartisTrailPlugin}Users] is duplicate for this plugin. This is illegal.

              at org.rhq.core.clientapi.agent.metadata.PluginMetadataManager.loadPlugin(PluginMetadataManager.java:178)

              at org.rhq.enterprise.server.resource.metadata.PluginManagerBean.registerPluginTypes(PluginManagerBean.java:424)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:

        • 1. Re: My rhq plugin error, reason of resource type duplicate
          mazz Master

          I haven't looked at any of your code, but from solely reading that error message:

           

          Type [{SolartisTrailPlugin}Users] is duplicate for this plugin. This is illegal.

           

          I will predict that in your rhq-plugin.xml descriptor you have two types defined with this attribute: name="Users"

           

          Obviously, as per that error message, this is illegal.

          • 2. Re: My rhq plugin error, reason of resource type duplicate
            udayatom Newbie

                                     Yes john, now only predict it, and changed it i got it. Thank you for your response. because after i post this question i got the result. so i back for forum to delete the post, you replied me . Thank you for your timely response.

             

                                  I have another doubts,

             

            <server name="MonitoringSystemPlugin"

                            discovery="ManagementDiscoveryComponent"

                            class="ManagementComponent1"

                            supportsManualAdd="true"

                            description=" Monitoring System plugin">

             

                         doubts

                         =====                        

                               1)can i use the mulitple components(discovery and class) at the same server

             

                               2)if i am use the value in the metric1 in server1. can i use the value of metric1 in server2 (how can i access the metric one resource to another resource).

             

                               3)what is the scope of the metric.

             

                               4)give me the examples, notes for plugin writing.

             

             

            Regards,

             

            Udayakumar

            • 3. Re: My rhq plugin error, reason of resource type duplicate
              jay shaughnessy Expert

              1)can i use the mulitple components(discovery and class) at the same server

               

                Each type has a discovery class (discovery=) and a component class (class=).  It doesn't matter if they are the same class or different classes as long as they implement the required interfaces.  In general different classes are used.

               

              2)if i am use the value in the metric1 in server1. can i use the value of metric1 in server2 (how can i access the metric one resource to another resource).

               

                The metrics for each type are applicable to that resources of that type and must be able to be reported by that type's component class.  Each type must define its own metrics, even if multiple types have metrics of the same name.

               

              3)what is the scope of the metric.

               

                The encompassing type.  Each resource of that type will have that metric reported.

               

              4)give me the examples, notes for plugin writing.

               

                For examples you can look at the code for any of the plugins in the RHQ source repo.  Look under modules/plugins/... in the repo.  You can find git links from the rhq project home page.

              • 4. Re: My rhq plugin error, reason of resource type duplicate
                udayatom Newbie

                Thanks jay,

                 

                                Thank you for clarification. please give me the example of "if i am use the value in the metric1 in server1. can i use the value of metric1 in server2". i need a example for better understand.  here i mentioned my requirement(i.e doubt ) in below. please you mention how to access. My need is, here i discovers discovery component at  the server Customer1ManagementDiscoveryComponent , after some process in my Customer1ManagementComponent, so i put values in the metrics. please explain how to transfer the value into the service name called Users .So again i use the same process in components(UserManagementDiscoveryComponent,UserManagementComponent).I need again to display the values to again because i need a details again in another Service Users. please explain, mention the structure of how to reuse the values?

                 

                <server name="Customer1allDetails"

                                discovery="Customer1ManagementDiscoveryComponent"

                                class="Customer1ManagementComponent"

                                supportsManualAdd="true"

                                description="Customer1monitoring plugin">

                 

                 

                 

                            <metric property="NoofUsersLoggedin"

                                displayName="No of Users Logged-In"

                                measurementType="dynamic"

                                displayType="summary"/>

                 

                            <metric property="NoofUsersLoggedoff"

                                displayName="No of Users Logged-off"

                                measurementType="dynamic"

                                displayType="summary"/>

                 

                            <metric property="NoofCurrentlyactiveusers"

                                displayName="No of Currently active users"

                                measurementType="dynamic"

                                displayType="summary"/>

                 

                            <metric property="NoofFailedInvalidLogins"

                                displayName="No of Failed Invalid Logins"

                                measurementType="dynamic"

                                displayType="summary"/> 

                 

                 

                 

                 

                            <service name="Users"

                                discovery="UserManagementDiscoveryComponent"

                                class="UserManagementComponent"

                                description="User management System"

                                supportsManualAdd="true"

                                singleton="true">

                 

                 

                 

                            <metric property="NoofUsersLoggedin"

                                displayName="No of Users Logged-In"

                                measurementType="dynamic"

                                displayType="summary"/>

                 

                            <metric property="NoofUsersLoggedoff"

                                displayName="No of Users Logged-off"

                                measurementType="dynamic"

                                displayType="summary"/>

                 

                            <metric property="NoofCurrentlyactiveusers"

                                displayName="No of Currently active users"

                                measurementType="dynamic"

                                displayType="summary"/>

                 

                            <metric property="NoofFailedInvalidLogins"

                                displayName="No of Failed Invalid Logins"

                                measurementType="dynamic"

                                displayType="summary"/>        

                 

                            </service>   

                 

                 

                 

                  </server>

                • 5. Re: My rhq plugin error, reason of resource type duplicate
                  Lukas Krejci Apprentice

                  There is no declarative mechanisms to provide you such feature automatically, but you can certainly achieve it.

                  Add something like this into your Customer1ManagementComponent:

                   

                  private volatile Integer lastKnownNoofUsersLoggedIn;
                  
                  public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
                     ...
                     lastKnownNoofUsersLoggedIn = collectedValue;
                  }
                  
                  public int getLastKnownNoofUsersLoggedIn() {
                     if (lastKnownNoofUsersLoggedIn == null) {
                         //we're being called before the first call to getValues()
                         //and thus need to collect the value manually here
                        ...
                     }
                     return lastKnownNoofUsersLoggedIn;
                  }
                  
                  

                   

                  Then declare your UserManagementComponent like:

                   

                   

                  public class UserManagementComponent implements ResourceComponent<Customer1ManagementComponent>, ... {
                  
                      ...
                      private ResourceContext resourceContext;
                  
                      public void start(ResourceConext<Customer1ManagementComponent> context) throws InvalidPluginConfigurationException {
                          this.resourceContext = context;
                          ...
                      }
                  
                      public int getLastKnownNoofUsersLoggedIn() {
                          return resourceContext.getParentResourceComponent().getLastKnownNoofUsersLoggedIn();      
                      }
                  
                      ...
                  }
                  
                  

                   

                  You can then use the getLastKnownNoofUsersLoggedIn() method in the UserManagementComponent whereever you need. Note though that as implemented above, the value of the metric will only be known until a metric collection occured and thus you might end up with this value uninitialized - hence the check for nullity in the getter.