wakame 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/History.txt +8 -0
  2. data/Rakefile +3 -3
  3. data/VERSION +1 -1
  4. data/app_generators/wakame/templates/cluster/resources/markers/http_application_server.rb +3 -0
  5. data/app_generators/wakame/templates/cluster/resources/markers/http_asset_server.rb +2 -0
  6. data/app_generators/wakame/templates/cluster/resources/markers/http_server.rb +9 -0
  7. data/app_generators/wakame/templates/config/cluster.rb +36 -99
  8. data/app_generators/wakame/templates/config/init.d/wakame-agent +3 -3
  9. data/app_generators/wakame/templates/config/init.d/wakame-master +3 -3
  10. data/app_generators/wakame/wakame_generator.rb +5 -1
  11. data/contrib/imagesetup.sh +9 -5
  12. data/lib/ext/uri.rb +13 -0
  13. data/lib/wakame/action.rb +46 -21
  14. data/lib/wakame/{rule_engine.rb → action_manager.rb} +148 -36
  15. data/lib/wakame/actions/deploy_config.rb +35 -0
  16. data/lib/wakame/actions/launch_cluster.rb +8 -10
  17. data/lib/wakame/actions/launch_vm.rb +26 -20
  18. data/lib/wakame/actions/migrate_service.rb +30 -19
  19. data/lib/wakame/actions/notify_child_changed.rb +34 -0
  20. data/lib/wakame/actions/notify_parent_changed.rb +34 -0
  21. data/lib/wakame/actions/propagate_resource.rb +27 -0
  22. data/lib/wakame/actions/propagate_service.rb +27 -0
  23. data/lib/wakame/actions/reload_service.rb +21 -9
  24. data/lib/wakame/actions/shutdown_cluster.rb +3 -3
  25. data/lib/wakame/actions/shutdown_vm.rb +14 -5
  26. data/lib/wakame/actions/start_service.rb +53 -47
  27. data/lib/wakame/actions/stop_service.rb +35 -23
  28. data/lib/wakame/actor/system.rb +6 -3
  29. data/lib/wakame/agent.rb +29 -7
  30. data/lib/wakame/amqp_client.rb +26 -5
  31. data/lib/wakame/command/action_status.rb +7 -7
  32. data/lib/wakame/command/actor.rb +10 -10
  33. data/lib/wakame/command/import_cluster_config.rb +10 -0
  34. data/lib/wakame/command/launch_cluster.rb +2 -2
  35. data/lib/wakame/command/launch_vm.rb +3 -3
  36. data/lib/wakame/command/migrate_service.rb +7 -7
  37. data/lib/wakame/command/propagate_resource.rb +42 -0
  38. data/lib/wakame/command/propagate_service.rb +21 -19
  39. data/lib/wakame/command/reload_service.rb +3 -13
  40. data/lib/wakame/command/shutdown_cluster.rb +2 -2
  41. data/lib/wakame/command/start_service.rb +14 -0
  42. data/lib/wakame/command/status.rb +32 -10
  43. data/lib/wakame/command/stop_service.rb +27 -21
  44. data/lib/wakame/command.rb +19 -3
  45. data/lib/wakame/command_queue.rb +87 -67
  46. data/lib/wakame/configuration.rb +6 -0
  47. data/lib/wakame/event.rb +17 -0
  48. data/lib/wakame/event_dispatcher.rb +32 -23
  49. data/lib/wakame/graph.rb +2 -1
  50. data/lib/wakame/initializer.rb +11 -8
  51. data/lib/wakame/master.rb +327 -209
  52. data/lib/wakame/monitor/agent.rb +5 -1
  53. data/lib/wakame/monitor/service.rb +6 -5
  54. data/lib/wakame/packets.rb +13 -21
  55. data/lib/wakame/runner/administrator_command.rb +383 -264
  56. data/lib/wakame/runner/agent.rb +1 -5
  57. data/lib/wakame/runner/master.rb +0 -3
  58. data/lib/wakame/service.rb +817 -538
  59. data/lib/wakame/status_db.rb +383 -0
  60. data/lib/wakame/template.rb +27 -130
  61. data/lib/wakame/trigger.rb +10 -18
  62. data/lib/wakame/triggers/instance_count_update.rb +1 -1
  63. data/lib/wakame/triggers/load_history.rb +1 -1
  64. data/lib/wakame/triggers/maintain_ssh_known_hosts.rb +8 -5
  65. data/lib/wakame/triggers/shutdown_unused_vm.rb +1 -1
  66. data/lib/wakame/util.rb +64 -55
  67. data/lib/wakame.rb +4 -0
  68. data/tests/test_action_manager.rb +111 -0
  69. data/tests/test_service.rb +128 -23
  70. data/tests/test_status_db.rb +82 -0
  71. data/tests/test_uri_amqp.rb +10 -0
  72. data/wakame_generators/resource/templates/apache_app/apache_app.rb +19 -18
  73. data/wakame_generators/resource/templates/apache_app/conf/apache2.conf +14 -2
  74. data/wakame_generators/resource/templates/apache_app/conf/system-app.conf +1 -1
  75. data/wakame_generators/resource/templates/apache_app/conf/vh/aaa.test.conf +9 -0
  76. data/wakame_generators/resource/templates/apache_lb/apache_lb.rb +21 -20
  77. data/wakame_generators/resource/templates/apache_lb/conf/apache2.conf +14 -2
  78. data/wakame_generators/resource/templates/apache_lb/conf/system-lb.conf +17 -2
  79. data/wakame_generators/resource/templates/apache_lb/conf/vh/aaa.test.conf +37 -0
  80. data/wakame_generators/resource/templates/apache_www/apache_www.rb +20 -18
  81. data/wakame_generators/resource/templates/apache_www/conf/apache2.conf +14 -2
  82. data/wakame_generators/resource/templates/apache_www/conf/system-www.conf +1 -1
  83. data/wakame_generators/resource/templates/apache_www/conf/vh/aaa.test.conf +9 -0
  84. data/wakame_generators/resource/templates/ec2_elastic_ip/ec2_elastic_ip.rb +6 -8
  85. data/wakame_generators/resource/templates/ec2_elb/ec2_elb.rb +7 -6
  86. data/wakame_generators/resource/templates/memcached/conf/memcached.conf +47 -0
  87. data/wakame_generators/resource/templates/memcached/init.d/memcached +61 -0
  88. data/wakame_generators/resource/templates/memcached/memcached.rb +73 -0
  89. data/wakame_generators/resource/templates/mysql_master/conf/my.cnf +5 -7
  90. data/wakame_generators/resource/templates/mysql_master/mysql_master.rb +35 -34
  91. data/wakame_generators/resource/templates/mysql_slave/conf/my.cnf +6 -6
  92. data/wakame_generators/resource/templates/mysql_slave/mysql_slave.rb +21 -24
  93. data/wakame_generators/resource/templates/nginx/conf/nginx.conf +17 -27
  94. data/wakame_generators/resource/templates/nginx/conf/vh/aaa.test.conf +30 -0
  95. data/wakame_generators/resource/templates/nginx/nginx.rb +18 -18
  96. metadata +34 -21
  97. data/lib/wakame/actions/propagate_instances.rb +0 -70
  98. data/lib/wakame/manager/commands.rb +0 -134
  99. data/lib/wakame/rule.rb +0 -116
  100. data/lib/wakame/triggers/process_command.rb +0 -41
  101. data/tests/test_rule_engine.rb +0 -127
  102. data/wakame_generators/resource/templates/apache_app/conf/sites-app.conf +0 -23
  103. data/wakame_generators/resource/templates/apache_lb/conf/sites-lb.conf +0 -54
  104. data/wakame_generators/resource/templates/apache_www/conf/sites-www.conf +0 -23
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ == 0.5.0 2009-09-18
2
+
3
+ * Add Memcached resource.
4
+
5
+ * Use SQL based persistent store for the status information.
6
+
7
+ * Many internal changes along with the above change.
8
+
1
9
  == 0.4.2 2009-07-24
