[SNMP4J] SnmpEngineListener fired multiple time for same address
Christy Jones (christyj)
christyj at cisco.com
Thu Sep 26 05:08:37 CEST 2013
Thanks Frank,
I also think splitting the conditions would help so that for a change in
engineID the code can fire a remove event followed by add event.
public boolean addEngineID(Address address, OctetString engineID) {
if (!Arrays.equals(this.localEngineID, engineID.getValue()))
{
OctetString previousEngineID = engineIDs.put(address, engineID);
if ((snmpEngineListeners != null))
{
if ((previousEngineID == null))
{
fireEngineChanged(new SnmpEngineEvent(this,
SnmpEngineEvent.ADDED_ENGINE_ID,engineID, address));
}
else if (!previousEngineID.equals(engineID))
{
fireEngineChanged(new SnmpEngineEvent(this,
SnmpEngineEvent.REMOVED_ENGINE_ID,previousEngineID,
address));
fireEngineChanged(new SnmpEngineEvent(this,
SnmpEngineEvent.ADDED_ENGINE_ID,engineID, address));
}
}
return true;
}
return false;
}
Regards
Christy
On 9/25/13 1:55 PM, "Frank Fock" <fock at agentpp.com> wrote:
>Hi Christy,
>
>This is indeed not optimal to fire the event, even if the engine ID did
>not change
>for an address. By replacing the method addEngineID in MPv3.java as
>follows you
>can improve the behavior:
>
> public boolean addEngineID(Address address, OctetString engineID) {
> if (!Arrays.equals(this.localEngineID, engineID.getValue())) {
> OctetString previousEngineID = engineIDs.put(address, engineID);
> if ((snmpEngineListeners != null) && ((previousEngineID == null)
>|| (!previousEngineID.equals(engineID)))) {
> fireEngineChanged(new SnmpEngineEvent(this,
>SnmpEngineEvent.ADDED_ENGINE_ID,
> engineID, address));
> }
> return true;
> }
> return false;
> }
>
>The next version of SNMP4J will include this patch.
>
>Best regards,
>Frank
>
>Am 25.09.2013 17:38, schrieb Christy Jones (christyj):
>> Hi,
>>
>> I'm using version 2.0.2 and in the process of implementing a
>> SnmpEngineListener.
>>
>> From what I observe the even when I'm polling for the same Address the
>> MPv3.addEngineID fires the listeners for every message sent.
>>
>> The if condition in MPv3.addEngineID to check with localEngineID does
>>not
>> appear to work well. The Address is available in the engineIDs map but
>>the
>> localEngineID does not match with the input engineID. The localengineID
>> appears to default one.
>>
>> Is there a specific reason to check against the localEngineID before
>> adding to the engineIDs map ? Could we not check if the Address is there
>> in endingIDs map directly?
>>
>> (!Arrays.equals(this.localEngineID, engineID.getValue()))
>>
>> Christy
>>
>>
>>
>>
>
>--
>---
>AGENT++
>Maximilian-Kolbe-Str. 10
>73257 Koengen, Germany
>https://agentpp.com
>Phone: +49 7024 8688230
>Fax: +49 7024 8688231
>
More information about the SNMP4J
mailing list