Class Scheduler

    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        define serialVersionUID for interoperability
        See Also:
        Constant Field Values
      • logger

        private static final Logger logger
      • DEBUG

        private static final boolean DEBUG
      • timer

        private transient Timer timer
        the timer
      • wakeUp

        private transient Scheduler.WakeUp wakeUp
        Current task schedule in Timer
    • Constructor Detail

      • Scheduler

        public Scheduler​(Timer timer)
                  throws IOException
        Creates the default scheduler.
        Parameters:
        timer - a ScalAgent timer.
        Throws:
        IOException
    • Method Detail

      • restart

        public void restart​(Timer timer)
                     throws Exception
        restart scheduler.
        Parameters:
        timer - a ScalAgent timer.
        Throws:
        Exception
      • toString

        public String toString()
        Provides a string image for this object.
        Overrides:
        toString in class Object
        Returns:
        a string image for this object
      • scheduleEvent

        public void scheduleEvent​(ScheduleEvent event,
                                  ScheduleTask task)
                           throws Exception
        schedule an event. Calls insertItem. Calls checkItems.
        Parameters:
        event - event to schedule.
        task - task to execute.
        Throws:
        Exception
      • insertItem

        private void insertItem​(ScheduleEvent event,
                                ScheduleTask task)
        insertItem ScheduleEvent event.
        Parameters:
        event -
        task - task to execute.
      • insertItem

        private void insertItem​(ScheduleItem newItem)
        Inserts an item in the list ordered by date. Inserts at list head a null dated item.
        Parameters:
        newItem - item to insert
      • checkItems

        private void checkItems()
                         throws Exception
        Checks for ripe events. reschedule event.
        Throws:
        Exception
      • removeItem

        private void removeItem​(ScheduleItem item)
        Removes an item from the list. Cancel WakeUP if the item is the current.
        Parameters:
        item - item to remove
      • schedule

        private void schedule​(ScheduleEvent event,
                              long period)
        schedule wake up task in timer.
        Parameters:
        event - schedule event.
        period - period in ms.
      • cancel

        private void cancel()
        cancel a wake up task in timer.