2
10
 
3
11
  * Add Web API for master control. (Note that the API design is not fixed yet)
data/Rakefile CHANGED
@@ -17,8 +17,7 @@ __END__
17
17
  gem.rubyforge_project = 'wakame'
18
18
  gem.executables = ['wakame']
19
19
  [['amqp','>= 0.6.0'],
20
- ['amazon-ec2','>= 0.3.6'],
21
- ['right_aws','>= 1.10.0'],
20
+ ['right_aws','>= 1.10.0'], # Ec2ELB works with 1.10.99 in their github.
22
21
  ['eventmachine','>= 0.12.8'],
23
22
  ['rake', '>= 0.8.7'],
24
23
  ['log4r', '>= 1.0.5'],
@@ -28,7 +27,8 @@ __END__
28
27
  ['jeweler', '>= 1.0.0'],
29
28
  ['rack', '>= 1.0.0'],
30
29
  ['thin', '>= 1.2.2'],
31
- ['json', '>= 1.1.7']
30
+ ['json', '>= 1.1.7'],
31
+ ['sequel', '>= 3.2.0']
32
32
  ].each { |i|
33
33
  gem.add_dependency(i[0], i[1])
34
34
  }
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.5.0
@@ -0,0 +1,3 @@
1
+ module HttpApplicationServer
2
+ end
3
+
@@ -0,0 +1,2 @@
1
+ module HttpAssetServer
2
+ end
@@ -0,0 +1,9 @@
1
+ module HttpServer
2
+ def self.included(klass)
3
+ klass.class_eval {
4
+ property :listen_port
5
+ property :listen_port_https
6
+ }
7
+ end
8
+ end
9
+
@@ -1,100 +1,37 @@
1
- class WebCluster < Wakame::Service::ServiceCluster
2
- attr_accessor :propagation_priority
1
+ define_cluster('WebCluster1') { |c|
2
+ c.add_resource(Apache_APP.new) { |r|
3
+ r.listen_port = 8001
4
+ r.max_instances = 5
5
+ }
6
+ c.add_resource(Nginx.new)
7
+ c.add_resource(Ec2ELB.new) { |r|
8
+ r.elb_name = 'xxxxxxx'
9
+ }
10
+ c.add_resource(MySQL_Master.new) {|r|
11
+ r.mysqld_basedir = '/home/wakame/mysql'
12
+ r.ebs_volume = 'vol-xxxxxxx'
13
+ r.ebs_device = '/dev/sdm'
14
+ }
15
+
16
+ c.set_dependency(Apache_APP, Nginx)
17
+ c.set_dependency(Nginx, Ec2ELB)
18
+ c.set_dependency(MySQL_Master, Apache_APP)
19
+
20
+ host = c.add_cloud_host { |h|
21
+ #h.vm_spec.availability_zone = 'us-east-1a'
22
+ }
23
+ c.propagate(Nginx, host.id)
24
+ c.propagate(Apache_APP, host.id)
25
+ c.propagate(MySQL_Master, host.id)
26
+ c.propagate(Ec2ELB)
27
+
28
+ c.define_triggers {|r|
29
+ #r.register_trigger(Wakame::Triggers::MaintainSshKnownHosts.new)
30
+ #r.register_trigger(Wakame::Triggers::LoadHistoryMonitor.new)
31
+ #r.register_trigger(Wakame::Triggers::InstanceCountUpdate.new)
32
+ #r.register_trigger(Wakame::Triggers::ScaleOutWhenHighLoad.new)
33
+ #r.register_trigger(Wakame::Triggers::ShutdownUnusedVM.new)
34
+ }
35
+
36
+ }
3
37
 
