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
@@ -14,7 +14,7 @@ class Wakame::Monitor::Service
14
14
  @service_monitor = svc_mon
15
15
  @status = Wakame::Service::STATUS_OFFLINE
16
16
  count = 0
17
- @timer = Wakame::Monitor::CheckerTimer.new(3) {
17
+ @timer = Wakame::Monitor::CheckerTimer.new(5) {
18
18
  self.signal_checker
19
19
  }
20
20
  end
@@ -60,8 +60,10 @@ class Wakame::Monitor::Service
60
60
  case res
61
61
  when Exception
62
62
  update_status(Wakame::Service::STATUS_FAIL)
63
+ @service_monitor.send_event(Wakame::Packets::StatusCheckResult.new(@service_monitor.agent, self.svc_id, Wakame::Service::STATUS_FAIL, res.message))
63
64
  when Wakame::Service::STATUS_ONLINE, Wakame::Service::STATUS_OFFLINE
64
- update_status(res)
65
+ update_status(res)
66
+ @service_monitor.send_event(Wakame::Packets::StatusCheckResult.new(@service_monitor.agent, self.svc_id, res))
65
67
  else
66
68
  Wakame.log.error("#{self.class}: Unknown response type from the checker: #{self.svc_id}, ")
67
69
  end
@@ -143,7 +145,7 @@ class Wakame::Monitor::Service
143
145
  end
144
146
 
145
147
  def send_event(a)
146
- Wakame.log.debug("Sending back a event: #{a.class}")
148
+ Wakame.log.debug("Sending back the event: #{a.class}")
147
149
  publish_to('agent_event', a.marshal)
148
150
  end
149
151
 
@@ -158,8 +160,7 @@ class Wakame::Monitor::Service
158
160
  def register(svc_id, checker_type, *args)
159
161
  chk = @checkers[svc_id]
160
162
  if chk
161
- Wakame.log.error("#{self.class}: Service registory duplication. #{svc_id}")
162
- raise "Service registory duplication. #{svc_id}"
163
+ unregister(svc_id)
163
164
  end
164
165
  case checker_type.to_sym
165
166
  when :pidfile
@@ -125,27 +125,19 @@ module Wakame
125
125
  class Nop < RequestBase
126
126
  end
127
127
 
128
- # class ServiceStart < RequestBase
129
- # attr_reader :instance_id, :property
130
- # def initialize(instance_id, property)
131
- # @instance_id = instance_id
132
- # @property = property
133
- # end
134
- # end
135
-
136
- # class ServiceStop < RequestBase
137
- # attr_reader :instance_id
138
- # def initialize(instance_id)
139
- # @instance_id = instance_id
140
- # end
141
- # end
142
-
143
- # class ServiceReload < RequestBase
144
- # attr_reader :instance_id
145
- # def initialize(instance_id)
146
- # @instance_id = instance_id
147
- # end
148
- # end
128
+ class StatusCheckResult < ResponseBase
129
+ def_attribute :svc_id
130
+ def_attribute :status
131
+ def_attribute :new_status
132
+ def_attribute :fail_message
133
+
134
+ def initialize(agent, svc_id, status, fail_message=nil)
135
+ super(agent)
136
+ @svc_id = svc_id
137
+ @status = status
138
+ @fail_message = fail_message
139
+ end
140
+ end
149
141
 
150
142
  class ServiceStatusChanged < ResponseBase
151
143
  #attr_accessor :svc_id, :prev_status, :new_status, :fail_message