use of org.opennms.netmgt.xml.event.Value in project opennms by OpenNMS.
the class PollerEventProcessor method nodeDeletedHandler.
/**
* This method is responsible for removing the node specified in the
* nodeDeleted event from the Poller's pollable node map.
*/
private void nodeDeletedHandler(Event event) {
Long nodeId = event.getNodeid();
final String sourceUei = event.getUei();
// Extract node label and transaction No. from the event parms
long txNo = -1L;
String parmName = null;
Value parmValue = null;
String parmContent = null;
for (Parm parm : event.getParmCollection()) {
parmName = parm.getParmName();
parmValue = parm.getValue();
if (parmValue == null)
continue;
else
parmContent = parmValue.getContent();
// get the external transaction number
if (parmName.equals(EventConstants.PARM_TRANSACTION_NO)) {
String temp = parmContent;
LOG.debug("nodeDeletedHandler: parmName: {} /parmContent: {}", parmName, parmContent);
try {
txNo = Long.valueOf(temp).longValue();
} catch (final NumberFormatException nfe) {
LOG.warn("nodeDeletedHandler: Parameter {} cannot be non-numeric", EventConstants.PARM_TRANSACTION_NO, nfe);
txNo = -1;
}
}
}
Date closeDate = event.getTime();
getPoller().getQueryManager().closeOutagesForNode(closeDate, event.getDbid(), nodeId.intValue());
PollableNode node = getNetwork().getNode(nodeId.intValue());
if (node == null) {
LOG.error("Nodeid {} does not exist in pollable node map, unable to delete node.", nodeId);
return;
}
node.delete();
}
use of org.opennms.netmgt.xml.event.Value in project opennms by OpenNMS.
the class DataSender method handleRtcUnsubscribe.
/**
* Inform the data sender of the listener unsubscribing
*/
@EventHandler(uei = EventConstants.RTC_UNSUBSCRIBE_EVENT_UEI)
public void handleRtcUnsubscribe(Event event) {
List<Parm> list = event.getParmCollection();
if (list == null) {
LOG.warn("{} ignored - info incomplete (null event parms)", event.getUei());
return;
}
String url = null;
String parmName = null;
Value parmValue = null;
String parmContent = null;
for (Parm parm : list) {
parmName = parm.getParmName();
parmValue = parm.getValue();
if (parmValue == null)
continue;
else
parmContent = parmValue.getContent();
if (parmName.equals(EventConstants.PARM_URL)) {
url = parmContent;
}
}
// check that we got the required parameter
if (url == null) {
LOG.warn("{} did not have required information. Value of url: {}", event.getUei(), url);
} else {
unsubscribe(url);
LOG.debug("{} unsubscribed {}", event.getUei(), url);
}
}
use of org.opennms.netmgt.xml.event.Value in project opennms by OpenNMS.
the class DataUpdater method handleInterfaceReparented.
/**
* Record the interfaceReparented info in the datastore
*/
private void handleInterfaceReparented(InetAddress ip, List<Parm> list) {
if (ip == null || list == null) {
LOG.warn("{} ignored - info incomplete - ip/parms: {}/{}", m_event.getUei(), InetAddressUtils.str(ip), list);
return;
}
// old node ID
int oldNodeId = -1;
// new node ID
int newNodeId = -1;
String parmName = null;
Value parmValue = null;
String parmContent = null;
for (Parm parm : list) {
parmName = parm.getParmName();
parmValue = parm.getValue();
if (parmValue == null)
continue;
else
parmContent = parmValue.getContent();
// old node ID
if (parmName.equals(EventConstants.PARM_OLD_NODEID)) {
String temp = parmContent;
try {
oldNodeId = Integer.parseInt(temp);
} catch (NumberFormatException nfe) {
LOG.warn("Parameter {} cannot be non-numeric", EventConstants.PARM_OLD_NODEID, nfe);
oldNodeId = -1;
}
} else // new node ID
if (parmName.equals(EventConstants.PARM_NEW_NODEID)) {
String temp = parmContent;
try {
newNodeId = Integer.parseInt(temp);
} catch (NumberFormatException nfe) {
LOG.warn("Parameter {} cannot be non-numeric", EventConstants.PARM_NEW_NODEID, nfe);
newNodeId = -1;
}
}
}
if (oldNodeId == -1 || newNodeId == -1) {
LOG.warn("{} did not have all required information for {} Values contained old nodeid: {} new nodeid: {}", m_event.getUei(), InetAddressUtils.str(ip), oldNodeId, newNodeId);
} else {
m_dataManager.interfaceReparented(ip, oldNodeId, newNodeId);
LOG.debug("{} reparented ip: {} from {} to {}", m_event.getUei(), InetAddressUtils.str(ip), oldNodeId, newNodeId);
}
}
use of org.opennms.netmgt.xml.event.Value in project opennms by OpenNMS.
the class Collectd method handleInterfaceReparented.
/**
* This method is responsible for processing 'interfacReparented' events.
* An 'interfaceReparented' event will have old and new nodeId parms
* associated with it. All CollectableService objects in the service
* updates map which match the event's interface address and the SNMP
* service have a reparenting update associated with them. When the
* scheduler next pops one of these services from an interval queue for
* collection all of the RRDs associated with the old nodeId are moved
* under the new nodeId and the nodeId of the collectable service is
* updated to reflect the interface's new parent nodeId.
*
* @param event
* The event to process.
* @throws InsufficientInformationException
*/
private void handleInterfaceReparented(Event event) throws InsufficientInformationException {
EventUtils.checkNodeId(event);
EventUtils.checkInterface(event);
LOG.debug("interfaceReparentedHandler: processing interfaceReparented event for {}", event.getInterface());
// Verify that the event has an interface associated with it
if (event.getInterface() == null)
return;
// Extract the old and new nodeId's from the event parms
String oldNodeIdStr = null;
String newNodeIdStr = null;
String parmName = null;
Value parmValue = null;
String parmContent = null;
for (Parm parm : event.getParmCollection()) {
parmName = parm.getParmName();
parmValue = parm.getValue();
if (parmValue == null)
continue;
else
parmContent = parmValue.getContent();
// old nodeid
if (parmName.equals(EventConstants.PARM_OLD_NODEID)) {
oldNodeIdStr = parmContent;
} else // new nodeid
if (parmName.equals(EventConstants.PARM_NEW_NODEID)) {
newNodeIdStr = parmContent;
}
}
//
if (oldNodeIdStr == null || newNodeIdStr == null) {
LOG.warn("interfaceReparentedHandler: old and new nodeId parms are required, unable to process.");
return;
}
// Iterate over the CollectableService objects in the services
// list looking for entries which share the same interface
// address as the reparented interface. Mark any matching objects
// for reparenting.
//
// The next time the service is scheduled for execution it
// will move all of the RRDs associated
// with the old nodeId under the new nodeId and update the service's
// SnmpMonitor.NodeInfo attribute to reflect the new nodeId. All
// subsequent collections will then be updating the appropriate RRDs.
//
OnmsIpInterface iface = null;
synchronized (getCollectableServices()) {
CollectableService cSvc = null;
Iterator<CollectableService> iter = getCollectableServices().iterator();
while (iter.hasNext()) {
cSvc = iter.next();
InetAddress addr = (InetAddress) cSvc.getAddress();
if (addr.equals(event.getInterfaceAddress())) {
synchronized (cSvc) {
// Got a match!
LOG.debug("interfaceReparentedHandler: got a CollectableService match for {}", event.getInterface());
// Retrieve the CollectorUpdates object associated
// with
// this CollectableService.
CollectorUpdates updates = cSvc.getCollectorUpdates();
if (iface == null) {
iface = getIpInterface(event.getNodeid().intValue(), event.getInterface());
}
// Now set the reparenting flag
updates.markForReparenting(oldNodeIdStr, newNodeIdStr, iface);
LOG.debug("interfaceReparentedHandler: marking {} for reparenting for service SNMP.", event.getInterface());
}
}
}
}
LOG.debug("interfaceReparentedHandler: processing of interfaceReparented event for interface {} completed.", event.getInterface());
}
use of org.opennms.netmgt.xml.event.Value in project opennms by OpenNMS.
the class EventBuilder method setParam.
/**
* <p>setParam</p>
*
* @param parmName a {@link java.lang.String} object.
* @param val a {@link java.lang.String} object.
* @return a {@link org.opennms.netmgt.model.events.EventBuilder} object.
*/
public EventBuilder setParam(final String parmName, final String val) {
if (m_event.getParmCollection().size() < 1) {
return addParam(parmName, val);
}
for (final Parm parm : m_event.getParmCollection()) {
if (parm.getParmName().equals(parmName)) {
final Value value = new Value();
value.setContent(val);
parm.setValue(value);
return this;
}
}
return addParam(parmName, val);
}
Aggregations