4
- module HttpAppServer; end
5
- module HttpAssetServer; end
6
- module HttpLoadBalanceServer; end
7
-
8
- VirtualHost = Class.new(OpenStruct)
9
- def initialize(master, &blk)
10
- super(master) { |c|
11
- c.add_resource(Ec2ElasticIp.new)
12
- c.add_resource(Apache_WWW.new)
13
- c.add_resource(Apache_APP.new)
14
- c.add_resource(Apache_LB.new)
15
- c.add_resource(MySQL_Master.new)
16
- #c.add_resource(MySQL_Slave.new)
17
-
18
- c.set_dependency(Apache_LB, Ec2ElasticIp)
19
- c.set_dependency(Apache_WWW, Apache_LB)
20
- c.set_dependency(Apache_APP, Apache_LB)
21
- c.set_dependency(MySQL_Master, Apache_APP)
22
- #c.set_dependency(MySQL_Master, MySQL_Slave)
23
- }
24
-
25
- define_rule { |r|
26
- r.register_trigger(Wakame::Triggers::ProcessCommand.new)
27
- r.register_trigger(Wakame::Triggers::MaintainSshKnownHosts.new)
28
- #r.register_trigger(Wakame::Triggers::LoadHistoryMonitor.new)
29
- #r.register_trigger(Wakame::Triggers::InstanceCountUpdate.new)
30
- #r.register_trigger(Wakame::Triggers::ScaleOutWhenHighLoad.new)
31
- #r.register_trigger(Wakame::Triggers::ShutdownUnusedVM.new)
32
- }
33
-
34
- add_virtual_host(VirtualHost.new(:server_name=>'aaa.test', :document_root=>'/home/wakame/app/development/test/public'))
35
- add_virtual_host(VirtualHost.new(:server_name=>'bbb.test', :document_root=>'/home/wakame/app/development/test/public'))
36
-
37
- end
38
-
39
- def virtual_hosts
40
- @virtual_hosts ||= []
41
- end
42
-
43
- def add_virtual_host(vh)
44
- virtual_hosts << vh
45
- end
46
-
47
-
48
- def each_app(&blk)
49
- each_instance(HttpAppServer) { |n|
50
- blk.call(n)
51
- }
52
- end
53
-
54
- def each_www(&blk)
55
- each_instance(HttpAssetServer) { |n|
56
- blk.call(n)
57
- }
58
- end
59
-
60
- def each_mysql(&blk)
61
- each_instance(MySQL_Master) { |n|
62
- blk.call(n)
63
- }
64
- end
65
-
66
- def each_mysql_master(&blk)
67
- each_instance(MySQL_Master) { |n|
68
- blk.call(n)
69
- }
70
- end
71
-
72
- def fetch_mysql_master_ip
73
- mysql_master_ip = nil
74
- each_mysql_master do |mysql|
75
- mysql_master_ip = mysql.agent.agent_ip
76
- end
77
- mysql_master_ip
78
- end
79
-
80
- def each_mysql_slave(&blk)
81
- each_instance(MySQL_Slave) { |n|
82
- blk.call(n)
83
- }
84
- end
85
-
86
- def fetch_mysql_slave_ip
87
- mysql_slave_ips = []
88
- each_mysql_slave do |mysql|
89
- mysql_slave_ips << mysql.agent.agent_ip
90
- end
91
- mysql_master_ips
92
- end
93
-
94
- # def each_postgresql(&blk)
95
- # each_instance(PostgreSQL_Master) { |n|
96
- # blk.call(n)
97
- # }
98
- # end
99
-
100
- end
@@ -19,9 +19,9 @@ PIDFILE=/var/run/wakame/wakame-agent.pid
19
19
  #LSBNAMES='-l' # Uncomment for LSB name support in /etc/cron.d/
