Class: Wakame::Triggers::LoadHistoryMonitor

Inherits:
Wakame::Trigger show all
Defined in:
lib/wakame/triggers/load_history.rb

Defined Under Namespace

Classes: AgentLoadHighEvent, AgentLoadNormalEvent, ServiceLoadHighEvent, ServiceLoadNormalEvent

Constant Summary

Constants included from AttributeHelper

AttributeHelper::CONVERT_CLASSES, AttributeHelper::PRIMITIVE_CLASSES

Instance Attribute Summary

Attributes inherited from Wakame::Trigger

#rule_engine

Instance Method Summary collapse

Methods inherited from Wakame::Trigger

#agent_monitor, #bind_engine, #cleanup, #command_queue, #master, #service_cluster, #trigger_action

Methods included from AttributeHelper

#dump_attrs

Methods included from FilterChain

included, #run_filter

Constructor Details

#initializeLoadHistoryMonitor

Returns a new instance of LoadHistoryMonitor.



38
39
40
41
42
43
# File 'lib/wakame/triggers/load_history.rb', line 38

def initialize
  @agent_data = {}
  @service_data = {}
  @high_threashold = 1.2
  @history_period = 3
end

Instance Method Details

#register_hooksObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/wakame/triggers/load_history.rb', line 45

def register_hooks
  event_subscribe(Event::AgentMonitored) { |event|
    @agent_data[event.agent.agent_id]={:load_history=>[], :last_event=>:normal}
    service_cluster.properties.each { |klass, prop|
      @service_data[klass] ||= {:load_history=>[], :last_event=>:normal}
    }
  }
  event_subscribe(Event::AgentUnMonitored) { |event|
    @agent_data.delete(event.agent.agent_id)
  }

  event_subscribe(Event::AgentPong) { |event|
    calc_load(event.agent)
  }
end