Class: Wakame::Actions::NotifyChildChanged

Inherits:
Wakame::Action show all
Defined in:
lib/wakame/actions/notify_child_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) ⇒ NotifyChildChanged

Returns a new instance of NotifyChildChanged.



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

def initialize(svc)
  @child_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
29
30
31
# File 'lib/wakame/actions/notify_child_changed.rb', line 8

def run
  parents = []
  StatusDB.barrier {
    parents = @child_svc.parent_instances
  }

  acquire_lock { |lst|
    lst << parents.map{|c| c.resource.class.to_s }.uniq
  }
  
  Wakame.log.debug("#{self.class}: Parent nodes for #{@child_svc.resource.class}: " + parents.map{|c| c.resource.class }.uniq.inspect )

  parents.each { |svc|
    if svc.status != Service::STATUS_ONLINE
      next
    end

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

end