20
20
 
21
21
  . /lib/lsb/init-functions
22
- if [ -z $WAKAME_HOME ]; then
22
+ if [ -z $WAKAME_ROOT ]; then
23
23
  [ -f /etc/default/wakame ] && . /etc/default/wakame
24
- export GEM_HOME WAKAME_HOME WAKAME_ENV
24
+ export GEM_HOME WAKAME_ROOT WAKAME_ENV
25
25
  fi
26
26
 
27
27
  start_agent()
@@ -40,7 +40,7 @@ start_agent()
40
40
  opts="$opts -s $i"
41
41
  done
42
42
  fi
43
- start-stop-daemon --start --quiet --pidfile $PIDFILE --name wakame-agent --startas $WAKAME_HOME/bin/wakame-agent -- $opts $LSBNAMES
43
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --name wakame-agent --startas $WAKAME_ROOT/bin/wakame-agent -- $opts $LSBNAMES
44
44
  }
45
45
 
46
46
  stop_agent()
@@ -21,9 +21,9 @@ PIDFILE=/var/run/wakame/wakame-master.pid
21
21
  #LSBNAMES='-l' # Uncomment for LSB name support in /etc/cron.d/
22
22
 
23
23
  . /lib/lsb/init-functions
24
- if [ -z $WAKAME_HOME ]; then
24
+ if [ -z $WAKAME_ROOT ]; then
25
25
  [ -f /etc/default/wakame ] && . /etc/default/wakame
26
- export GEM_HOME WAKAME_HOME WAKAME_ENV
26
+ export GEM_HOME WAKAME_ROOT WAKAME_ENV
27
27
  fi
28
28
 
29
29
  start_master()
@@ -41,7 +41,7 @@ start_master()
41
41
  chown "$USER:$GROUP" $pid_dir
42
42
  fi
43
43
 
44
- start-stop-daemon --start --quiet --pidfile $PIDFILE --name wakame-master --startas $WAKAME_HOME/bin/wakame-master -- -u $USER $LSBNAMES
44
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --name wakame-master --startas $WAKAME_ROOT/bin/wakame-master -- -u $USER $LSBNAMES
45
45
 
46
46
  }
47
47
  stop_master()
@@ -14,6 +14,7 @@ class WakameGenerator < RubiGen::Base
14
14
  cluster/actions
15
15
  cluster/triggers
16
16
  cluster/resources
17
+ cluster/resources/markers
17
18
  cluster/commands
18
19
  config
19
20
  config/init.d
