[SNMP4J] Re: notificationOriginator is becoming NULL

Frank Fock fock at agentpp.com
Sun Sep 16 12:19:12 CEST 2007


Hi Urwashi,

If the NotificationOriginator instance becomes null,
this is rather a synchronization/singleton pattern
problem ("Is the static factory method synchronized?")
than a SNMP4J-Agent API problem.

The reinitialization should work, however when you use
removeAll you probably get a time slot without notification
targets (depends on your synchronization scheme).

A better approach to reset the target config would be
to create a new one and then only changing the pointer
from the old to the new one by creating a new
NotificationOriginatorImpl (or even better by subclassing
it to change the pointers individually).

Best regards,
Frank

Urwashi Sharma wrote:
> Hi Frank,
> 
> I am building an application by using  Snmp4J agent Api and deploying it
> into JBOSS . I am sending traps by using a notify call on
> notificationOriginator by TestAgent.  My TestAgent is a singleton classs.
> However, what I am seeing is that sometimes notificationOriginator becomes
> NULL. I am not sure how it is changing to null. Moreover, when I am trying
> to initialize it again it doesn’t get’s initialiaze as this is a run time
> behaviour I am not able to troubleshoot because of my limited knowledge.
> For my application it is a kind of Fatal error and only restarting of the
> agent fixes the problem. This problem is occurring at runtime and it is not
> consistent. Here is a code that shows how I am reinitializing the
> notificationoriginator after it became null.
> 
> For your info, I am storing all the Trap receiver info in the form of
> Object in a LDAP type of database. A user can change IP address in this
> lower layer and my task is to reload this info again in targetMib and
> Notification mib. I am doing this by emptying this table and reloading info
> from the database like this:
> 
> 
> targetMIB.getSnmpTargetAddrEntry().removeAll();
> 
> notificationMIB.getNotifyTable().removeAll();
> 
> 
> Here is a code for reinitializing it.
> 
> 
> public void sendTraps(Vector vbs, OID testOID, String context)
>             {
> 
>                         try {
>                                     VariableBinding []testTrap = new
> VariableBinding[vbs.size()];
>                                     for (int i = 0; i < vbs.size(); i++)
>                                     {
>                                                 testTrap[i] =
> (VariableBinding)vbs.get(i);
>                                     }
> 
>                                     if(testTrap== null)
>                                                 return;
> 
>                                     if(notificationOriginator == null)
>                                     {
>                                                 log.info(" Notification
> Originator is null.... Initializing it");
> 
>                                                 log.info(" session is " +
> session + " Vacm is " + vacmMIB + " sysUpTime is " +
> snmpv2MIB.getSysUpTime() + " Target mib is "
>                                                                         +
> snmpTargetMIB + " notification mib is " + snmpNotificationMIB);
>                                                 notificationOriginator =
>                                                             new
> NotificationOriginatorImpl(session, vacmMIB,
> snmpv2MIB.getSysUpTime(),
> snmpTargetMIB, snmpNotificationMIB);
>                                     }
> 
>                                     notificationOriginator.notify(new
> OctetString(context), testOID, testTrap);
>                                     log.info(" Sending Trap to Targets ");
>                         } catch (Exception e) {
>                                     log.error("Exception while sending Trap
> ");
>                         }
>             }
> 
> 
> 

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




More information about the SNMP4J mailing list