Class: Wakame::Actions::ShutdownCluster

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

Constant Summary

Constants included from AttributeHelper

AttributeHelper::CONVERT_CLASSES, AttributeHelper::PRIMITIVE_CLASSES

Instance Attribute Summary

Attributes inherited from Wakame::Action

#trigger

Instance Method Summary collapse

Methods inherited from Wakame::Action

#acquire_lock, #actor_request, #agent_monitor, #all_subactions_complete?, #bind_trigger, #flush_subactions, #master, #notes, #notify, #notify_queue, #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

Instance Method Details

#runObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/wakame/actions/shutdown_cluster.rb', line 4

def run
  levels = service_cluster.dg.levels
  Wakame.log.debug("#{self.class}: Resource shutdown order: " + levels.collect {|lv| '['+ lv.collect{|prop| "#{prop.class}" }.join(', ') + ']' }.join(', '))
  acquire_lock { |list|
    levels.each {|lv| list << lv.collect{|res| res.class } }
  }

  levels.reverse.each { |lv|
    lv.each { |svc_prop|
      service_cluster.each_instance(svc_prop.class) { |svc_inst|
        trigger_action(StopService.new(svc_inst))
      }
    }
    flush_subactions
  }

  agent_monitor.registered_agents.each { |id, agent|
    trigger_action(ShutdownVM.new(agent))
  }
end