@@ -58,7 +59,10 @@ class WakameGenerator < RubiGen::Base
58
59
  BASEDIRS.each { |path| m.directory path }
59
60
 
60
61
  m.file_copy_each %w(Rakefile README)
61
- m.file_copy_each %w(config/boot.rb config/cluster.rb config/environments/common.rb config/environments/stand_alone.rb config/environments/ec2.rb)
62
+ m.file_copy_each %w(config/boot.rb config/cluster.rb config/environments/common.rb config/environments/stand_alone.rb config/environments/ec2.rb
63
+ cluster/resources/markers/http_application_server.rb
64
+ cluster/resources/markers/http_asset_server.rb
65
+ cluster/resources/markers/http_server.rb)
62
66
  m.dependency "install_rubigen_scripts", [destination_root, :wakame]
63
67
 
64
68
  %w(wakame-master wakame-agent wakameadm).each do |script|
@@ -9,12 +9,14 @@ apt-get -y install apache2-mpm-prefork libapache2-mod-rpaf
9
9
  apt-get -y install mysql-server mysql-client
10
10
  apt-get -y install erlang-nox
11
11
  apt-get -y install unzip zip rsync libopenssl-ruby libhmac-ruby rubygems irb ri rdoc sysstat
12
+ apt-get -y install apache2-prefork-dev ruby-dev make g++ libopenssl-ruby subversion
13
+ apt-get -y install memcached
12
14
 
13
15
  apt-get clean
14
16
 
15
17
  (cd /tmp;
16
- wget http://www.rabbitmq.com/releases/rabbitmq-server/v1.5.4/rabbitmq-server_1.5.4-1_all.deb;
17
- dpkg -i rabbitmq-server_1.5.4-1_all.deb;
18
+ wget http://www.rabbitmq.com/releases/rabbitmq-server/v1.6.0/rabbitmq-server_1.6.0-1_all.deb
19
+ dpkg -i rabbitmq-server_1.6.0-1_all.deb
18
20
  )
19
21
 
20
22
 
@@ -40,7 +42,7 @@ EOF
40
42
  fi
41
43
 
42
44
  cat <<EOF > /etc/default/wakame
43
- WAKAME_HOME=/home/wakame/corelib
45
+ WAKAME_ROOT=/home/wakame/wakame.proj
44
46
  GEM_HOME=/usr/local/gems
45
47
  EOF
46
48
 
@@ -48,12 +50,14 @@ update-rc.d -f apache2 remove
48
50
  update-rc.d -f mysql remove
49
51
  update-rc.d -f mysql-ndb remove
50
52
  update-rc.d -f mysql-ndb-mgm remove
53
+ update-rc.d -f mysql-ndb-mgm memcached
51
54
  # Disable apparmor
52
55
  update-rc.d -f apparmor remove
53
56
 
54
- cat <<EOF > /usr/local/bin/passenger_ruby.sh
57
+ cat <<'EOF' > /usr/local/bin/passenger_ruby.sh
55
58
  #!/bin/sh
56
- export GEM_PATH="/usr/local/gems"
59
+ . /etc/environment
60
+ export RUBYLIB GEM_HOME
57
61
  exec /usr/bin/ruby $@
58
62
  EOF
59
63
  chmod 755 /usr/local/bin/passenger_ruby.sh
data/lib/ext/uri.rb CHANGED
@@ -8,7 +8,20 @@ module URI
8
8
  :path
9
9
  ].freeze
10
10
 
11
+ DEFAULT_PORT=5672
12
+
13
+ def self.build(args)
14
+ tmp = Util::make_components_hash(self, args)
15
+ return super(tmp)
16
+ end
17
+
18
+ def initialize(*args)
19
+ args[5] = '/' if args[5].nil? || args[5] == ''
20
+ super(*args)
21
+ end
22
+
11
23
  alias :vhost :path
24
+ alias :vhost= :path=
12
25
  end
13
26
 
14
27
  @@schemes['AMQP'] = AMQP
data/lib/wakame/action.rb CHANGED
@@ -8,19 +8,25 @@ module Wakame
8
8
  def_attribute :completion_status
9
9
  def_attribute :parent_action
10
10
 
11
- attr_reader :trigger
11
+ attr_accessor :action_manager
12
12
 
13
13
  def master
14
- trigger.master
14
+ action_manager.master
15
15
  end
16
16
 
17
17
  def agent_monitor
18
- trigger.agent_monitor
18
+ master.agent_monitor
19
19
  end
20
20
 
