Search in sources :

Example 21 with EventHandler

use of org.opennms.netmgt.events.api.annotations.EventHandler 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);
    }
}
Also used : Value(org.opennms.netmgt.xml.event.Value) Parm(org.opennms.netmgt.xml.event.Parm) EventHandler(org.opennms.netmgt.events.api.annotations.EventHandler)

Example 22 with EventHandler

use of org.opennms.netmgt.events.api.annotations.EventHandler in project opennms by OpenNMS.

the class SnmpPoller method primarychangeHandler.

/**
 * <p>primarychangeHandler</p>
 *
 * @param event a {@link org.opennms.netmgt.xml.event.Event} object.
 */
@EventHandler(uei = EventConstants.PRIMARY_SNMP_INTERFACE_CHANGED_EVENT_UEI)
public void primarychangeHandler(Event event) {
    LOG.debug("primarychangeHandler: managing event: {}", event.getUei());
    getNetwork().delete(Long.valueOf(event.getNodeid()).intValue());
    for (Parm parm : event.getParmCollection()) {
        if (parm.isValid() && parm.getParmName().equals("newPrimarySnmpAddress")) {
            scheduleNewSnmpInterface(parm.getValue().getContent());
            return;
        }
    }
}
Also used : Parm(org.opennms.netmgt.xml.event.Parm) EventHandler(org.opennms.netmgt.events.api.annotations.EventHandler)

Example 23 with EventHandler

use of org.opennms.netmgt.events.api.annotations.EventHandler in project opennms by OpenNMS.

the class Statsd method handleReloadConfigEvent.

/**
 * <p>handleReloadConfigEvent</p>
 *
 * @param e a {@link org.opennms.netmgt.xml.event.Event} object.
 */
@EventHandler(uei = EventConstants.RELOAD_DAEMON_CONFIG_UEI)
public void handleReloadConfigEvent(Event e) {
    if (isReloadConfigEventTarget(e)) {
        LOG.info("handleReloadConfigEvent: reloading configuration...");
        EventBuilder ebldr = null;
        LOG.debug("handleReloadConfigEvent: acquiring lock...");
        synchronized (m_scheduler) {
            try {
                LOG.debug("handleReloadConfigEvent: lock acquired, unscheduling current reports...");
                unscheduleReports();
                m_reportDefinitionBuilder.reload();
                LOG.debug("handleReloadConfigEvent: config remarshaled, unscheduling current reports...");
                LOG.debug("handleReloadConfigEvent: reports unscheduled, rescheduling...");
                start();
                LOG.debug("handleRelodConfigEvent: reports rescheduled.");
                ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, "Statsd");
                ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "Statsd");
            } catch (Throwable exception) {
                LOG.error("handleReloadConfigurationEvent: Error reloading configuration", exception);
                ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_FAILED_UEI, "Statsd");
                ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "Statsd");
                ebldr.addParam(EventConstants.PARM_REASON, exception.getLocalizedMessage().substring(1, 128));
            }
            if (ebldr != null) {
                getEventForwarder().sendNow(ebldr.getEvent());
            }
        }
        LOG.debug("handleReloadConfigEvent: lock released.");
    }
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) EventHandler(org.opennms.netmgt.events.api.annotations.EventHandler)

Aggregations

EventHandler (org.opennms.netmgt.events.api.annotations.EventHandler)23 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)9 Parm (org.opennms.netmgt.xml.event.Parm)8 OnmsNode (org.opennms.netmgt.model.OnmsNode)3 Transactional (org.springframework.transaction.annotation.Transactional)3 ExecutionException (java.util.concurrent.ExecutionException)2 Task (org.opennms.core.tasks.Task)2 Value (org.opennms.netmgt.xml.event.Value)2 Method (java.lang.reflect.Method)1 InetAddress (java.net.InetAddress)1 ParseException (java.text.ParseException)1 IPAddress (org.opennms.core.network.IPAddress)1 IPAddressRange (org.opennms.core.network.IPAddressRange)1 RancidAdapterConfigFactory (org.opennms.netmgt.config.RancidAdapterConfigFactory)1 SnmpEventInfo (org.opennms.netmgt.config.SnmpEventInfo)1 OnmsAcknowledgment (org.opennms.netmgt.model.OnmsAcknowledgment)1 Event (org.opennms.netmgt.xml.event.Event)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)1