[SNMP4J] Unable to add rows with Rowstatus and TableUtils?

johan.rask at jayway.se johan.rask at jayway.se
Mon Jul 7 13:51:54 CEST 2008


I found the error myself after looking at Snmp4jHeartbeatMib.
I was missing a RowFactory so adding on did the trick.

model.setRowFactory(new DefaultMOMutableRow2PCFactory());

Should there not be a default one, or is this not possible?

Regards /Johan R

2008-07-07 johan.rask at jayway.se wrote:

Hi,
>
>I have a table which I want to add rows dynamically. I have changed code from the
>TestAgent class to something that I feel should work but I still get "unable to create object"
>eller message. I would appreciate some help with this, I cannot find any examples of this.
>
>Any help is appreciated!
>
>Regards /Johan
>
>// Calling createRow (currentTableRowIndex == 1)
>// I have also tried with non-null value argument but I get the same result.
>// This code result in "unable to create object"
>ResponseEvent event = tableUtils.createRow(
>                builder.getRequest().getTarget(), mibSupport.bsTunnelControl(),
>                new OID(String.valueOf(currentTableRowIndex)),null );    
>
>// TABLE SETUP USED
>private  DefaultMOTable buildTunnelTable() {
>        MOTableSubIndex[] subIndexes =
>            new MOTableSubIndex[] { new MOTableSubIndex(SMIConstants.SYNTAX_INTEGER) };
>        MOTableIndex indexDef = new MOTableIndex(subIndexes, false);
>        MOColumn[] columns = new MOColumn[10];
>        int c = 0;
>        columns[c++] =
>            new RowStatus(c, 
>                         MOAccessImpl.ACCESS_READ_CREATE);     // Tunnel control
>        columns[c++] =
>            new MOMutableColumn(c, SMIConstants.SYNTAX_INTEGER,
>                         MOAccessImpl.ACCESS_READ_CREATE);     // Tunnelindex
>        columns[c++] =
>            new MOMutableColumn(c, SMIConstants.SYNTAX_OCTET_STRING,
>                         MOAccessImpl.ACCESS_READ_CREATE,null);     // Desit/cis ip
>        columns[c++] =
>            new MOMutableColumn(c, SMIConstants.SYNTAX_OCTET_STRING,
>                         MOAccessImpl.ACCESS_READ_CREATE,null);   // Adm iP
>        columns[c++] =
>            new MOMutableColumn(c, SMIConstants.SYNTAX_OCTET_STRING,
>                         MOAccessImpl.ACCESS_READ_CREATE,null);     // Dest uid
>        columns[c++] =
>            new MOMutableColumn(c, SMIConstants.SYNTAX_INTEGER,
>                         MOAccessImpl.ACCESS_READ_CREATE,null);    // Radiomode
>        columns[c++] =
>            new MOMutableColumn(c, SMIConstants.SYNTAX_INTEGER,
>                         MOAccessImpl.ACCESS_READ_CREATE);     // Tunneltype
>        columns[c++] =
>            new MOMutableColumn(c, SMIConstants.SYNTAX_INTEGER,
>                         MOAccessImpl.ACCESS_READ_CREATE);     // TunnelState
>        columns[c++] =
>            new MOMutableColumn(c, SMIConstants.SYNTAX_INTEGER,
>                         MOAccessImpl.ACCESS_READ_CREATE,null);    // Tunnel test
>        columns[c++] =
>            new MOMutableColumn(c, SMIConstants.SYNTAX_OCTET_STRING,
>                         MOAccessImpl.ACCESS_READ_CREATE);     //Last error
>        
>   
>        DefaultMOTable ifTable =
>            new DefaultMOTable(new OID(mibSupport.bsTunnelEntry()), indexDef, columns);
>        
>        MOMutableTableModel model = (MOMutableTableModel) ifTable.getModel();
>       
>        List peers = this.unit.getRemotePeers();
>       
>        int rowCount = 0;
>        
>        for (RemotePeer remotePeer : peers) {
>            log.debug("Creating new tunnel table row to peer " + remotePeer.uid);
>            rowCount++;
>            Variable[] rowValues = new Variable[] {
>                    new Integer32(RowStatus.active),
>                    new Integer32(rowCount),
>                    new OctetString(remotePeer.cisIp),
>                    new OctetString(remotePeer.uid),
>                    new OctetString(remotePeer.admIp),
>                    new Integer32(1),
>                    new Integer32(1),
>                    new Integer32(1),
>                    new Integer32(1),
>                    new OctetString()
>                };
>             model.addRow(new DefaultMOMutableRow2PC (new OID(String.valueOf(rowCount))
>             , rowValues));
>        }
>        ifTable.setVolatile(true);
>        ifTable.addMOChangeListener(this);
>        ifTable.addMOChangeListener(this.unit);
>        return ifTable;
>      }
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://lists.agentpp.org/mailman/listinfo/snmp4j
>
>


More information about the SNMP4J mailing list