OpenNMS API 1.2.3

org.opennms.netmgt.notifd
Class BroadcastEventProcessor

java.lang.Object
  extended byorg.opennms.netmgt.notifd.BroadcastEventProcessor
All Implemented Interfaces:
EventListener

public final class BroadcastEventProcessor
extends java.lang.Object
implements EventListener

Author:
Brian Weaver , OpenNMS

Field Summary
private  java.util.Map m_noticeQueues
           
private  Notifd m_notifd
           
private static java.lang.String NOTIFD_EXPANSION_PARM
          A regular expression for matching an expansion parameter delimited by percent signs.
private static org.apache.regexp.RE notifdExpandRE
           
 
Constructor Summary
(package private) BroadcastEventProcessor(Notifd notifd, java.util.Map noticeQueues)
          This constructor is called to initilize the event receiver.
 
Method Summary
private  boolean autoAckExistsForEvent(java.lang.String eventUei)
          Returns true if an auto acknowledgment exists for the specificed event, such that the arrival of some second, different event will auto acknowledge the event passed as an argument.
private  void automaticAcknowledge(Event event)
           
(package private)  java.util.Map buildParameterMap(Notification notification, Event event, int noticeId)
           
 void close()
          Unsubscribe from eventd
private  boolean continueWithNotice(Event event)
          This method determines if the notice should continue based on the status of the notify
static java.lang.String expandNotifParms(java.lang.String inp, java.util.Map paramMap)
          A parameter expansion algorithm, designed to replace strings delimited by percent signs '%' with a value supplied by a Map object.
private  NotifdConfigManager getConfigManager()
           
private  EventIpcManager getEventManager()
           
 java.lang.String getName()
          Return an id for this event listener
private  NotificationManager getNotificationManager()
           
private  int getUserCount(Target[] targets, Escalate[] escalations)
          Detemines the number of users assigned to a list of Target and Escalate lists.
private  int getUsersInTarget(Target target)
           
private  NotificationTask makeEmailTask(long sendTime, java.util.Map parameters, int noticeId, java.lang.String address, java.lang.String[] commandList, java.util.List siblings)
           
private  NotificationTask makeUserTask(long sendTime, java.util.Map parameters, int noticeId, java.lang.String targetName, java.lang.String[] commandList, java.util.List siblings)
           
 void onEvent(Event event)
          This method is invoked by the EventIpcManager when a new event is available for processing.
private  void processEscalations(Escalate[] escalations, java.util.List targetSiblings, NoticeQueue noticeQueue, long startTime, java.util.Map params, int noticeId)
           
private  void processTargets(Target[] targets, java.util.List targetSiblings, NoticeQueue noticeQueue, long startTime, java.util.Map params, int noticeId)
           
 java.util.Map rebuildParameterMap(int notifId, java.lang.String resolutionPrefix)
           
 java.lang.String scheduledOutage(long nodeId, java.lang.String theInterface)
          Checks the package information for the pollable service and determines if any of the calendar outages associated with the package apply to the current time and the service's interface.
private  void scheduleNoticesForEvent(Event event)
           
private  void sendNotifEvent(java.lang.String uei, java.lang.String logMessage, java.lang.String description)
          Sends and event related to a notification
private  void sendResolvedNotifications(java.util.Collection notifIDs, Event event, java.lang.String acknowledge, java.lang.String[] match, java.lang.String resolutionPrefix)
           
protected  void sendResolvedNotificationsToUser(java.lang.String queueID, java.lang.String targetName, java.lang.String[] commands, java.util.Map params)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_noticeQueues

private java.util.Map m_noticeQueues

NOTIFD_EXPANSION_PARM

private static final java.lang.String NOTIFD_EXPANSION_PARM
A regular expression for matching an expansion parameter delimited by percent signs.

See Also:
Constant Field Values

notifdExpandRE

private static org.apache.regexp.RE notifdExpandRE

m_notifd

private Notifd m_notifd
Constructor Detail

BroadcastEventProcessor

BroadcastEventProcessor(Notifd notifd,
                        java.util.Map noticeQueues)
This constructor is called to initilize the event receiver. A connection to the message server is opened and this instance is setup as the endpoint for broadcast events. When a new event arrives it is processed and the appropriate action is taken.

Method Detail

close

public void close()
Unsubscribe from eventd


getEventManager

private EventIpcManager getEventManager()
Returns:

onEvent

public void onEvent(Event event)
This method is invoked by the EventIpcManager when a new event is available for processing.

Specified by:
onEvent in interface EventListener
Parameters:
event - The event .

automaticAcknowledge

private void automaticAcknowledge(Event event)

sendResolvedNotifications

private void sendResolvedNotifications(java.util.Collection notifIDs,
                                       Event event,
                                       java.lang.String acknowledge,
                                       java.lang.String[] match,
                                       java.lang.String resolutionPrefix)
                                throws java.lang.Exception
