wakame 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/app_generators/wakame/templates/cluster/resources/markers/http_application_server.rb +3 -0
- data/app_generators/wakame/templates/cluster/resources/markers/http_asset_server.rb +2 -0
- data/app_generators/wakame/templates/cluster/resources/markers/http_server.rb +9 -0
- data/app_generators/wakame/templates/config/cluster.rb +36 -99
- data/app_generators/wakame/templates/config/init.d/wakame-agent +3 -3
- data/app_generators/wakame/templates/config/init.d/wakame-master +3 -3
- data/app_generators/wakame/wakame_generator.rb +5 -1
- data/contrib/imagesetup.sh +9 -5
- data/lib/ext/uri.rb +13 -0
- data/lib/wakame/action.rb +46 -21
- data/lib/wakame/{rule_engine.rb → action_manager.rb} +148 -36
- data/lib/wakame/actions/deploy_config.rb +35 -0
- data/lib/wakame/actions/launch_cluster.rb +8 -10
- data/lib/wakame/actions/launch_vm.rb +26 -20
- data/lib/wakame/actions/migrate_service.rb +30 -19
- data/lib/wakame/actions/notify_child_changed.rb +34 -0
- data/lib/wakame/actions/notify_parent_changed.rb +34 -0
- data/lib/wakame/actions/propagate_resource.rb +27 -0
- data/lib/wakame/actions/propagate_service.rb +27 -0
- data/lib/wakame/actions/reload_service.rb +21 -9
- data/lib/wakame/actions/shutdown_cluster.rb +3 -3
- data/lib/wakame/actions/shutdown_vm.rb +14 -5
- data/lib/wakame/actions/start_service.rb +53 -47
- data/lib/wakame/actions/stop_service.rb +35 -23
- data/lib/wakame/actor/system.rb +6 -3
- data/lib/wakame/agent.rb +29 -7
- data/lib/wakame/amqp_client.rb +26 -5
- data/lib/wakame/command/action_status.rb +7 -7
- data/lib/wakame/command/actor.rb +10 -10
- data/lib/wakame/command/import_cluster_config.rb +10 -0
- data/lib/wakame/command/launch_cluster.rb +2 -2
- data/lib/wakame/command/launch_vm.rb +3 -3
- data/lib/wakame/command/migrate_service.rb +7 -7
- data/lib/wakame/command/propagate_resource.rb +42 -0
- data/lib/wakame/command/propagate_service.rb +21 -19
- data/lib/wakame/command/reload_service.rb +3 -13
- data/lib/wakame/command/shutdown_cluster.rb +2 -2
- data/lib/wakame/command/start_service.rb +14 -0
- data/lib/wakame/command/status.rb +32 -10
- data/lib/wakame/command/stop_service.rb +27 -21
- data/lib/wakame/command.rb +19 -3
- data/lib/wakame/command_queue.rb +87 -67
- data/lib/wakame/configuration.rb +6 -0
- data/lib/wakame/event.rb +17 -0
- data/lib/wakame/event_dispatcher.rb +32 -23
- data/lib/wakame/graph.rb +2 -1
- data/lib/wakame/initializer.rb +11 -8
- data/lib/wakame/master.rb +327 -209
- data/lib/wakame/monitor/agent.rb +5 -1
- data/lib/wakame/monitor/service.rb +6 -5
- data/lib/wakame/packets.rb +13 -21
- data/lib/wakame/runner/administrator_command.rb +383 -264
- data/lib/wakame/runner/agent.rb +1 -5
- data/lib/wakame/runner/master.rb +0 -3
- data/lib/wakame/service.rb +817 -538
- data/lib/wakame/status_db.rb +383 -0
- data/lib/wakame/template.rb +27 -130
- data/lib/wakame/trigger.rb +10 -18
- data/lib/wakame/triggers/instance_count_update.rb +1 -1
- data/lib/wakame/triggers/load_history.rb +1 -1
- data/lib/wakame/triggers/maintain_ssh_known_hosts.rb +8 -5
- data/lib/wakame/triggers/shutdown_unused_vm.rb +1 -1
- data/lib/wakame/util.rb +64 -55
- data/lib/wakame.rb +4 -0
- data/tests/test_action_manager.rb +111 -0
- data/tests/test_service.rb +128 -23
- data/tests/test_status_db.rb +82 -0
- data/tests/test_uri_amqp.rb +10 -0
- data/wakame_generators/resource/templates/apache_app/apache_app.rb +19 -18
- data/wakame_generators/resource/templates/apache_app/conf/apache2.conf +14 -2
- data/wakame_generators/resource/templates/apache_app/conf/system-app.conf +1 -1
- data/wakame_generators/resource/templates/apache_app/conf/vh/aaa.test.conf +9 -0
- data/wakame_generators/resource/templates/apache_lb/apache_lb.rb +21 -20
- data/wakame_generators/resource/templates/apache_lb/conf/apache2.conf +14 -2
- data/wakame_generators/resource/templates/apache_lb/conf/system-lb.conf +17 -2
- data/wakame_generators/resource/templates/apache_lb/conf/vh/aaa.test.conf +37 -0
- data/wakame_generators/resource/templates/apache_www/apache_www.rb +20 -18
- data/wakame_generators/resource/templates/apache_www/conf/apache2.conf +14 -2
- data/wakame_generators/resource/templates/apache_www/conf/system-www.conf +1 -1
- data/wakame_generators/resource/templates/apache_www/conf/vh/aaa.test.conf +9 -0
- data/wakame_generators/resource/templates/ec2_elastic_ip/ec2_elastic_ip.rb +6 -8
- data/wakame_generators/resource/templates/ec2_elb/ec2_elb.rb +7 -6
- data/wakame_generators/resource/templates/memcached/conf/memcached.conf +47 -0
- data/wakame_generators/resource/templates/memcached/init.d/memcached +61 -0
- data/wakame_generators/resource/templates/memcached/memcached.rb +73 -0
- data/wakame_generators/resource/templates/mysql_master/conf/my.cnf +5 -7
- data/wakame_generators/resource/templates/mysql_master/mysql_master.rb +35 -34
- data/wakame_generators/resource/templates/mysql_slave/conf/my.cnf +6 -6
- data/wakame_generators/resource/templates/mysql_slave/mysql_slave.rb +21 -24
- data/wakame_generators/resource/templates/nginx/conf/nginx.conf +17 -27
- data/wakame_generators/resource/templates/nginx/conf/vh/aaa.test.conf +30 -0
- data/wakame_generators/resource/templates/nginx/nginx.rb +18 -18
- metadata +34 -21
- data/lib/wakame/actions/propagate_instances.rb +0 -70
- data/lib/wakame/manager/commands.rb +0 -134
- data/lib/wakame/rule.rb +0 -116
- data/lib/wakame/triggers/process_command.rb +0 -41
- data/tests/test_rule_engine.rb +0 -127
- data/wakame_generators/resource/templates/apache_app/conf/sites-app.conf +0 -23
- data/wakame_generators/resource/templates/apache_lb/conf/sites-lb.conf +0 -54
- data/wakame_generators/resource/templates/apache_www/conf/sites-www.conf +0 -23
@@ -0,0 +1,14 @@
|
|
1
|
+
class Wakame::Command::StartService
|
2
|
+
include Wakame::Command
|
3
|
+
|
4
|
+
command_name='start_service'
|
5
|
+
|
6
|
+
def run
|
7
|
+
svc = service_cluster.find_service(params[:service_id])
|
8
|
+
if svc.nil?
|
9
|
+
raise "Unknown Service ID: #{params[:service_id]}"
|
10
|
+
end
|
11
|
+
|
12
|
+
trigger_action(Wakame::Actions::StartService.new(svc))
|
13
|
+
end
|
14
|
+
end
|
@@ -1,19 +1,41 @@
|
|
1
1
|
|
2
|
-
require 'erb'
|
3
|
-
|
4
2
|
class Wakame::Command::Status
|
5
3
|
include Wakame::Command
|
4
|
+
include Wakame::Service
|
6
5
|
|
7
|
-
def run
|
8
|
-
|
9
|
-
master = rule.master
|
10
|
-
|
11
|
-
@service_cluster = master.service_cluster.dump_status
|
12
|
-
@agent_monitor = master.agent_monitor.dump_status
|
6
|
+
def run
|
7
|
+
Wakame::StatusDB.barrier {
|
13
8
|
res = {
|
14
|
-
:
|
15
|
-
:
|
9
|
+
:cluster=>nil,
|
10
|
+
:agent_pool=>nil,
|
11
|
+
:agents=>{},
|
12
|
+
:services=>{},
|
13
|
+
:resources=>{},
|
14
|
+
:cloud_hosts=>{}
|
15
|
+
}
|
16
|
+
|
17
|
+
res[:agent_pool] = AgentPool.instance.dump_attrs
|
18
|
+
AgentPool.instance.group_active.keys.each { |id|
|
19
|
+
res[:agents][id] = Agent.find(id).dump_attrs
|
16
20
|
}
|
21
|
+
|
22
|
+
cluster_id = master.cluster_manager.clusters.first
|
23
|
+
if cluster_id
|
24
|
+
cluster = ServiceCluster.find(cluster_id)
|
25
|
+
res[:cluster] = cluster.dump_attrs
|
26
|
+
cluster.services.keys.each { |id|
|
27
|
+
res[:services][id]=ServiceInstance.find(id).dump_attrs
|
28
|
+
}
|
29
|
+
|
30
|
+
cluster.resources.keys.each { |id|
|
31
|
+
res[:resources][id]=Resource.find(id).dump_attrs
|
32
|
+
}
|
33
|
+
|
34
|
+
cluster.cloud_hosts.keys.each { |id|
|
35
|
+
res[:cloud_hosts][id]=CloudHost.find(id).dump_attrs
|
36
|
+
}
|
37
|
+
end
|
38
|
+
#p res[:cluster]
|
17
39
|
res
|
18
40
|
}
|
19
41
|
|
@@ -3,29 +3,35 @@ class Wakame::Command::StopService
|
|
3
3
|
|
4
4
|
command_name='stop_service'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
if !@options["service_name"].nil?
|
13
|
-
levels = rule.service_cluster.dg.levels
|
14
|
-
levels.reverse.each {|lv|
|
15
|
-
lv.each { |svc_prop|
|
16
|
-
if svc_prop.class.to_s == @options["service_name"].to_s
|
17
|
-
rule.service_cluster.each_instance(svc_prop.class) { |svc_inst|
|
18
|
-
rule.trigger_action(Wakame::Actions::StopService.new(svc_inst))
|
19
|
-
}
|
20
|
-
end
|
21
|
-
}
|
22
|
-
}
|
6
|
+
# terminate
|
7
|
+
# service_id or resource_name
|
8
|
+
def run
|
9
|
+
do_terminate = true
|
10
|
+
if options['do_terminate'] == 'false'
|
11
|
+
do_terminate = false
|
23
12
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
13
|
+
|
14
|
+
if options['service_id']
|
15
|
+
svc_inst = service_cluster.find_service(options['service_id'])
|
16
|
+
trigger_action(Wakame::Actions::StopService.new(svc_inst, do_terminate))
|
17
|
+
elsif options['resource_name']
|
18
|
+
# resource_name is expected to be set two types of name: the class name inherited from Resource or the module name.
|
19
|
+
# The user can stop set of service instances as per the filterring rule of each_instace() method.
|
20
|
+
# For example: if you pass "HttpServer" module name to the resource_name option, all the services include "HttpServer" module
|
21
|
+
# will be stopped in one shot.
|
22
|
+
filter_type = Wakame::Util.build_const(options['resource_name'])
|
23
|
+
if (filter_type.is_a?(Module) && !filter_type.is_a?(Class)) ||
|
24
|
+
(filter_type.is_a?(Class) && filter_type < Wakame::Service::Resource)
|
25
|
+
# They are valid filter types.
|
26
|
+
else
|
27
|
+
raise "Invalid names as resource name: #{options['resource_name']}"
|
28
|
+
end
|
29
|
+
service_cluster.each_instance(filter_type).each { |svc_inst|
|
30
|
+
trigger_action(Wakame::Actions::StopService.new(svc_inst, do_terminate))
|
28
31
|
}
|
32
|
+
else
|
33
|
+
raise "Could not find valid service_id or resource_name parameter."
|
29
34
|
end
|
35
|
+
|
30
36
|
end
|
31
37
|
end
|
data/lib/wakame/command.rb
CHANGED
@@ -21,14 +21,30 @@ module Wakame
|
|
21
21
|
@options = path
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def params
|
25
|
+
@options
|
25
26
|
end
|
27
|
+
alias :options :params
|
26
28
|
|
27
|
-
def run
|
29
|
+
def run
|
28
30
|
end
|
29
31
|
|
30
|
-
|
32
|
+
protected
|
33
|
+
def master
|
34
|
+
Master.instance
|
31
35
|
end
|
32
36
|
|
37
|
+
def trigger_action(action)
|
38
|
+
master.action_manager.trigger_action(action)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Tentative utility method for
|
42
|
+
def service_cluster
|
43
|
+
cluster_id = master.cluster_manager.clusters.first
|
44
|
+
raise "There is no cluster loaded" if cluster_id.nil?
|
45
|
+
|
46
|
+
Service::ServiceCluster.find(cluster_id)
|
47
|
+
end
|
48
|
+
alias :cluster :service_cluster
|
33
49
|
end
|
34
50
|
end
|
data/lib/wakame/command_queue.rb
CHANGED
@@ -8,12 +8,40 @@ require 'json'
|
|
8
8
|
|
9
9
|
module Wakame
|
10
10
|
class CommandQueue
|
11
|
-
|
11
|
+
include Manager
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
@master = master
|
13
|
+
def initialize()
|
15
14
|
@queue = Queue.new
|
16
15
|
@result_queue = Queue.new
|
16
|
+
@statistics = {
|
17
|
+
:total_command_count => 0
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def init
|
22
|
+
@command_thread = Thread.new {
|
23
|
+
Wakame.log.info("#{self.class}: Started command thread: #{Thread.current}")
|
24
|
+
while cmd = @queue.deq
|
25
|
+
begin
|
26
|
+
unless cmd.kind_of?(Wakame::Command)
|
27
|
+
Wakame.log.warn("#{self.class}: Incompatible type of object has been sent to ProcessCommand thread. #{cmd.class}")
|
28
|
+
next
|
29
|
+
end
|
30
|
+
|
31
|
+
res = nil
|
32
|
+
StatusDB.barrier {
|
33
|
+
Wakame.log.debug("#{self.class}: Being processed the command: #{cmd.class}")
|
34
|
+
res = cmd.run
|
35
|
+
res
|
36
|
+
}
|
37
|
+
rescue => e
|
38
|
+
Wakame.log.error(e)
|
39
|
+
res = e
|
40
|
+
ensure
|
41
|
+
@result_queue.enq(res)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
}
|
17
45
|
|
18
46
|
cmdsv_uri = URI.parse(Wakame.config.http_command_server_uri)
|
19
47
|
|
@@ -22,23 +50,13 @@ module Wakame
|
|
22
50
|
@thin_server.start
|
23
51
|
end
|
24
52
|
|
25
|
-
def
|
53
|
+
def terminate
|
26
54
|
@thin_server.stop
|
27
|
-
|
28
|
-
|
29
|
-
def deq_cmd()
|
30
|
-
@queue.deq
|
31
|
-
end
|
32
|
-
|
33
|
-
def enq_result(res)
|
34
|
-
@result_queue.enq(res)
|
55
|
+
@command_thread.kill
|
35
56
|
end
|
36
57
|
|
37
58
|
def send_cmd(cmd)
|
38
59
|
begin
|
39
|
-
|
40
|
-
#cmd = Marshal.load(cmd)
|
41
|
-
|
42
60
|
@queue.enq(cmd)
|
43
61
|
|
44
62
|
ED.fire_event(Event::CommandReceived.new(cmd))
|
@@ -50,66 +68,68 @@ module Wakame
|
|
50
68
|
end
|
51
69
|
end
|
52
70
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
req = Rack::Request.new(env)
|
63
|
-
begin
|
64
|
-
unless req.get?().to_s == "true"
|
65
|
-
raise "No Support Response"
|
66
|
-
end
|
67
|
-
query = req.query_string()
|
68
|
-
params = req.params()
|
69
|
-
if Wakame.config.enable_authentication == "true"
|
70
|
-
auth = authentication(params, query)
|
71
|
-
end
|
72
|
-
cname = params["action"].split("_")
|
71
|
+
|
72
|
+
class Adapter
|
73
|
+
|
74
|
+
def initialize(command_queue)
|
75
|
+
@command_queue = command_queue
|
76
|
+
end
|
77
|
+
|
78
|
+
def call(env)
|
79
|
+
req = Rack::Request.new(env)
|
73
80
|
begin
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
unless req.get?().to_s == "true"
|
82
|
+
raise "No Support Response"
|
83
|
+
end
|
84
|
+
query = req.query_string()
|
85
|
+
params = req.params()
|
86
|
+
if Wakame.config.enable_authentication == "true"
|
87
|
+
auth = authentication(params, query)
|
88
|
+
end
|
89
|
+
cname = params["action"].split("_")
|
90
|
+
begin
|
91
|
+
cmd = eval("Command::#{(cname.collect{|c| c.capitalize}).join}").new
|
92
|
+
cmd.options = params
|
93
|
+
command = @command_queue.send_cmd(cmd)
|
94
|
+
|
95
|
+
if command.is_a?(Exception)
|
96
|
+
status = 500
|
97
|
+
body = json_encode(status, command.message)
|
98
|
+
else
|
99
|
+
status = 200
|
100
|
+
body = json_encode(status, "OK", command)
|
101
|
+
end
|
102
|
+
rescue => e
|
103
|
+
status = 404
|
104
|
+
body = json_encode(status, e)
|
105
|
+
end
|
85
106
|
rescue => e
|
86
|
-
|
87
|
-
|
107
|
+
status = 403
|
108
|
+
body = json_encode(status, e)
|
109
|
+
Wakame.log.error(e)
|
88
110
|
end
|
89
|
-
|
90
|
-
status = 403
|
91
|
-
body = json_encode(status, e)
|
111
|
+
[ status, {'Content-Type' => 'text/javascript+json'}, body]
|
92
112
|
end
|
93
|
-
[ status, {'Content-Type' => 'text/javascript+json'}, body]
|
94
|
-
end
|
95
113
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
114
|
+
def authentication(path, query)
|
115
|
+
key = Wakame.config.private_key
|
116
|
+
req = query.split(/\&signature\=/)
|
117
|
+
hash = OpenSSL::HMAC::digest(OpenSSL::Digest::SHA256.new, key, req[0])
|
118
|
+
hmac = Base64.encode64(hash).gsub(/\+/, "").gsub(/\n/, "").to_s
|
119
|
+
if hmac != path["signature"]
|
120
|
+
raise "Authentication failed"
|
121
|
+
end
|
103
122
|
end
|
104
|
-
end
|
105
123
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
124
|
+
def json_encode(status, message, data=nil)
|
125
|
+
if status == 200 && data.is_a?(Hash)
|
126
|
+
body = [{:status=>status, :message=>message}, {:data=>data}].to_json
|
127
|
+
else
|
128
|
+
body = [{:status=>status, :message=>message}].to_json
|
129
|
+
end
|
130
|
+
body
|
111
131
|
end
|
112
|
-
body
|
113
132
|
end
|
133
|
+
|
114
134
|
end
|
115
135
|
end
|
data/lib/wakame/configuration.rb
CHANGED
@@ -9,6 +9,7 @@ module Wakame
|
|
9
9
|
PARAMS = {
|
10
10
|
#:config_template_root => nil,
|
11
11
|
#:config_tmp_root => nil,
|
12
|
+
:status_db_dsn => nil,
|
12
13
|
:config_root => nil,
|
13
14
|
:cluster_class => 'WebCluster',
|
14
15
|
:load_paths => [],
|
@@ -69,9 +70,14 @@ module Wakame
|
|
69
70
|
%w(lib).map{|dir| File.join(root_path, dir) }.select{|path| File.directory?(path)}
|
70
71
|
end
|
71
72
|
|
73
|
+
def cluster_config_path
|
74
|
+
File.expand_path('config/cluster.rb', root_path)
|
75
|
+
end
|
76
|
+
|
72
77
|
#
|
73
78
|
class DefaultSet
|
74
79
|
def process(config)
|
80
|
+
config.status_db_dsn = "sqlite://" + File.expand_path('tmp/wakame.db', config.root_path)
|
75
81
|
end
|
76
82
|
end
|
77
83
|
|
data/lib/wakame/event.rb
CHANGED
@@ -100,6 +100,23 @@ module Wakame
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
+
class ServiceUnboundHost < Base
|
104
|
+
attr_reader :service, :host
|
105
|
+
def initialize(service, host)
|
106
|
+
super()
|
107
|
+
@service = service
|
108
|
+
@host = host
|
109
|
+
end
|
110
|
+
end
|
111
|
+
class ServiceBoundHost < Base
|
112
|
+
attr_reader :service, :host
|
113
|
+
def initialize(service, host)
|
114
|
+
super()
|
115
|
+
@service = service
|
116
|
+
@host = host
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
103
120
|
class ServiceBoundCluster < Base
|
104
121
|
attr_reader :service, :service_cluster
|
105
122
|
def initialize(svc_inst, cluster)
|
@@ -14,10 +14,19 @@ module Wakame
|
|
14
14
|
self.instance.subscribe(event_class, *args, &blk)
|
15
15
|
end
|
16
16
|
|
17
|
-
def unsubscribe(
|
18
|
-
self.instance.unsubscribe(
|
17
|
+
def unsubscribe(ticket)
|
18
|
+
self.instance.unsubscribe(ticket)
|
19
19
|
end
|
20
20
|
|
21
|
+
def subscribe_once(event_class, *args, &blk)
|
22
|
+
tkt = self.subscribe(event_class, *args) { |event|
|
23
|
+
begin
|
24
|
+
blk.call(event) if blk
|
25
|
+
ensure
|
26
|
+
self.unsubscribe(tkt)
|
27
|
+
end
|
28
|
+
}
|
29
|
+
end
|
21
30
|
|
22
31
|
def fire_event(event_obj)
|
23
32
|
self.instance.fire_event(event_obj)
|
@@ -48,25 +57,25 @@ module Wakame
|
|
48
57
|
raise ArgumentError, "event_class has to be a form of String or Class type"
|
49
58
|
end
|
50
59
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
60
|
+
StatusDB.barrier {
|
61
|
+
tlist = @event_handlers[event_class]
|
62
|
+
if tlist.nil?
|
63
|
+
tlist = @event_handlers[event_class] = []
|
64
|
+
end
|
65
|
+
|
66
|
+
tickets = []
|
67
|
+
args.each { |o|
|
68
|
+
tickets << Util.gen_id
|
69
|
+
@tickets.store(tickets.last, [event_class, o])
|
70
|
+
tlist << tickets.last
|
71
|
+
}
|
72
|
+
|
73
|
+
if blk
|
74
|
+
tickets << Util.gen_id
|
75
|
+
@tickets.store(tickets.last, [event_class, blk])
|
76
|
+
tlist << tickets.last
|
77
|
+
end
|
78
|
+
|
70
79
|
# Return in array if num of ticket to be returned is more than or equal 2.
|
71
80
|
tickets.size > 1 ? tickets : tickets.first
|
72
81
|
}
|
@@ -78,7 +87,7 @@ module Wakame
|
|
78
87
|
return nil
|
79
88
|
end
|
80
89
|
|
81
|
-
|
90
|
+
StatusDB.barrier {
|
82
91
|
Wakame.log.debug("#{self.class}.unsubscribe(#{ticket})")
|
83
92
|
|
84
93
|
@unsubscribe_queue << ticket
|
@@ -126,7 +135,7 @@ module Wakame
|
|
126
135
|
|
127
136
|
#@handler_run_queue.push(run_handlers)
|
128
137
|
|
129
|
-
|
138
|
+
StatusDB.barrier {
|
130
139
|
begin
|
131
140
|
run_callbacks.call
|
132
141
|
rescue => e
|
data/lib/wakame/graph.rb
CHANGED
data/lib/wakame/initializer.rb
CHANGED
@@ -29,7 +29,7 @@ module Wakame
|
|
29
29
|
|
30
30
|
def process_master
|
31
31
|
process
|
32
|
-
|
32
|
+
setup_database
|
33
33
|
load_resources
|
34
34
|
load_core_commands
|
35
35
|
load_core_actions
|
@@ -43,7 +43,6 @@ module Wakame
|
|
43
43
|
|
44
44
|
def process_cli
|
45
45
|
process
|
46
|
-
load_core_commands
|
47
46
|
end
|
48
47
|
|
49
48
|
def setup_load_paths
|
@@ -60,6 +59,7 @@ module Wakame
|
|
60
59
|
#log = Logger.new((Wakame.root||Dir.pwd) / "log.log")
|
61
60
|
out = ::Log4r::StdoutOutputter.new('stdout',
|
62
61
|
:formatter => Log4r::PatternFormatter.new(
|
62
|
+
:depth => 9999, # stack trace depth
|
63
63
|
:pattern => "%d %C [%l]: %M",
|
64
64
|
:date_format => "%Y/%m/%d %H:%M:%S"
|
65
65
|
)
|
@@ -113,6 +113,12 @@ module Wakame
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def load_resources
|
116
|
+
load_path = File.expand_path('cluster/resources/markers', configuration.root_path)
|
117
|
+
Dir.glob("#{load_path}/*.rb").sort.each do |file|
|
118
|
+
Wakame.log.debug("Loading resource marker: #{file}")
|
119
|
+
load file
|
120
|
+
end
|
121
|
+
|
116
122
|
load_path = File.expand_path('cluster/resources', configuration.root_path)
|
117
123
|
Dir.glob("#{load_path}/*/*.rb").sort.each do |file|
|
118
124
|
if file =~ %r{\A#{Regexp.escape(load_path)}/([^/]+)/([^/]+)\.rb\Z} && $1 == $2
|
@@ -121,12 +127,6 @@ module Wakame
|
|
121
127
|
end
|
122
128
|
#require file.sub(matcher, '\1')
|
123
129
|
end
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
|
128
|
-
def load_cluster
|
129
|
-
load File.expand_path('config/cluster.rb', configuration.root_path)
|
130
130
|
end
|
131
131
|
|
132
132
|
def load_actors
|
@@ -157,6 +157,9 @@ module Wakame
|
|
157
157
|
}
|
158
158
|
end
|
159
159
|
|
160
|
+
def setup_database
|
161
|
+
Wakame::StatusDB.adapter
|
162
|
+
end
|
160
163
|
|
161
164
|
end
|
162
165
|
end
|