use of org.opennms.netmgt.events.api.annotations.EventHandler in project opennms by OpenNMS.
the class DataSender method handleRtcSubscribe.
/**
* Inform the data sender of the new listener
*/
@EventHandler(uei = EventConstants.RTC_SUBSCRIBE_EVENT_UEI)
public void handleRtcSubscribe(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 clabel = null;
String user = null;
String passwd = 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;
} else if (parmName.equals(EventConstants.PARM_CAT_LABEL)) {
clabel = parmContent;
} else if (parmName.equals(EventConstants.PARM_USER)) {
user = parmContent;
} else if (parmName.equals(EventConstants.PARM_PASSWD)) {
passwd = parmContent;
}
}
// check that we got all required parms
if (url == null || clabel == null || user == null || passwd == null) {
LOG.warn("{} did not have all required information. Values contained url: {} catlabel: {} user: {} passwd: {}", event.getUei(), url, clabel, user, passwd);
} else {
subscribe(url, clabel, user, passwd);
LOG.debug("{} subscribed {}: {}: {}", event.getUei(), url, clabel, user);
}
}
use of org.opennms.netmgt.events.api.annotations.EventHandler in project opennms by OpenNMS.
the class SnmpPoller method reloadSnmpConfig.
/**
* <p>reloadSnmpConfig</p>
*
* @param event a {@link org.opennms.netmgt.xml.event.Event} object.
*/
@EventHandler(uei = EventConstants.CONFIGURE_SNMP_EVENT_UEI)
public void reloadSnmpConfig(Event event) {
LOG.debug("reloadSnmpConfig: managing event: {}", event.getUei());
try {
Thread.sleep(5000);
} catch (final InterruptedException e) {
LOG.debug("interrupted while waiting for reload", e);
Thread.currentThread().interrupt();
}
SnmpEventInfo info = null;
try {
info = new SnmpEventInfo(event);
if (StringUtils.isBlank(info.getFirstIPAddress())) {
LOG.error("configureSNMPHandler: event contained invalid firstIpAddress. {}", event);
return;
}
} catch (final Throwable e) {
LOG.error("reloadSnmpConfig: ", e);
return;
}
final IPAddressRange range = new IPAddressRange(info.getFirstIPAddress(), info.getLastIPAddress());
for (final IPAddress ipaddr : range) {
LOG.debug("reloadSnmpConfig: found ipaddr: {}", ipaddr);
if (getNetwork().hasPollableInterface(ipaddr.toDbString())) {
LOG.debug("reloadSnmpConfig: recreating the Interface to poll: {}", ipaddr);
getNetwork().delete(ipaddr.toDbString());
scheduleNewSnmpInterface(ipaddr.toDbString());
} else {
LOG.debug("reloadSnmpConfig: no Interface found for ipaddr: {}", ipaddr);
}
}
}
use of org.opennms.netmgt.events.api.annotations.EventHandler in project opennms by OpenNMS.
the class Tl1d method handleRelooadConfigurationEvent.
/**
* <p>handleRelooadConfigurationEvent</p>
*
* @param e a {@link org.opennms.netmgt.xml.event.Event} object.
*/
@EventHandler(uei = EventConstants.RELOAD_DAEMON_CONFIG_UEI)
public void handleRelooadConfigurationEvent(Event e) {
if (isReloadConfigEventTarget(e)) {
EventBuilder ebldr = null;
try {
stopListeners();
removeClients();
/*
* leave everything currently on the queue, no need to mess with that, might want a handler
* someday for emptying the current queue on a reload event or even a pause clients or something.
*
* Don't interrupt message processor, it simply waits on the queue from something to be added.
*
*/
m_configurationDao.update();
initializeTl1Connections();
startClients();
LOG.debug("handleReloadConfigurationEvent: {} defined.", m_tl1Clients.size());
LOG.info("handleReloadConfigurationEvent: completed.");
ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, getName());
ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "Tl1d");
} catch (Throwable exception) {
LOG.error("handleReloadConfigurationEvent: failed.", exception);
ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_FAILED_UEI, getName());
ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "Tl1d");
ebldr.addParam(EventConstants.PARM_REASON, exception.getLocalizedMessage().substring(1, 128));
}
if (ebldr != null) {
m_eventForwarder.sendNow(ebldr.getEvent());
}
}
}
use of org.opennms.netmgt.events.api.annotations.EventHandler in project opennms by OpenNMS.
the class Provisioner method handleNodeUpdated.
/**
* <p>handleNodeUpdated</p>
* A re-import has occurred, attempt a rescan now.
*
* @param e a {@link org.opennms.netmgt.xml.event.Event} object.
*/
@EventHandler(uei = EventConstants.NODE_UPDATED_EVENT_UEI)
public void handleNodeUpdated(Event e) {
LOG.debug("Node updated event received: {}", e);
if (!Boolean.valueOf(System.getProperty(SCHEDULE_RESCAN_FOR_UPDATED_NODES, "true"))) {
LOG.debug("Rescanning updated nodes is disabled via property: {}", SCHEDULE_RESCAN_FOR_UPDATED_NODES);
return;
}
// Default
String rescanExisting = Boolean.TRUE.toString();
for (Parm parm : e.getParmCollection()) {
if (EventConstants.PARM_RESCAN_EXISTING.equals(parm.getParmName()) && ("false".equalsIgnoreCase(parm.getValue().getContent()) || "dbonly".equalsIgnoreCase(parm.getValue().getContent()))) {
rescanExisting = Boolean.FALSE.toString();
}
}
if (!Boolean.valueOf(rescanExisting)) {
LOG.debug("Rescanning updated nodes is disabled via event parameter: {}", EventConstants.PARM_RESCAN_EXISTING);
return;
}
removeNodeFromScheduleQueue(new Long(e.getNodeid()).intValue());
NodeScanSchedule scheduleForNode = getProvisionService().getScheduleForNode(e.getNodeid().intValue(), true);
if (scheduleForNode != null) {
addToScheduleQueue(scheduleForNode);
}
}
use of org.opennms.netmgt.events.api.annotations.EventHandler in project opennms by OpenNMS.
the class InterfaceToNodeCacheEventProcessor method handleNodeGainedInterface.
@EventHandler(uei = EventConstants.NODE_GAINED_INTERFACE_EVENT_UEI)
@Transactional
public void handleNodeGainedInterface(Event event) {
LOG.debug("Received event: {}", event.getUei());
Long nodeId = event.getNodeid();
if (nodeId == null) {
LOG.error(EventConstants.NODE_GAINED_INTERFACE_EVENT_UEI + ": Event with no node ID: " + event.toString());
return;
}
OnmsNode node = m_nodeDao.get(nodeId.intValue());
if (node == null) {
LOG.warn(EventConstants.NODE_GAINED_INTERFACE_EVENT_UEI + ": Cannot find node in DB: " + nodeId);
return;
}
// add to known nodes
m_cache.setNodeId(node.getLocation().getLocationName(), event.getInterfaceAddress(), nodeId.intValue());
}
Aggregations