21
+ # Tentative utility method for
21
22
  def service_cluster
22
- trigger.service_cluster
23
+ cluster_id = master.cluster_manager.clusters.first
24
+ raise "There is no cluster loaded" if cluster_id.nil?
25
+
26
+ Service::ServiceCluster.find(cluster_id)
23
27
  end
28
+ alias :cluster :service_cluster
29
+
24
30
  def status=(status)
25
31
  if @status != status
26
32
  @status = status
@@ -35,26 +41,27 @@ module Wakame
35
41
  @subactions ||= []
36
42
  end
37
43
 
38
- def bind_trigger(trigger)
39
- @trigger = trigger
40
- end
41
-
42
- def trigger_action(subaction, opts={})
44
+ def trigger_action(subaction=nil, &blk)
45
+ if blk
46
+ subaction = ProcAction.new(blk)
47
+ end
48
+
43
49
  subactions << subaction
44
50
  subaction.parent_action = self
45
51
  subaction.job_id = self.job_id
46
- subaction.bind_trigger(self.trigger)
52
+ subaction.action_manager = self.action_manager
47
53
 
48
- trigger.rule_engine.run_action(subaction)
54
+ action_manager.run_action(subaction)
49
55
  end
50
56
 
51
- def flush_subactions(sec=nil)
52
- job_context = trigger.rule_engine.active_jobs[self.job_id]
57
+ def flush_subactions(sec=60*30)
58
+ job_context = action_manager.active_jobs[self.job_id]
53
59
  return if job_context.nil?
54
60
 
55
- timeout(sec.nil? ? nil : sec) {
61
+ timeout(sec) {
56
62
  until all_subactions_complete?
57
63
  #Wakame.log.debug "#{self.class} all_subactions_complete?=#{all_subactions_complete?}"
64
+ Thread.pass
58
65
  src = notify_queue.deq
59
66
  # Exit the current action when a subaction notified exception.
60
67
  if src.is_a?(Exception)
@@ -64,6 +71,7 @@ module Wakame
64
71
  end
65
72
  }
66
73
  end
74
+ thread_immutable_methods :flush_subactions
67
75
 
68
76
  def all_subactions_complete?
69
77
  subactions.each { |a|
@@ -76,6 +84,7 @@ module Wakame
76
84
  def notify_queue
77
85
  @notify_queue ||= ::Queue.new
78
86
  end
87
+ private :notify_queue
79
88
 
80
89
  def notify(src=nil)
81
90
  #Wakame.log.debug("#{self.class}.notify() has been called")
@@ -96,7 +105,7 @@ module Wakame
96
105
  a.walk_subactions(&blk)
97
106
  }
98
107
  end
99
-
108
+
100
109
  def actor_request(agent_id, path, *args, &blk)
101
110
  request = master.actor_request(agent_id, path, *args)
102
111
  if blk
@@ -110,23 +119,24 @@ module Wakame
110
119
  request = actor_request(agent_id, path, *args).request
111
120
  request.wait
112
121
  end
113
-
122
+
114
123
  def notes
115
- trigger.rule_engine.active_jobs[self.job_id][:notes]
124
+ action_manager.active_jobs[self.job_id][:notes]
116
125
  end
117
126
 
118
127
  # Set the lock flags to resources
119
128
  def acquire_lock(&blk)
120
- EM.barrier {
129
+ StatusDB.barrier {
121
130
  reslist = []
122
131
  blk.call(reslist)
123
132
  reslist.flatten!
124
- reslist.each {|r| service_cluster.lock_queue.set(r.to_s, self.job_id) }
133
+ reslist.each {|r| action_manager.lock_queue.set(r.to_s, self.job_id) }
125
134
  }
126
135
 
127
- service_cluster.lock_queue.wait(self.job_id)
136
+ action_manager.lock_queue.wait(self.job_id)
128
137
  end
129
-
138
+ thread_immutable_methods :acquire_lock
139
+
130
140
  def run
131
141
  raise NotImplementedError
132
142
  end
@@ -137,5 +147,20 @@ module Wakame
137
147
  def on_canceled
138
148
  end
139
149
 
150
+
151
+ class ProcAction < Action
152
+ def initialize(proc_obj)
153
+ raise ArgumentError unless proc_obj.is_a? Proc
154
+ @proc_obj = proc_obj
155
+ end
156
+
157
+ def run()
158
+ @proc_obj.call(self)
159
+ end
160
+ end
161
+
162
+
140
163
  end
164
+
165
+
141
166
  end