Managed Object Qs

by 
 on 04-Nov-2009 02:20 AM.
  in  OEMs & Developers 

Hi,


I want to query managed object. Below is what I am doing


         TopoAPI topoApi = (TopoAPI) NmsUtil.getAPI ("TopoAPI");

        java.util.Properties criteria  = new java.util.Properties();
        criteria.put("Type","myDevType");  //myDevType defined in OIDType.data
        
        Vector MOVector = null;
        try {
             MOVector  =  topoApi.getObjects("ManagedObject",criteria);
            
        } catch (RemoteException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        } catch (NmsStorageException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        } catch (UserTransactionException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        }
       
        if(MOVector != null) {
           Iterator<ManagedObject>     movItr = MOVector.iterator<ManagedObject>();
            while(movItr.hasNext()) {
            ManagedObject mo = movItr.next();
                   System.out.println("Here we are on "+mo.getDisplayName());  
            }
         }     

I get MOVector always null
I checked from the ManagedObject table from DB that there some host with "myType"
But in above, I always get MOVector always null.

  • No status
  • Answered
  • Working on it
  • Need more info
  1 user has this question 

Re: Managed Object Qs

by 
 on 06-Nov-2009 01:41 AM
Hi

Regarding your query , on analyzing your code snippet, we have noticed that ,in the match criteria which you have set for your managed object, the key value for Managed Object type should be "type" and not "Type".i.e all the letters should be in lower case.The reason being while filtering using TopoAPI.getObjects() , it will look for the property key value as "type". Hence, your Managed Object wouldn;t have been added to your MOVector since you have specified the property key value as "Type".

Hence, on performing the above change, you code should work.For further clarifications, kindy get back to us.

Regards
Vijayalakshmi

Re: Managed Object Qs

by 
 on 06-Nov-2009 05:49 AM

 Dear Ganesh,

Thanks for your mail.

We analyzed your issue and we believe that the following entry in your code snippet will be the root cause of this issue.

MOVector = topoApi.getObjects("ManagedObject",criteria);

Please note that getObjects() method will return a vector of objects that match the given criteria  where the first argument classname is used to filter out the objects.

Assume that the below entries were in the database:

MOID
 CLASSNAME
ISSNMP
1
Node
False
2
SnmpNode
true
3
Switch
true
4
ManagedObject
false


To fetch all the SNMP Nodes from the Topology Database, We can give the criteria as "isSNMP","true".

The following code snippet can be used to achieve this.

Properties criteria = new Properties();
criteria.put("isSNMP","true");
Vector MOVector = topoAPI.getObjects("SnmpNode",criteria);

This method will search the objects with the match criteria where isSNMP is true. The expected result with the above database entries will be both SnmpNode and Switch. Then the argument classname is used to filter out the objects. This getObjects() method returns only those objects whose classname property is the one passed to this method.

In this case, the classname is "SnmpNode", hence it will return only the corresponding objects (that is with MOID 2)

Please note that if the given classname is incorrect, then this method will return null. In the above example, if the classname passed as "ManagedObject" instead of "SnmpNode", (Refer the below code snippet)

Properties criteria = new Properties();
criteria.put("isSNMP","true");
Vector MOVector = topoAPI.getObjects("ManagedObject",criteria);

Now this method would return null, as the match criteria ("isSNMP" "True")  is not satisfied for the CLASSNAME "ManagedObject".

We believe that you have extended the object in your environment, hence you need to make sure that your customized extended object classname is given as the first argument of getObjects() method. This helps to resolve the issue.

You can also try with the sample RMI program that we have tested in our environment and have attached the same for your reference

We believe this helps to resolve your issue.

Do get back to us for any further clarifications in this regard.

Thanks and Regards,
Sharmila
Attachments
Post Actions
Statistics
  • 2
     Replies
  • 264
     Views
  • 0
     Followers
Tags for the post
No tags available for this topic.
© 2009 Corp. All rights reserved. Trademarks | Privacy Policy | Site Map | Contact Us | Careers

Edit Link Delete Link

Edit Link Delete Link

LoadingImage