Class AutomationProcessor

  • All Implemented Interfaces:
    Runnable, ReadyRunnable

    public class AutomationProcessor
    extends Object
    implements ReadyRunnable
    This class used to process automations configured in the vacuumd-configuration.xml file. Automations are identified by a name and they reference Triggers and Actions by name, as well. Autmations also have an interval attribute that determines how often they run.
    Version:
    $Id: $
    Author:
    David Hustace
    • Constructor Detail

      • AutomationProcessor

        public AutomationProcessor​(Automation automation)
        Public constructor.
        Parameters:
        automation - a Automation object.
    • Method Detail

      • getAction

        public org.opennms.netmgt.vacuumd.AutomationProcessor.ActionProcessor getAction()

        getAction

        Returns:
        a AutomationProcessor.ActionProcessor object.
      • getTrigger

        public org.opennms.netmgt.vacuumd.AutomationProcessor.TriggerProcessor getTrigger()

        getTrigger

        Returns:
        a AutomationProcessor.TriggerProcessor object.
      • run

        public void run()

        run

        Specified by:
        run in interface Runnable
      • runAutomation

        public boolean runAutomation()
                              throws SQLException
        Called by the run method to execute the sql statements of triggers and actions defined for an automation. An automation may have 0 or 1 trigger and must have 1 action. If the automation doesn't have a trigger than the action must not contain any tokens.
        Returns:
        a boolean.
        Throws:
        SQLException - if any.
      • verifyRowCount

        protected boolean verifyRowCount​(ResultSet triggerResultSet)
                                  throws SQLException

        verifyRowCount

        Parameters:
        triggerResultSet - a ResultSet object.
        Returns:
        a boolean.
        Throws:
        SQLException - if any.
      • countRows

        public int countRows​(ResultSet rs)
                      throws SQLException
        Method used to count the rows in a ResultSet. This probably requires that your ResultSet is scrollable.
        Parameters:
        rs - a ResultSet object.
        Returns:
        a int.
        Throws:
        SQLException - if any.
      • containsTokens

        public boolean containsTokens​(String targetString)
        Simple helper method to determine if the targetString contains any '${token}'s.
        Parameters:
        targetString - a String object.
        Returns:
        a boolean.
      • getAutomation

        public Automation getAutomation()

        getAutomation

        Returns:
        Returns the automation.
      • isReady

        public boolean isReady()

        isReady

        Specified by:
        isReady in interface ReadyRunnable
        Returns:
        a boolean.
      • getSchedule

        public Schedule getSchedule()

        getSchedule

        Returns:
        Returns the schedule.
      • setSchedule

        public void setSchedule​(Schedule schedule)

        setSchedule

        Parameters:
        schedule - The schedule to set.
      • setReady

        public void setReady​(boolean ready)

        setReady

        Parameters:
        ready - a boolean.