Class: Wakame::Triggers::ScaleoutWhenHighLoad

Inherits:
Wakame::Trigger show all
Defined in:
lib/wakame/actions/scaleout_when_high_load.rb

Constant Summary

Constants included from AttributeHelper

AttributeHelper::CLASS_TYPE_KEY, AttributeHelper::CONVERT_CLASSES, AttributeHelper::PRIMITIVE_CLASSES

Instance Method Summary collapse

Methods inherited from Wakame::Trigger

#agent_monitor, #cleanup, #command_queue, #master, #trigger_action

Methods included from AttributeHelper

#dump_attrs, #retrieve_attr_attribute

Methods included from FilterChain

included, #run_filter

Constructor Details

#initializeScaleoutWhenHighLoad

Returns a new instance of ScaleoutWhenHighLoad.



4
5
# File 'lib/wakame/actions/scaleout_when_high_load.rb', line 4

def initialize
end

Instance Method Details

#register_hooksObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/wakame/actions/scaleout_when_high_load.rb', line 7

def register_hooks
  event_subscribe(LoadHistoryMonitor::AgentLoadHighEvent) { |event|
    if service_cluster.status != Service::ServiceCluster::STATUS_ONLINE
      Wakame.log.info("Service Cluster is not online yet. Skip to scaling out")
      next
    end
    Wakame.log.debug("Got load high avg: #{event.agent.agent_id}")

    propagate_svc = nil
    event.agent.services.each { |id, svc|
      if svc.property.class == Service::Apache_APP
        propagate_svc = svc 
        break
      end
    }

    unless propagate_svc.nil?
      trigger_action(Actions::PropagateInstancesAction.new(propagate_svc.property)) 
    end
  }

  event_subscribe(LoadHistoryMonitor::AgentLoadNormalEvent) { |event|
    next

    if service_cluster.status != Service::ServiceCluster::STATUS_ONLINE
      Wakame.log.info("Service Cluster is not online yet.")
      next
    end
    Wakame.log.debug("Back to normal load: #{event.agent.agent_id}")
    event.agent.services.each { |id, svc|
      trigger_action(Actions::StopService.new(svc))
    }
    
  }
end