[SNMP4J] Re: Issue with dependent table Column

Frank Fock fock at agentpp.com
Thu Oct 4 23:36:20 CEST 2007


Hi Deepak,

I have no idea what's going wrong.
Have you checked the log file of the
agent on debug level?
Are there any VACM views affecting
the query?

Best regards,
Frank

Saraswat, Deepak wrote:
> Hi Frank,
> 
>  
> 
> I have two tables one is Base and the other is dependent table. I have 
> implemented a relationship between two tables by implementing a class 
> that extends MOTableRelation and overrides addDependentRows as explained 
> in JavaDoc. Finally, I called set relation to set relation between them.
> 
>  
> 
>  
> 
>             public void setCoamProductEntryRelation(MOTable baseTable) {
> 
>                         log.info(" Setting relationship between 
> CoamProductTableEntry and CoamProductExtTableEntry ");
> 
>                         coamProductNameEntryRelation =
> 
>                    new CoamProductTableRelation(baseTable, 
> getCoamProductExtTableEntry());
> 
>                         coamProductNameEntryRelation.createRelationShip();
> 
>               }
> 
>  
> 
> My dependent table got two columns in it. While adding rows in the base 
> table I can see that rows are also getting added to dependent table with 
> the value to both the columns:
> 
>  
> 
> /**            * Adds all dependent rows for the specified base table 
> row to the dependent
> 
>                * table.
> 
>                *
> 
>                * @param baseTableRow
> 
>                *    a row of the base table.
> 
>                */
> 
>             protected void addDependentRows(MOTableRow baseTableRow) {
> 
>                         log.info(" Adding rows in dependent 
> table.................");
> 
>                         OID[] indexes = getDependentIndexes(baseTableRow);
> 
>                         ReadWriteProperties rwProp = new 
> ReadWriteProperties();                      
> 
>                        
> 
>                 for (int i=0; i<indexes.length; i++) {
> 
>                         byte [] baseRowIndex = indexes[i].toByteArray();
> 
>                                     OctetString baseRowIndexVal = new 
> OctetString(baseRowIndex);
> 
>                        
> 
>                         String depIndexVal = 
> rwProp.getProperty("DependentTable.Row1.Column1");
> 
>                         String depValCol2 = 
> rwProp.getProperty("DependentTable.Row1.Column2");
> 
>                        
> 
>                         OID index = (new OctetString( 
> baseRowIndexVal.toString() + "." + depIndexVal).toSubIndex(true));
> 
>                        
> 
>                         MOTableRow depRow =
> 
>                       dependentTable.createRow(index,
> 
>                                       new Variable[]{new 
> OctetString(depIndexVal), new OctetString(depValCol2)});// Adding Values 
> of the dependent table.
> 
>            
> 
>                   depRow.setBaseRow(baseTableRow); //Adding a row in a 
> dependent table
> 
>                   log.info(" Number of Columns in the dependent Row " + 
> depRow.size());
> 
>                   log.info("Size of dependent Row is " + depRow.size());
> 
>                   log.info(" dependent Row is " + depRow.toString());
> 
>                   dependentTable.addRow(depRow);
> 
>                 }
> 
>  
> 
> However, when I query agent to get the values of the dependent table it 
> only returns values of the first column in table view. If I call getnext 
> on the table it displays value of first column only. I am not sure why 
> agent is not recognizing second column of the dependent table. While  it 
> created dependent table successfully and also added values in it 
> successfully.
> 
>  
> 
> Everything works fine for the Base table which also got two columns in 
> it. Could you help me to troubleshoot it.
> 
>  
> 
> Here is the code for Creating a Dependent table:
> 
>  
> 
>                        
> 
>             public void createcoamProductExtTable()
> 
>             {
> 
>                         CoamProductExtEntryIndexes =
> 
>                                     new MOTableSubIndex[] {
> 
>                                                 
> moFactory.createSubIndex(oidCoamProductExtFamily,
> 
>                                                                         
> SMIConstants.SYNTAX_OCTET_STRING, 0, 255)
> 
>                         };
> 
>  
> 
>                         CoamProductExtTableEntryIndex =
> 
>                                     
> moFactory.createIndex(CoamProductExtEntryIndexes,
> 
>                                                             false,
> 
>                                                             new 
> MOTableIndexValidator() {
> 
>                                                 public boolean 
> isValidIndex(OID index) {
> 
>                                                             boolean 
> isValidIndex = true;
> 
>                                                             return 
> isValidIndex;
> 
>                                                 }
> 
>                                     });
> 
>  
> 
>                         // Columns
> 
>                         MOColumn[] CoamProductExtTableEntryColumns = new 
> MOColumn[2];
> 
>  
> 
>                         
> CoamProductExtTableEntryColumns[idxCoamProductExtFamily] =
> 
>                                     new 
> MOMutableColumn(colCoamProductExtFamily, 
> SMIConstants.SYNTAX_OCTET_STRING,MOAccessImpl.ACCESS_READ_WRITE);
> 
>  
> 
>                         
> CoamProductExtTableEntryColumns[idxCoamProductExtDesc] =
> 
>                                     new 
> MOMutableColumn(idxCoamProductExtDesc, 
> SMIConstants.SYNTAX_OCTET_STRING,MOAccessImpl.ACCESS_READ_WRITE);
> 
>                        
> 
>  
> 
>                         CoamProductExtTableEntry =
> 
>                                     new 
> DefaultMOTable(oidCoamProductExtEntry,
> 
>                                                             
> CoamProductExtTableEntryIndex,
> 
>                                                             
> CoamProductExtTableEntryColumns);
> 
>                         //Table model
> 
>                         CoamProductExtTableEntryModel = new 
> DefaultMOMutableTableModel();
> 
>  
> 
>                         CoamProductExtTableEntryModel.setRowFactory(new 
> CoamProductExtTableEntryRowFactory());
> 
>                         
> CoamProductExtTableEntry.setModel(CoamProductExtTableEntryModel);
> 
>             }
> 
>            
> 
>            
> 
>             /**
> 
>              * A factory class to create rows in a 
> CoamProductExtTableEntry Table.
> 
>              * @author Deepak Saraswat
> 
>              *
> 
>              */
> 
>             class CoamProductExtTableEntryRowFactory implements 
> MOTableRowFactory
> 
>             {
> 
>                         public synchronized MOTableRow createRow(OID 
> index, Variable[] values) throws UnsupportedOperationException
> 
>                         {
> 
>                                     CoamProductExtTableEntryRow row = 
> new CoamProductExtTableEntryRow(index, values);
> 
>                                     return row;
> 
>                         }
> 
>  
> 
>                         public synchronized void freeRow(MOTableRow row) {
> 
>  
> 
>                         }
> 
>             }
> 
>  
> 
>             /**
> 
>              * Creating customized rows by extending 
> DefaultMOMutableRow2PC and overwriting getValue and Prepare function of it .
> 
>              */
> 
>             public class CoamProductExtTableEntryRow extends 
> DefaultMOMutableRow2PC {
> 
>                         public CoamProductExtTableEntryRow(OID index, 
> Variable[] values) {
> 
>                                     super(index, values);
> 
>                                     log.info(" Value size is " + 
> values.length);
> 
>                                    
> 
>                                     for(int i =0; i< values.length; i++)
> 
>                                                 log.info(" Value " + i 
> +  " is " + values[i]);
> 
>                                    
> 
>                                     log.info(" Coam Product Table Entry 
> Ext Row called in " + this.getClass().getName());
> 
>  
> 
>                         }
> 
>  
> 
>                         /**
> 
>                          * This function fetches value for the specified 
> index and return it back to North bound.
> 
>                          * Overwrite this method to provide custmoised 
> retrieval of the values.
> 
>                          */
> 
>                         public Variable getValue(int column)
> 
>                         {
> 
>                                     log.info(" Get value function of the 
> Dependent row for column " + column);
> 
>                                     String value = null;
> 
>                                     ReadWriteProperties rwProp = new 
> ReadWriteProperties();
> 
>                                     rwProp.loadPropertyFile();
> 
>                                    
> 
>                                     if(column ==idxCoamProductExtFamily)
> 
>                                                 value = 
> rwProp.getProperty("DependentTable.Row1.Column1");
> 
>                                     else if(column == idxCoamProductExtDesc)
> 
>                                                  value = 
> rwProp.getProperty("DependentTable.Row1.Column2");
> 
>                                     else
> 
>                                                 value = " could not find 
> a row";
> 
>                                     return new OctetString(value);
> 
>                         }
> 
>  
> 
> Thanks for the help in advance.
> 
>  
> 
> Regards,
> 
> Deepak
> 

-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list