lib/cotcube-scheduler/scheduler.rb
# the heartbeat ticks once a minute and prepare 1 minute in advance the jobs to be run
the heartbeat ticks once a minute and prepare 1 minute in advance the jobs to be run
the heartbeat ticks once a minute and prepare 1 minute in advance the jobs to be run
def heartbeat_start
        @last_heartbeat    = Time.now
        @redux_queue   = Queue.new
        @spawn_queue   = Queue.new
        @heartbeat_monitor = Monitor.new
        @heartbeat  = Thread.new do 
          loop do 
            sleep 1 while (Time.now - last_heartbeat) < 5
            sleep DateTime.now.seconds_until_next_minute(offset: 30) + 0.05
            redux_queue << Time.now
            sleep 9.989
            spawn_queue  << Time.now
            @last_heartbeat = Time.now
          end
        end
        @redux_processor = Thread.new do 
          while heartbeat = redux_queue.pop
            log "Beating in redux: #{heartbeat}"
          end
        end
        @spawn_processor  = Thread.new do 
          while heartbeat = spawn_queue.pop
            log "Beating in spawn: #{heartbeat}"
          end
        end
      end
def heartbeat_start @last_heartbeat = Time . now @redux_queue = Queue . new @spawn_queue = Queue . new @heartbeat_monitor = Monitor . new @heartbeat = Thread . new do loop do sleep 1 while ( Time . now - last_heartbeat ) < 5 sleep DateTime . now . seconds_until_next_minute ( offset : 30 ) + 0.05 redux_queue << Time . now sleep 9.989 spawn_queue << Time . now @last_heartbeat = Time . now end end @redux_processor = Thread . new do while heartbeat = redux_queue . pop log "Beating in redux: #{heartbeat}" end end @spawn_processor = Thread . new do while heartbeat = spawn_queue . pop log "Beating in spawn: #{heartbeat}" end end end
the heartbeat ticks once a minute and prepare 1 minute in advance the jobs to be run
the heartbeat ticks once a minute and prepare 1 minute in advance the jobs to be run
# the heartbeat queue transmits the heartbeat from the heartbeat thread to #     the heartbeat processor # the heartbeat monitor watches all changes on the joblist (should its name then be joblist_monitor??) # the heart beats each minute with an offset of 30 seconds # then  it first triggers the reduce_queue, which takes care of running/finished jobs  # afterwards it  triggers the spawn_queue , which takes care of spawning new runenvs 