Throws:
java.lang.Exception

sendResolvedNotificationsToUser

protected void sendResolvedNotificationsToUser(java.lang.String queueID,
                                               java.lang.String targetName,
                                               java.lang.String[] commands,
                                               java.util.Map params)
                                        throws java.lang.Exception
Throws:
java.lang.Exception

getNotificationManager

private NotificationManager getNotificationManager()
Returns:

getConfigManager

private NotifdConfigManager getConfigManager()
Returns:

continueWithNotice

private boolean continueWithNotice(Event event)
This method determines if the notice should continue based on the status of the notify


autoAckExistsForEvent

private boolean autoAckExistsForEvent(java.lang.String eventUei)
Returns true if an auto acknowledgment exists for the specificed event, such that the arrival of some second, different event will auto acknowledge the event passed as an argument. E.g. if there is an auto ack set up to acknowledge a nodeDown when a nodeUp is received, passing nodeDown to this method will return true. Should this method be in NotifdConfigFactory?


scheduleNoticesForEvent

private void scheduleNoticesForEvent(Event event)

getUserCount

private int getUserCount(Target[] targets,
                         Escalate[] escalations)
                  throws java.io.IOException,
                         org.exolab.castor.xml.MarshalException,
                         org.exolab.castor.xml.ValidationException
Detemines the number of users assigned to a list of Target and Escalate lists. Group names may be specified in these objects and the users will have to be extracted from those groups

Parameters:
targets - the list of Target objects
escalations - the list of Escalate objects
Returns:
the total # of users assigned in each Target and Escalate objecst.
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getUsersInTarget

private int getUsersInTarget(Target target)
                      throws java.io.IOException,
                             org.exolab.castor.xml.MarshalException,
                             org.exolab.castor.xml.ValidationException
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

sendNotifEvent

private void sendNotifEvent(java.lang.String uei,
                            java.lang.String logMessage,
                            java.lang.String description)
Sends and event related to a notification

Parameters:
uei - the UEI for the event

buildParameterMap

java.util.Map buildParameterMap(Notification notification,
                                Event event,
                                int noticeId)

expandNotifParms

public static java.lang.String expandNotifParms(java.lang.String inp,
                                                java.util.Map paramMap)
A parameter expansion algorithm, designed to replace strings delimited by percent signs '%' with a value supplied by a Map object.

Parameters:
inp - the input string
paramMap - a map that will supply the substitution values

processTargets

private void processTargets(Target[] targets,
                            java.util.List targetSiblings,
                            NoticeQueue noticeQueue,
                            long startTime,
                            java.util.Map params,
                            int noticeId)
                     throws java.io.IOException,
                            org.exolab.castor.xml.MarshalException,
                            org.exolab.castor.xml.ValidationException
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

processEscalations

private void processEscalations(Escalate[] escalations,
                                java.util.List targetSiblings,
                                NoticeQueue noticeQueue,
                                long startTime,
                                java.util.Map params,
                                int noticeId)
                         throws java.io.IOException,
                                org.exolab.castor.xml.MarshalException,
                                org.exolab.castor.xml.ValidationException
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

makeUserTask

private NotificationTask makeUserTask(long sendTime,
                                      java.util.Map parameters,
                                      int noticeId,
                                      java.lang.String targetName,
                                      java.lang.String[] commandList,
                                      java.util.List siblings)
                               throws java.io.IOException,
                                      org.exolab.castor.xml.MarshalException,
                                      org.exolab.castor.xml.ValidationException
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

makeEmailTask

private NotificationTask makeEmailTask(long sendTime,
                                       java.util.Map parameters,
                                       int noticeId,
                                       java.lang.String address,
                                       java.lang.String[] commandList,
                                       java.util.List siblings)
                                throws java.io.IOException,
                                       org.exolab.castor.xml.MarshalException,
                                       org.exolab.castor.xml.ValidationException
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getName

public java.lang.String getName()
Return an id for this event listener

Specified by:
getName in interface EventListener

rebuildParameterMap

public java.util.Map rebuildParameterMap(int notifId,
                                         java.lang.String resolutionPrefix)
                                  throws java.lang.Exception
Returns:
Throws:
java.lang.Exception

scheduledOutage

public java.lang.String scheduledOutage(long nodeId,
                                        java.lang.String theInterface)
Checks the package information for the pollable service and determines if any of the calendar outages associated with the package apply to the current time and the service's interface. If an outage applies it's name is returned...otherwise null is returned.

Returns:
null if no outage found (indicating a notification may be sent) or the outage name, if an applicable outage is found (indicating notification should not be sent).
Throws:
java.io.IOException
org.exolab.castor.xml.ValidationException
org.exolab.castor.xml.MarshalException

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.