Search in sources :

Example 1 with RancidAdapterConfigFactory

use of org.opennms.netmgt.config.RancidAdapterConfigFactory 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());
        }
    }
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) RancidAdapterConfigFactory(org.opennms.netmgt.config.RancidAdapterConfigFactory) TransactionStatus(org.springframework.transaction.TransactionStatus) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) EventHandler(org.opennms.netmgt.events.api.annotations.EventHandler)

Aggregations

RancidAdapterConfigFactory (org.opennms.netmgt.config.RancidAdapterConfigFactory)1 EventHandler (org.opennms.netmgt.events.api.annotations.EventHandler)1 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)1