Class: Wakame::Actions::NotifyParentChanged

Inherits:
Wakame::Action show all
Defined in:
lib/wakame/actions/notify_parent_changed.rb

Constant Summary

Constants included from AttributeHelper

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

Instance Attribute Summary

Attributes inherited from Wakame::Action

#action_manager

Instance Method Summary collapse

Methods inherited from Wakame::Action

#acquire_lock, #actor_request, #agent_monitor, #all_subactions_complete?, #flush_subactions, #master, #notes, #notify, #on_canceled, #on_failed, #service_cluster, #status=, #subactions, #sync_actor_request, #trigger_action, #walk_subactions

Methods included from ThreadImmutable

#bind_thread, included, #target_thread, #target_thread?, #thread_check

Methods included from AttributeHelper

#dump_attrs, #retrieve_attr_attribute

Constructor Details

#initialize(svc) ⇒ NotifyParentChanged

Returns a new instance of NotifyParentChanged.



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

def initialize(svc)
  @parent_svc = svc
end

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/wakame/actions/notify_parent_changed.rb', line 8

def run
  children = StatusDB.barrier {
    @parent_svc.child_instances
  }

  acquire_lock(children.map{|c| c.resource.class.to_s }.uniq)
  
  Wakame.log.debug("#{self.class}: Child nodes for #{@parent_svc.resource.class}: " + children.map{|c| c.resource.class }.uniq.inspect )

  children.each { |svc|
    if svc.monitor_status != Service::STATUS_ONLINE
      next
    end

    trigger_action { |proc_action|
      svc.resource.on_parent_changed(svc, proc_action)
    }
  }
  flush_subactions

end