/** * Returns an Action with a name matching the string parmater * * @param actionName a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.config.vacuumd.Action} object. */ public synchronized Action getAction(String actionName) { for (Action act : getActions()) { if (act.getName().equals(actionName)) { return act; } } return null; }
/** * Returns an Automation with a name matching the string parameter * * @param autoName a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.config.vacuumd.Automation} object. */ public synchronized Automation getAutomation(String autoName) { for (Automation auto : getAutomations()) { if (auto.getName().equals(autoName)) { return auto; } } return null; }
/** * Returns a Trigger with a name matching the string parameter * * @param triggerName a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.config.vacuumd.Trigger} object. */ public synchronized Trigger getTrigger(String triggerName) { for (Trigger trig : getTriggers()) { if (trig.getName().equals(triggerName)) { return trig; } } return null; }
/** * Reload the config from the default config file * * @exception java.io.IOException * Thrown if the specified config file cannot be read/loaded * @throws java.io.IOException if any. */ public static synchronized void reload() throws IOException { if (m_loadedFromFile) { setInstance(null); init(); } }
/** * Public constructor. * * @param automation a {@link org.opennms.netmgt.config.vacuumd.Automation} object. */ @SuppressWarnings("deprecation") public AutomationProcessor(Automation automation) { m_ready = true; m_automation = automation; m_trigger = new TriggerProcessor(m_automation.getName(), VacuumdConfigFactory.getInstance().getTrigger(m_automation.getTriggerName().orElse(null))); m_action = new ActionProcessor(m_automation.getName(), VacuumdConfigFactory.getInstance().getAction(m_automation.getActionName())); m_autoEvent = new AutoEventProcessor(m_automation.getName(), VacuumdConfigFactory.getInstance().getAutoEvent(m_automation.getAutoEventName().orElse(null))); m_actionEvent = new ActionEventProcessor(m_automation.getName(),VacuumdConfigFactory.getInstance().getActionEvent(m_automation.getActionEvent().orElse(null))); }
private void initializeDataSources() throws IOException, ClassNotFoundException, PropertyVetoException, SQLException { for (Trigger trigger : getVacuumdConfig().getTriggers()) { DataSourceFactory.init(trigger.getDataSource()); } for (Action action : getVacuumdConfig().getActions()) { DataSourceFactory.init(action.getDataSource()); } }
/** * Load the config from the default config file and create the singleton * instance of this factory. * * @exception java.io.IOException * Thrown if the specified config file cannot be read * @throws java.io.IOException if any. */ public static synchronized void init() throws IOException { if (m_singleton != null) { /* * The init method has already called, so return. * To reload, reload() will need to be called. */ return; } InputStream is = null; try { is = new FileInputStream(ConfigFileConstants.getFile(ConfigFileConstants.VACUUMD_CONFIG_FILE_NAME)); setInstance(new VacuumdConfigFactory(is)); } finally { if (is != null) { IOUtils.closeQuietly(is); } } m_loadedFromFile = true; }
/** {@inheritDoc} */ @Override protected void onInit() { try { LOG.info("Loading the configuration file."); VacuumdConfigFactory.init(); getEventManager().addEventListener(this, EventConstants.RELOAD_VACUUMD_CONFIG_UEI); getEventManager().addEventListener(this, EventConstants.RELOAD_DAEMON_CONFIG_UEI); initializeDataSources(); } catch (Throwable ex) { LOG.error("Failed to load outage configuration", ex); throw new UndeclaredThrowableException(ex); } LOG.info("Vacuumd initialization complete"); createScheduler(); scheduleAutomations(); }
/** * Returns the AutoEvent associated with the auto-event-name * * @deprecated Use {@link ActionEvent} objects instead. Access these objects with {@link #getActionEvent(String)}. * @param name a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.config.vacuumd.AutoEvent} object. */ public synchronized AutoEvent getAutoEvent(String name) { for (AutoEvent ae : getAutoEvents()) { if (ae.getName().equals(name)) { return ae; } } return null; }
/** * <p>getActionEvent</p> * * @param name a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.config.vacuumd.ActionEvent} object. */ public ActionEvent getActionEvent(String name) { for (ActionEvent actionEvent : getActionEvents()) { if (actionEvent.getName().equals(name)) { return actionEvent; } } return null; } }
private void scheduleAutomations() { for (Automation auto : getVacuumdConfig().getAutomations()) { scheduleAutomation(auto); } }