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());
}
}
}
Aggregations