Package org.opennms.netmgt.model.events
Class EventUtils
- java.lang.Object
-
- org.opennms.netmgt.model.events.EventUtils
-
public abstract class EventUtils extends Object
Abstract EventUtils class.
- Version:
- $Id: $
- Author:
- ranger
-
-
Constructor Summary
Constructors Constructor Description EventUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkInterface(IEvent e)
static void
checkInterface(Event e)
Ensures the given event has an interfacestatic void
checkNodeId(IEvent e)
static void
checkNodeId(Event e)
Ensures that the given Event has a node idstatic void
checkService(IEvent e)
static void
checkService(Event e)
Ensures that the given event has a service parameterstatic Event
createApplicationDeletedEvent(String source, int applicationId, String applicationName)
Constructs a applicationDeleted Event for a given application id and namestatic Event
createAssetInfoChangedEvent(String source, long nodeId, long txNo)
Construct a deleteNode event for the given nodeId.static Event
createDeleteInterfaceEvent(String source, long nodeId, String ipAddr, int ifIndex, long txNo)
Constructs a deleteInterface event for the given nodeId, ipAddress (or ifIndex) pair.static Event
createDeleteNodeEvent(String source, long nodeId, long txNo)
static Event
createDeleteServiceEvent(String source, long nodeId, String ipAddr, String service, long txNo)
Constructs a deleteService event for the given nodeId, ipAddress, serviceName triple.static Event
createInterfaceDeletedEvent(String source, int nodeId, InetAddress addr)
Construct an interfaceDeleted event for an interface.static Event
createNodeAddedEvent(String source, int nodeId, String nodeLabel, OnmsNode.NodeLabelSource labelSource, String monitorKey)
createNodeAddedEventstatic Event
createNodeCategoryMembershipChangedEvent(String source, Integer nodeId, String nodeLabel, String[] categoriesAdded, String[] categoriesDeleted)
static Event
createNodeDeletedEvent(String source, int nodeId, String hostName, String nodeLabel, OnmsMonitoringLocation nodeLocation, String nodeForeignId, String nodeForeignSource, OnmsIpInterface nodePrimaryInterface)
This method is responsible for generating a nodeDeleted event and sending it to eventd..static Event
createNodeGainedInterfaceEvent(String source, int nodeId, InetAddress ifaddr)
createNodeGainedInterfaceEventstatic Event
createNodeGainedServiceEvent(String source, int nodeId, InetAddress ifaddr, String service, String nodeLabel, OnmsNode.NodeLabelSource labelSource, String sysName, String sysDescr)
createNodeGainedServiceEventstatic Event
createNodeLocationChangedEvent(String source, Integer nodeId, String nodeLabel, String prevLocation, String currentLocation)
createNodeLocationChangedEventstatic Event
createNodeUpdatedEvent(String source, Integer nodeId, String nodeLabel, OnmsNode.NodeLabelSource labelSource, String rescanExisting, String monitorKey)
createNodeUpdatedEventstatic Event
createServiceDeletedEvent(String source, int nodeId, InetAddress addr, String service)
Constructs a serviceDeleted Event for the nodeId, ipAddr, serviceName triplestatic boolean
eventsMatch(IEvent e1, IEvent e2)
eventsMatchstatic boolean
eventsMatch(Event e1, Event e2)
eventsMatchstatic int
getIntParm(IEvent e, String parmName, int defaultValue)
static int
getIntParm(Event e, String parmName, int defaultValue)
Retrieve the value associated with an event parameter and parse it to an int.static long
getLongParm(Event e, String parmName, long defaultValue)
Retrieve the value associated with an event parameter and parse it to a long.static String
getParm(IEvent e, String parmName)
static String
getParm(IEvent e, String parmName, String defaultValue)
static String
getParm(Event e, String parmName)
Return the value of an event parameter of null if it does not exist.static String
getParm(Event e, String parmName, String defaultValue)
Retrieve a parameter from and event, returning defaultValue of the parameter is not set.static boolean
isNonIpInterface(String intf)
Is the given interface a non-IP interfacestatic void
requireParm(IEvent e, String parmName)
static void
requireParm(Event e, String parmName)
Throw an exception if an event does have the required parameterstatic String
toString(Collection<Parm> parms)
static String
toString(Event event)
toStringstatic String
toString(Snmp snmp)
toStringstatic String
toString(Value value)
toString
-
-
-
Method Detail
-
createNodeAddedEvent
public static Event createNodeAddedEvent(String source, int nodeId, String nodeLabel, OnmsNode.NodeLabelSource labelSource, String monitorKey)
createNodeAddedEvent
-
createNodeGainedInterfaceEvent
public static Event createNodeGainedInterfaceEvent(String source, int nodeId, InetAddress ifaddr)
createNodeGainedInterfaceEvent
- Parameters:
source
- aString
object.nodeId
- a int.ifaddr
- aInetAddress
object.- Returns:
- a
Event
object.
-
createNodeGainedServiceEvent
public static Event createNodeGainedServiceEvent(String source, int nodeId, InetAddress ifaddr, String service, String nodeLabel, OnmsNode.NodeLabelSource labelSource, String sysName, String sysDescr)
createNodeGainedServiceEvent
-
createNodeDeletedEvent
public static Event createNodeDeletedEvent(String source, int nodeId, String hostName, String nodeLabel, OnmsMonitoringLocation nodeLocation, String nodeForeignId, String nodeForeignSource, OnmsIpInterface nodePrimaryInterface)
This method is responsible for generating a nodeDeleted event and sending it to eventd..- Parameters:
source
- A string representing the source of the eventnodeId
- Nodeid of the node got deleted.hostName
- the Host server name.nodeLabel
- the node label of the deleted node.- Returns:
- a
Event
object.
-
createInterfaceDeletedEvent
public static Event createInterfaceDeletedEvent(String source, int nodeId, InetAddress addr)
Construct an interfaceDeleted event for an interface.- Parameters:
source
- the source of the eventnodeId
- the nodeId of the node the interface resides inipAddr
- the ipAdddr of the event- Returns:
- an Event represent an interfaceDeleted event for the given interface
-
createServiceDeletedEvent
public static Event createServiceDeletedEvent(String source, int nodeId, InetAddress addr, String service)
Constructs a serviceDeleted Event for the nodeId, ipAddr, serviceName triple- Parameters:
source
- the source of the eventnodeId
- the nodeId that the service resides onipAddr
- the interface that the service resides onservice
- the name of the service that was deleted- Returns:
- an Event that represents the serviceDeleted event for the give triple
-
createApplicationDeletedEvent
public static Event createApplicationDeletedEvent(String source, int applicationId, String applicationName)
Constructs a applicationDeleted Event for a given application id and name- Parameters:
source
- the source of the eventapplicationId
- the id of the deleted applicationapplicationName
- the name of the deleted application- Returns:
- an Event that represents the applicationDeleted event for the given id and name
-
getLongParm
public static long getLongParm(Event e, String parmName, long defaultValue)
Retrieve the value associated with an event parameter and parse it to a long. If the value can not be found, return a default value.- Parameters:
e
- the Event to retrieve the parameter fromparmName
- the name of the parameter to retrievedefaultValue
- the value to return if the paramter can not be retrieved or parsed- Returns:
- the value of the parameter as a long
-
getIntParm
public static int getIntParm(Event e, String parmName, int defaultValue)
Retrieve the value associated with an event parameter and parse it to an int. If the value can not be found, return a default value.- Parameters:
e
- the Event to retrieve the parameter fromparmName
- the name of the parameter to retrievedefaultValue
- the value to return if the paramter can not be retrieved or parsed- Returns:
- the value of the parameter as a long
-
getParm
public static String getParm(Event e, String parmName, String defaultValue)
Retrieve a parameter from and event, returning defaultValue of the parameter is not set.- Parameters:
e
- The Event to retrieve the parameter fromparmName
- the name of the parameter to retrievedefaultValue
- the default value to return if the parameter is not set- Returns:
- the value of the parameter, or defalutValue if the parameter is not set
-
getParm
public static String getParm(Event e, String parmName)
Return the value of an event parameter of null if it does not exist.- Parameters:
e
- the Event to get the parameter forparmName
- the name of the parameter to retrieve- Returns:
- the value of the parameter, or null of the parameter is not set
-
createNodeUpdatedEvent
public static Event createNodeUpdatedEvent(String source, Integer nodeId, String nodeLabel, OnmsNode.NodeLabelSource labelSource, String rescanExisting, String monitorKey)
createNodeUpdatedEvent
-
createNodeLocationChangedEvent
public static Event createNodeLocationChangedEvent(String source, Integer nodeId, String nodeLabel, String prevLocation, String currentLocation)
createNodeLocationChangedEvent
-
createNodeCategoryMembershipChangedEvent
public static Event createNodeCategoryMembershipChangedEvent(String source, Integer nodeId, String nodeLabel, String[] categoriesAdded, String[] categoriesDeleted)
-
toString
public static String toString(Collection<Parm> parms)
-
checkInterface
public static void checkInterface(Event e) throws InsufficientInformationException
Ensures the given event has an interface- Parameters:
e
- the event- Throws:
org.opennms.netmgt.capsd.InsufficientInformationException
- if an interface is not availableInsufficientInformationException
-
isNonIpInterface
public static boolean isNonIpInterface(String intf)
Is the given interface a non-IP interface- Parameters:
intf
- the interface- Returns:
- true/false
-
checkNodeId
public static void checkNodeId(Event e) throws InsufficientInformationException
Ensures that the given Event has a node id- Parameters:
e
- the event- Throws:
org.opennms.netmgt.capsd.InsufficientInformationException
- if a node id is not availableInsufficientInformationException
-
checkService
public static void checkService(Event e) throws InsufficientInformationException
Ensures that the given event has a service parameter- Parameters:
e
- the event to check- Throws:
org.opennms.netmgt.capsd.InsufficientInformationException
- if the event does not have a serviceInsufficientInformationException
-
createDeleteInterfaceEvent
public static Event createDeleteInterfaceEvent(String source, long nodeId, String ipAddr, int ifIndex, long txNo)
Constructs a deleteInterface event for the given nodeId, ipAddress (or ifIndex) pair.- Parameters:
source
- the source for the eventnodeId
- the nodeId of the node that owns the interfaceipAddr
- the ipAddress of the interface being deletedifIndex
- the ifIndex of the interface being deletedtxNo
- the transaction number to use for processing this event- Returns:
- an Event representing a deleteInterface event for the given nodeId, ipaddr
-
createDeleteNodeEvent
public static Event createDeleteNodeEvent(String source, long nodeId, long txNo)
-
createAssetInfoChangedEvent
public static Event createAssetInfoChangedEvent(String source, long nodeId, long txNo)
Construct a deleteNode event for the given nodeId.- Parameters:
source
- the source for the eventnodeId
- the node to be deleted.txNo
- the transaction number associated with deleting the node- Returns:
- an Event object representing a delete node event.
-
createDeleteServiceEvent
public static Event createDeleteServiceEvent(String source, long nodeId, String ipAddr, String service, long txNo)
Constructs a deleteService event for the given nodeId, ipAddress, serviceName triple.- Parameters:
source
- the source for the eventnodeId
- the nodeId of the node that service resides onipAddr
- the ipAddress of the interface the service resides onservice
- the service that is being deletedtxNo
- the transaction number to use for processing this event- Returns:
- an Event representing a deleteInterface event for the given nodeId, ipaddr
-
requireParm
public static void requireParm(Event e, String parmName) throws InsufficientInformationException
Throw an exception if an event does have the required parameter- Parameters:
e
- the event the parameter must reside onparmName
- aString
object.- Throws:
org.opennms.netmgt.capsd.InsufficientInformationException
- if the paramter is not set on the event or if its value has no contentInsufficientInformationException
-
requireParm
public static void requireParm(IEvent e, String parmName) throws InsufficientInformationException
- Throws:
InsufficientInformationException
-
checkInterface
public static void checkInterface(IEvent e) throws InsufficientInformationException
- Throws:
InsufficientInformationException
-
checkNodeId
public static void checkNodeId(IEvent e) throws InsufficientInformationException
- Throws:
InsufficientInformationException
-
checkService
public static void checkService(IEvent e) throws InsufficientInformationException
- Throws:
InsufficientInformationException
-
-