use of org.opennms.netmgt.events.api.annotations.EventHandler in project opennms by OpenNMS.
the class Bsmd method handleAlarmLifecycleEvents.
@EventHandler(ueis = { EventConstants.ALARM_CREATED_UEI, EventConstants.ALARM_ESCALATED_UEI, EventConstants.ALARM_CLEARED_UEI, EventConstants.ALARM_UNCLEARED_UEI, EventConstants.ALARM_UPDATED_WITH_REDUCED_EVENT_UEI, EventConstants.ALARM_DELETED_EVENT_UEI })
public void handleAlarmLifecycleEvents(Event e) {
if (e == null || !m_hasBusinessServicesDefined) {
// in which case we don't need to perform any further handling
return;
}
final Parm alarmIdParm = e.getParm(EventConstants.PARM_ALARM_ID);
if (alarmIdParm == null || alarmIdParm.getValue() == null) {
LOG.warn("The alarmId parameter has no value on event with uei: {}. Ignoring.", e.getUei());
return;
}
int alarmId;
try {
alarmId = Integer.parseInt(alarmIdParm.getValue().getContent());
} catch (NumberFormatException ee) {
LOG.warn("Failed to retrieve the alarmId for event with uei: {}. Ignoring.", e.getUei(), ee);
return;
}
if (EventConstants.ALARM_DELETED_EVENT_UEI.equals(e.getUei())) {
handleAlarmDeleted(e, alarmId);
} else {
handleAlarmCreatedOrUpdated(e, alarmId);
}
}
use of org.opennms.netmgt.events.api.annotations.EventHandler in project opennms by OpenNMS.
the class Ackd method handleAckEvent.
/**
* Handles the event driven access to acknowledging <code>OnmsAcknowledgable</code>s. The acknowledgment event
* contains 4 parameters:
* ackUser: The user acknowledging the <code>OnmsAcknowledgable</code>
* ackAction: ack, unack, esc, clear
* ackType: <code>AckType</code. representing either an <code>OnmsAlarm</code>, <code>OnmsNotification</code>, etc.
* refId: The ID of the <code>OnmsAcknowledgable</code>
*
* @param event a {@link org.opennms.netmgt.xml.event.Event} object.
*/
@EventHandler(uei = EventConstants.ACKNOWLEDGE_EVENT_UEI)
public void handleAckEvent(Event event) {
LOG.info("handleAckEvent: Received acknowledgment event: {}", event);
OnmsAcknowledgment ack;
try {
ack = new OnmsAcknowledgment(event);
m_ackDao.processAck(ack);
} catch (ParseException e) {
LOG.error("handleAckEvent: unable to process acknowledgment event: {}", event, e);
}
}
use of org.opennms.netmgt.events.api.annotations.EventHandler in project opennms by OpenNMS.
the class Ackd method handleReloadConfigEvent.
/**
* <p>handleReloadConfigEvent</p>
*
* @param event a {@link org.opennms.netmgt.xml.event.Event} object.
*/
@EventHandler(uei = EventConstants.RELOAD_DAEMON_CONFIG_UEI)
public void handleReloadConfigEvent(Event event) {
String specifiedDaemon = null;
LOG.info("handleReloadConfigEvent: processing reload event: {}", event);
List<Parm> parms = event.getParmCollection();
for (Parm parm : parms) {
specifiedDaemon = parm.getValue().getContent();
if (EventConstants.PARM_DAEMON_NAME.equals(parm.getParmName()) && getName().equalsIgnoreCase(specifiedDaemon)) {
LOG.debug("handleReloadConfigEvent: reload event is for this daemon: {}; reloading configuration...", getName());
try {
m_configDao.reloadConfiguration();
EventBuilder bldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, getName(), Calendar.getInstance().getTime());
bldr.addParam(EventConstants.PARM_DAEMON_NAME, getName());
m_eventForwarder.sendNow(bldr.getEvent());
LOG.debug("handleReloadConfigEvent: restarting readers due to reload configuration event...");
this.restartReaders(true);
} catch (Throwable e) {
LOG.error("handleReloadConfigEvent: ", e);
EventBuilder bldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_FAILED_UEI, getName(), Calendar.getInstance().getTime());
bldr.addParam(EventConstants.PARM_DAEMON_NAME, getName());
bldr.addParam(EventConstants.PARM_REASON, e.getLocalizedMessage().substring(0, 128));
m_eventForwarder.sendNow(bldr.getEvent());
}
LOG.debug("handleReloadConfigEvent: configuration reloaded.");
// return here because we are done.
return;
}
}
LOG.debug("handleReloadConfigEvent: reload event not for this daemon: {}; daemon specified is: {}", getName(), specifiedDaemon);
}
use of org.opennms.netmgt.events.api.annotations.EventHandler in project opennms by OpenNMS.
the class RancidProvisioningAdapter method handleReloadConfigEvent.
/**
* <p>handleReloadConfigEvent</p>
*
* @param event a {@link org.opennms.netmgt.xml.event.Event} object.
*/
@EventHandler(uei = EventConstants.RELOAD_DAEMON_CONFIG_UEI)
public void handleReloadConfigEvent(Event event) {
if (isReloadConfigEventTarget(event)) {
EventBuilder ebldr = null;
LOG.debug("reloading the rancid adapter configuration");
try {
RancidAdapterConfigFactory.init();
final RancidAdapterConfigFactory factory = RancidAdapterConfigFactory.getInstance();
factory.getWriteLock().lock();
try {
factory.update();
m_template.execute(new TransactionCallbackWithoutResult() {
@Override
public void doInTransactionWithoutResult(TransactionStatus arg0) {
buildRancidNodeMap();
}
});
} finally {
factory.getWriteLock().unlock();
}
ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, "Provisiond.RancidProvisioningAdapter");
ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "Provisiond.RancidProvisioningAdapter");
} catch (Throwable e) {
LOG.info("unable to reload rancid adapter configuration", e);
ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_FAILED_UEI, "Provisiond.RancidProvisioningAdapter");
ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "Provisiond.RancidProvisioningAdapter");
ebldr.addParam(EventConstants.PARM_REASON, e.getLocalizedMessage().substring(1, 128));
}
if (ebldr != null) {
getEventForwarder().sendNow(ebldr.getEvent());
}
}
}
use of org.opennms.netmgt.events.api.annotations.EventHandler in project opennms by OpenNMS.
the class Reportd method handleRunReportEvent.
/**
* <p>handleRunReportEvent</p>
*
* @param e a {@link org.opennms.netmgt.xml.event.Event} object.
*/
@EventHandler(uei = EventConstants.REPORTD_RUN_REPORT)
public void handleRunReportEvent(Event e) {
String reportName = "";
for (Parm parm : e.getParmCollection()) {
if (EventConstants.PARM_REPORT_NAME.equals(parm.getParmName()))
reportName = parm.getValue().getContent();
else
LOG.info("Unknown Event Constant: {}", parm.getParmName());
}
if (!"".equals(reportName)) {
LOG.debug("running report {}", reportName);
runReport(reportName);
} else {
LOG.error("Can not run report -- reportName not specified");
}
}
Aggregations