Class: Wakame::Triggers::InstanceCountUpdate

Inherits:
Wakame::Trigger show all
Defined in:
lib/wakame/triggers/instance_count_update.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

Instance Method Details

#register_hooks(cluster_id) ⇒ Object



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
42
# File 'lib/wakame/triggers/instance_count_update.rb', line 8

def register_hooks(cluster_id)
  @instance_counters = {}
  ms = Scheduler::PerHourSequence.new
  #ms[0]=1
  #ms[30]=5
  ms[0]=1
  ms["0:2:00"]=4
  ms["0:5:00"]=1
  ms["0:9:00"]=4
  ms["0:13:00"]=1
  ms["0:17:00"]=4
  ms["0:21:00"]=1
  ms["0:25:00"]=1
  ms["0:29:00"]=1
  ms["0:33:00"]=4
  #ms["0:37:00"]=1
  #ms["0:41:00"]=4
  ms["0:45:00"]=1
  ms["0:49:00"]=4
  ms["0:53:00"]=1
  ms["0:57:00"]=4
  # @instance_counters[Apache_APP.to_s] = TimedCounter.new(Scheduler::LoopSequence.new(ms), self)

  event_subscribe(Event::InstanceCountChanged) { |event|
    next if service_cluster.status == Service::ServiceCluster::STATUS_OFFLINE

    if event.increased?
      Wakame.log.debug("#{self.class}: trigger PropagateInstancesAction.new(#{event.resource.class})")
      trigger_action(Actions::PropagateInstancesAction.new(event.resource))
    elsif event.decreased?
      Wakame.log.debug("#{self.class}: trigger DestroyInstancesAction.new(#{event.resource.class})")
      trigger_action(Actions::DestroyInstancesAction.new(event.resource))
    end
  }
end