public abstract class EventUtils extends Object
Constructor and Description |
---|
EventUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addEventListener(EventListener listener,
List<String> ueiList)
Make the given listener object a listener for the list of events
referenced in the ueiList.
|
static void |
addParam(Event event,
String parmName,
Object pollResultId)
addParam
|
static void |
checkEventId(Event e)
Ensures that the event has a database eventId
|
static void |
checkHost(Event e)
Ensures the given event has a host
|
static void |
checkInterface(Event e)
Ensures the given event has an interface
|
static void |
checkInterfaceOrIfIndex(Event e)
Ensures the given event has an interface or ifIndex
|
static void |
checkNodeId(Event e)
Ensures that the given Event has a node id
|
static void |
checkService(Event e)
Ensures that the given event has a service parameter
|
static Event |
createAddInterfaceEvent(String source,
String nodeLabel,
String ipaddr,
String hostName,
long txNo)
This method is responsible for generating an addInterface event and
sending it to eventd..
|
static Event |
createAndSendDeleteInterfaceEvent(String source,
String nodeLabel,
String ipaddr,
String hostName,
long txNo)
This method is responsible for generating a deleteInterface event and
sending it to eventd..
|
static Event |
createAndSendDeleteNodeEvent(String source,
String nodeLabel,
String hostName,
long txNo)
This method is responsible for generating a deleteNode event and sending
it to eventd..
|
static Event |
createAndSendDeleteServiceEvent(String source,
DbNodeEntry nodeEntry,
InetAddress ifaddr,
String service,
String hostName,
long txNo)
This method is responsible for generating a deleteService event and
sending it to eventd..
|
static Event |
createAndSendInterfaceDeletedEvent(String source,
int nodeId,
String ipaddr,
String hostName,
long txNo)
This method is responsible for generating an interfaceDeleted event and
sending it to eventd...
|
static Event |
createAssetInfoChangedEvent(String source,
long nodeId,
long txNo)
Construct a deleteNode event for the given nodeId.
|
static Event |
createChangeServiceEvent(String source,
String ipaddr,
String service,
String action,
String hostName,
long txNo)
This method is responsible for generating a changeService event and
sending it to eventd..
|
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)
Construct a deleteNode event for the given nodeId.
|
static Event |
createDeleteServiceEvent(String source,
long nodeId,
String ipAddr,
String service,
long txNo)
Constructs a deleteService event for the given nodeId, ipAddress,
serivcename triple.
|
static Event |
createForceRescanEvent(String hostName,
long nodeId)
This method is responsible for generating a forceRescan event and sending
it to eventd..
|
static Event |
createInterfaceDeletedEvent(String source,
long nodeId,
String ipAddr,
int ifIndex,
long txNo)
Construct an interfaceDeleted event for an interface.
|
static Event |
createInterfaceDeletedEvent(String source,
long nodeId,
String ipAddr,
long txNo)
Construct an interfaceDeleted event for an interface.
|
static Event |
createNodeAddedEvent(DbNodeEntry nodeEntry)
This method is responsible for generating a nodeAdded event and sending
it to eventd..
|
static Event |
createNodeAddedEvent(int nodeId,
String nodeLabel,
OnmsNode.NodeLabelSource labelSource)
createNodeAddedEvent
|
static Event |
createNodeAddedEvent(String source,
int nodeId,
String nodeLabel,
OnmsNode.NodeLabelSource labelSource)
createNodeAddedEvent
|
static Event |
createNodeDeletedEvent(String source,
int nodeId,
String hostName,
String nodeLabel,
long txNo)
This method is responsible for generating a nodeDeleted event and sending
it to eventd..
|
static Event |
createNodeDeletedEvent(String source,
long nodeId,
long txNo)
Construct a nodeDeleteed event for the given nodeId
|
static Event |
createNodeGainedInterfaceEvent(DbNodeEntry nodeEntry,
InetAddress ifaddr)
This method is responsible for generating a nodeGainedInterface event and
sending it to eventd..
|
static Event |
createNodeGainedInterfaceEvent(String source,
int nodeId,
InetAddress ifaddr)
createNodeGainedInterfaceEvent
|
static Event |
createNodeGainedServiceEvent(DbNodeEntry nodeEntry,
InetAddress ifaddr,
String service,
long txNo)
This method is responsible for generating a nodeGainedService event and
sending it to eventd..
|
static Event |
createNodeGainedServiceEvent(String source,
int nodeId,
InetAddress ifaddr,
String service,
String nodeLabel,
OnmsNode.NodeLabelSource labelSource,
String sysName,
String sysDescr)
createNodeGainedServiceEvent
|
static Event |
createServiceDeletedEvent(String source,
long nodeId,
String ipAddr,
String service,
long txNo)
Constructs a serviceDeleted Event for the nodeId, ipAddr, serviceName
triple
|
static long |
getEventID(Event e)
Get the eventId for the given event
|
static int |
getIntParm(Event e,
String parmName)
getIntParm
|
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 long |
getNodeId(Event e)
Return the nodeId of the node associated with and event, or -1 of no node
is associated.
|
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 interface
|
static void |
requireParm(Event e,
String parmName)
Throw an exception if an event does have the required parameter
|
static void |
sendEvent(Event newEvent,
String callerUei,
long txNo,
boolean isXmlRpcEnabled)
Send an event to the Event manaager to be broadcast to interested
listeners
|
static String |
toString(Event event)
Deprecated.
Use org.opennms.netmgt.model.events.EventUtils.toString(event) instead.
|
static String |
toString(Snmp snmp)
Deprecated.
Use org.opennms.netmgt.model.events.EventUtils.toString(snmp) instead.
|
static String |
toString(Value value)
Deprecated.
Use org.opennms.netmgt.model.events.EventUtils.toString(value) instead.
|
public static void addEventListener(EventListener listener, List<String> ueiList)
listener
- the lister to addueiList
- the list of events the listener is interestedpublic static void checkEventId(Event e) throws InsufficientInformationException
e
- the eventInsufficientInformationException
- if an event id is not evailablepublic static void checkInterface(Event e) throws InsufficientInformationException
e
- the eventInsufficientInformationException
- if an interface is not availablepublic static boolean isNonIpInterface(String intf)
intf
- the interfacepublic static void checkInterfaceOrIfIndex(Event e) throws InsufficientInformationException
e
- the eventInsufficientInformationException
- if neither an interface nor an ifIndex is availablepublic static void checkHost(Event e) throws InsufficientInformationException
e
- the eventInsufficientInformationException
- if an interface is not availablepublic static void checkNodeId(Event e) throws InsufficientInformationException
e
- the eventInsufficientInformationException
- if a node id is not availablepublic static void checkService(Event e) throws InsufficientInformationException
e
- the event to checkInsufficientInformationException
- if the event does not have a servicepublic static Event createDeleteInterfaceEvent(String source, long nodeId, String ipAddr, int ifIndex, long txNo)
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 eventpublic static Event createDeleteNodeEvent(String source, long nodeId, long txNo)
source
- the source for the eventnodeId
- the node to be deleted.txNo
- the transaction number associated with deleting the nodepublic static Event createAssetInfoChangedEvent(String source, long nodeId, long txNo)
source
- the source for the eventnodeId
- the node to be deleted.txNo
- the transaction number associated with deleting the nodepublic static Event createInterfaceDeletedEvent(String source, long nodeId, String ipAddr, long txNo)
source
- the source of the eventnodeId
- the nodeId of the node the interface resides inipAddr
- the ipAdddr of the eventtxNo
- a transaction number associated with the eventpublic static Event createInterfaceDeletedEvent(String source, long nodeId, String ipAddr, int ifIndex, long txNo)
source
- the source of the eventnodeId
- the nodeId of the node the interface resides inipAddr
- the ipAdddr of the eventifIndex
- the ifIndex of the eventtxNo
- a transaction number associated with the eventpublic static Event createNodeDeletedEvent(String source, long nodeId, long txNo)
source
- the source for the eventnodeId
- the id of the node being deletedtxNo
- a transaction number associated with the eventpublic static Event createServiceDeletedEvent(String source, long nodeId, String ipAddr, String service, long txNo)
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 deletedtxNo
- a transaction number associated with the eventpublic static long getEventID(Event e)
e
- the event to get the eventId forpublic static long getLongParm(Event e, String parmName, long defaultValue)
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
parsedpublic static int getIntParm(Event e, String parmName, int defaultValue)
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
parsedpublic static long getNodeId(Event e)
e
- the eventpublic static String getParm(Event e, String parmName)
e
- the Event to get the parameter forparmName
- the name of the parameter to retrievepublic static String getParm(Event e, String parmName, String defaultValue)
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 setpublic static void requireParm(Event e, String parmName) throws InsufficientInformationException
e
- the event the parameter must reside onparmName
- a String
object.InsufficientInformationException
- if the paramter is not set on the event or if its value has
no contentpublic static void sendEvent(Event newEvent, String callerUei, long txNo, boolean isXmlRpcEnabled)
newEvent
- the event to sendisXmlRpcEnabled
- a boolean.callerUei
- a String
object.txNo
- a long.public static Event createNodeAddedEvent(DbNodeEntry nodeEntry)
nodeEntry
- The node Added.Event
object.public static Event createNodeAddedEvent(int nodeId, String nodeLabel, OnmsNode.NodeLabelSource labelSource)
createNodeAddedEvent
public static Event createNodeAddedEvent(String source, int nodeId, String nodeLabel, OnmsNode.NodeLabelSource labelSource)
createNodeAddedEvent
public static Event createNodeGainedInterfaceEvent(DbNodeEntry nodeEntry, InetAddress ifaddr)
nodeEntry
- The node that gained the interface.ifaddr
- the interface gained on the node.Event
object.public static Event createNodeGainedInterfaceEvent(String source, int nodeId, InetAddress ifaddr)
createNodeGainedInterfaceEvent
source
- a String
object.nodeId
- a int.ifaddr
- a InetAddress
object.Event
object.public static Event createNodeDeletedEvent(String source, int nodeId, String hostName, String nodeLabel, long txNo)
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.txNo
- a long.Event
object.public static Event createAndSendDeleteNodeEvent(String source, String nodeLabel, String hostName, long txNo)
source
- the source of the eventnodeLabel
- the nodelabel of the deleted node.hostName
- the Host server name.txNo
- the external transaction No of the event.Event
object.public static Event createForceRescanEvent(String hostName, long nodeId)
hostName
- the Host server name.nodeId
- the node ID of the node to rescan.Event
object.public static Event createAndSendInterfaceDeletedEvent(String source, int nodeId, String ipaddr, String hostName, long txNo)
source
- the source of the eventnodeId
- Nodeid of the node that the deleted interface resides on.ipaddr
- the ipaddress of the deleted Interface.hostName
- the Host server name.txNo
- the external transaction No. of the original event.Event
object.public static Event createNodeGainedServiceEvent(DbNodeEntry nodeEntry, InetAddress ifaddr, String service, long txNo)
nodeEntry
- The node that gained the service.ifaddr
- the interface gained the service.service
- the service gained.txNo
- the transaction no.Event
object.public static Event createNodeGainedServiceEvent(String source, int nodeId, InetAddress ifaddr, String service, String nodeLabel, OnmsNode.NodeLabelSource labelSource, String sysName, String sysDescr)
createNodeGainedServiceEvent
public static Event createAndSendDeleteServiceEvent(String source, DbNodeEntry nodeEntry, InetAddress ifaddr, String service, String hostName, long txNo)
source
- the source of the eventnodeEntry
- The node that the service to get deleted on.ifaddr
- the interface the service to get deleted on.service
- the service to delete.hostName
- set to the host field in the eventtxNo
- the transaction no.Event
object.public static Event createAddInterfaceEvent(String source, String nodeLabel, String ipaddr, String hostName, long txNo)
source
- the source of the eventnodeLabel
- the node label of the node where the interface resides.ipaddr
- IP address of the interface to be added.hostName
- the Host server name.txNo
- the exteranl transaction numberEvent
object.public static Event createAndSendDeleteInterfaceEvent(String source, String nodeLabel, String ipaddr, String hostName, long txNo)
source
- the source of the eventnodeLabel
- the node label of the node where the interface resides.ipaddr
- IP address of the interface to be deleted.hostName
- the Host server name.txNo
- the external transaction No.Event
object.public static Event createChangeServiceEvent(String source, String ipaddr, String service, String action, String hostName, long txNo)
source
- the source of the eventipaddr
- IP address of the interface where the service resides.service
- the service to be changed(add or remove).action
- what operation to perform for the service/interface pair.hostName
- sets the host field of the eventtxNo
- the external transaction No.Event
object.public static Event createDeleteServiceEvent(String source, long nodeId, String ipAddr, String service, long txNo)
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 eventpublic static String toString(Event event)
toString
public static String toString(Value value)
toString
public static String toString(Snmp snmp)
toString
Copyright © 2017. All rights reserved.