|
AdventNet Web NMS 4 API Specification | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This interface has to be implemented by the user code that intends to register itself
as an Alert Observer. Alert Observers are notified whenever an Alert object is added,
updated or deleted of Alert Object taking place within the Web NMS system. On these
Alert Operations(Add,Update and Delete), the corresponding Alert Object is passed to the
Observers. This notification happens through the invocation of the update(Alert) or
update(Vector) method.
The Alert Observer will be intimated even when an alert is updated by adding
annotations or when an user picks/unpicks,clears or deletes an alert.
The user code implementing this interface should register itself as an observer
to the WebNMS system, using AlertAPI.registerForAlerts(AlertObserver) method, where
the user written class instance should be passed as an argument to this method.
The following code can be used for an Alert Observer which can run in a separate JVM. This example gets secured and authenticated AlertAPI.
import com.adventnet.nms.alertdb.AlertAPI;
import com.adventnet.nms.alertdb.AlertObserver;
import com.adventnet.nms.alertdb.Alert;
import com.adventnet.security.authentication.RMIAccessAPI;
import java.rmi.Naming;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
import java.util.Vector;
public class TestAlertObserver extends UnicastRemoteObject implements AlertObserver
{
TestAlertObserver() throws RemoteException
{
}
public void update(Alert alt)
{
System.out.println("Notification Received for Alert: Single update");
}
public void update(Vector v)
{
System.out.println("Notification Received for Alert: Batch Update");
}
void start()
{
try
{
RMIAccessAPI rmiapi = (RMIAccessAPI)Naming.lookup("//hostName/RMIAccessAPI");
AlertAPI api = (AlertAPI)rmiapi.getAPI("userName","password","AlertAPI");
if(api.registerForAlerts(this))
{
System.out.println("Successfully registered as AlertObserver");
}
else
{
System.out.println("Failed in registering as AlertObserver");
}
}
catch(Exception e)
{
System.out.println("Error in registering ");
e.printStackTrace();
}
}
public static void main(String args[])
{
try
{
TestAlertObserver observer = new TestAlertObserver();
observer.start();
}
catch(Exception e)
{
System.out.println("Error in initailizing TestAlertObserver");
e.printStackTrace();
}
}
}
User can use the following code snippet to get AlertAPI handle through RMI without RMI security mechanism of NMS.
try
{
AlertAPI api = (AlertAPI)Naming.lookup("//hostName/AlertAPI");
}
catch(Exception ee)
{
System.out.println("Error in getting AlertAPI handle");
ee.printStackTrace();
}
While running AlertObserver in the same JVM as that of WebNMS server,
NmsUtil.getAPI(String) can be used to get the
AlertAPI handle.
The registered Alert Observers can be deregistered using
AlertAPI.deregisterForAlerts(AlertObserver) method.
Alert Observers will be intimated only after alerts are processed by user configured Alert Filters. User should be aware, that only the alerts that are newly added or updated through the Event generation mechanism will be passed through Alert Filters. Given this scenario, the application of Alert filters might lead to a condition that on receiving an alert (due to addition or updation) an user defined Alert Filter can suppress it or drop it using Custom Java class. In this case the Alert observers will not be notified about suppressed or dropped Alert.
Note: Users are suggested to use AlertListener
since it has more sophisticated mechanism to identity the type of operation.
AlertAPI,
AlertListener,
SeverityInfo| Method Summary | |
void |
update(Alert alert)
For all Alert Observers which are registered to WebNMS, this method is invoked whenever there is an addition,updation or deletion of an Alert Object. |
void |
update(java.util.Vector vect)
This method is similar to the previous method except the argument which is a Vector of Alert Objects. |
| Method Detail |
public void update(Alert alert)
throws java.rmi.RemoteException
update(Vector) will be invoked when there are a group of alerts getting
added or updated or deleted in the Web NMS system. In such case the Vector
object will contain all the Alert Objects under operation.
As mentioned earlier, Alert Observer will be notified for all operations on Alerts viz. Additions ,Deletions and Updations.
To ascertain whether the notification for the concerned Alert is due to addition or
updation or deletion the user could use severity and previousSeverity
properties of the Alert Object. The severity and previousSeverity of Alert object
can be obtained using Alert.getSeverity() and Alert.getPreviousSeverity()
methods respectively.
The information tabulated below could stand as a guideline for the users in this regard.
| Operation type | Severity | Previous Severity |
| Addition | int value based on the entry given in SeverityInfo.conf | Special purpose Severity can be obtained from SeverityInfo.getSpecialPurposeSeverity() |
| Deletion | Special purpose severity which can be obtained from SeverityInfo.getSpecialPurposeSeverity() |
int value based on the entry given in SeverityInfo.conf |
| Updation | int value based on the entry given in SeverityInfo.conf | int value based on the entry given in SeverityInfo.conf |
Note: Alert processing thread waits until invocation of this method gets completed. Hence users are suggested not to overload this method. This method is invoked after Alert object is added in database
alert - The Alert Object that has been either added or updated or deleted,
in WebNMS system.java.rmi.RemoteException - if any exception in remote machineAlert,
update(Vector)
public void update(java.util.Vector vect)
throws java.rmi.RemoteException
Note: Alert processing thread waits until invocation of this method gets completed. Hence users are suggested not to overload this method. This method is invoked after Alert objects are added in database
vect - Vector of Alert Objects that has been added or updated or
deleted by the Web NMS systemjava.rmi.RemoteException - if any exception occurs in remote machineAlert,
update(Alert)
|
AdventNet Web NMS 4 API Specification | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||