[SNMP4J] Fwd: Table Model
Aiman Farhat
aiman.farhat at gmail.com
Thu May 2 14:30:10 CEST 2013
Hi All,
The problem I am facing with snmp4j is as follow, I am building a
*dynamic*table model, where every time a request comes I clear the old
data and then
recreate it. The Issue I am facing is when I am sending subsequent requests
the data model is not returning the correct rows. Just to give you an
example:
As a test the data I am sending back to the request either:
Set A:
Component1
Component2
Component3
Component4
Component5
Component6
OR
Set B:
Component11
Component22
Component33
Component44
Component55
Component66
Now the problem as follow:
I see the following results in the Mib browser returned:
Component1
Component22
Component3
Component44
Component55
Component6
As you can see the values in the table model is not what I have expected.
As when I am building the table model I am clearing the old data then re
populated with either set A or Set B
of dummy values.
Just to elaborate more from code prospective :
T*his is building the table section:*
DefaultMOTable table = new DefaultMOTable(tableRootOid, indexDef,
columns.toArray(new
MOColumn[0]));
MOMutableTableModel model = (MOMutableTableModel) table.getModel();
int i = 1;
for (Variable[] variables : tableRows) {
model.addRow(new DefaultMOMutableRow2PC(new OID(String.valueOf(i)),
variables));
i++;
}
table.setVolatile(true);
return table;
This section details the registration of the managed Table Object
server.register(table, null);
server.addLookupListener(new DeployedComponentListener(table), table);
And this is my Listener class implementation
@Override
*public* *void* queryEvent(MOServerLookupEvent event) {
*DefaultMOTable* table = (*DefaultMOTable*) event.getLookupResult();
MOMutableTableModel<DefaultMOMutableRow2PC>
model = *(MOMutableTableModel<DefaultMOMutableRow2PC>) table.getModel()*;
*synchronized* (model) {
model.clear();
Random r = *new* Random();
*int* rand = r.nextInt(2);
*if* (rand == 0) {
Variable[] var1 = *new* Variable[]
{ *new* Integer32(1),
*new* OctetString(
"Component1"),
*new*
OctetString("Component1
version"),
*new*
OctetString("Component1
revision"),
*new*
OctetString("Component1
insenace id"),
*new* OctetString("")
};
more var…..
model.addRow(*new*DefaultMOMutableRow2PC(
*new* OID("1"), var1));
model.addRow(*new*DefaultMOMutableRow2PC(
*new* OID("2"), var2));
model.addRow(*new*DefaultMOMutableRow2PC(
*new* OID("3"), var3));
model.addRow(*new*DefaultMOMutableRow2PC(
*new* OID("4"), var4));
model.addRow(*new*DefaultMOMutableRow2PC(
*new* OID("5"), var5));
model.addRow(*new*DefaultMOMutableRow2PC(
*new* OID("6"), var6));
} *else* {
Variable[] var1 = *new* Variable[]
{ *new* Integer32(1),
*new* OctetString(
"Component11"),
*new* OctetString(""
),
*new* OctetString(""
),
*new* OctetString(""
),
*new* OctetString("")
};
more var
model.addRow(*new*DefaultMOMutableRow2PC(
*new* OID("1"), var1));
model.addRow(*new*DefaultMOMutableRow2PC(
*new* OID("2"), var2));
model.addRow(*new*DefaultMOMutableRow2PC(
*new* OID("3"), var3));
model.addRow(*new*DefaultMOMutableRow2PC(
*new* OID("4"), var4));
model.addRow(*new*DefaultMOMutableRow2PC(
*new* OID("5"), var5));
model.addRow(*new*DefaultMOMutableRow2PC(
*new* OID("6"), var6));
}
}
I am following the AgentPro instrumentation guide this the only guide I
could find on how to build the table model.
Thanks
AF
More information about the SNMP4J
mailing list