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
@@ -1,70 +0,0 @@
|
|
1
|
-
module Wakame
|
2
|
-
module Actions
|
3
|
-
class PropagateInstances < Action
|
4
|
-
|
5
|
-
def initialize(svc_prop, propagate_num=0)
|
6
|
-
raise ArgumentError unless svc_prop.is_a?(Wakame::Service::Resource)
|
7
|
-
@svc_prop = svc_prop
|
8
|
-
@propagate_num = propagate_num
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
svc_to_start = []
|
13
|
-
|
14
|
-
EM.barrier {
|
15
|
-
@propagate_num.times {
|
16
|
-
service_cluster.propagate(@svc_prop)
|
17
|
-
}
|
18
|
-
|
19
|
-
# First, look for the service instances which are already created in the cluster. Then they will be scheduled to start the services later.
|
20
|
-
online_svc = []
|
21
|
-
service_cluster.each_instance(@svc_prop.class) { |svc_inst|
|
22
|
-
if svc_inst.status == Service::STATUS_ONLINE || svc_inst.status == Service::STATUS_STARTING
|
23
|
-
online_svc << svc_inst
|
24
|
-
else
|
25
|
-
svc_to_start << svc_inst
|
26
|
-
end
|
27
|
-
}
|
28
|
-
|
29
|
-
# The list is empty means that this action is called to propagate a new service instance instead of just starting scheduled instances.
|
30
|
-
svc_count = service_cluster.instance_count(@svc_prop)
|
31
|
-
if svc_count > online_svc.size + svc_to_start.size
|
32
|
-
Wakame.log.debug("#{self.class}: @svc_prop.instance_count - online_svc.size=#{svc_count - online_svc.size}")
|
33
|
-
(svc_count - (online_svc.size + svc_to_start.size)).times {
|
34
|
-
svc_to_start << service_cluster.propagate(@svc_prop.class)
|
35
|
-
}
|
36
|
-
end
|
37
|
-
}
|
38
|
-
|
39
|
-
acquire_lock { |ary|
|
40
|
-
svc_to_start.each { |svc|
|
41
|
-
ary << svc.resource.class
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
svc_to_start.each { |svc|
|
46
|
-
target_agent = nil
|
47
|
-
if svc.property.require_agent
|
48
|
-
# Try to arrange agent from existing agent pool.
|
49
|
-
if svc.agent.nil?
|
50
|
-
EM.barrier {
|
51
|
-
agent_monitor.each_online { |ag|
|
52
|
-
if !ag.has_service_type?(@svc_prop.class) && @svc_prop.vm_spec.current.satisfy?(ag)
|
53
|
-
target_agent = ag
|
54
|
-
break
|
55
|
-
end
|
56
|
-
}
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
60
|
-
Wakame.log.debug("#{self.class}: arranged agent for #{svc.resource.class}: #{target_agent ? target_agent.agent_id : nil}")
|
61
|
-
end
|
62
|
-
|
63
|
-
trigger_action(StartService.new(svc, target_agent))
|
64
|
-
}
|
65
|
-
flush_subactions
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
|
2
|
-
module Wakame
|
3
|
-
module Manager
|
4
|
-
module Commands
|
5
|
-
|
6
|
-
class Nop
|
7
|
-
end
|
8
|
-
|
9
|
-
class ClusterLaunch
|
10
|
-
end
|
11
|
-
|
12
|
-
class ClusterShutdown
|
13
|
-
end
|
14
|
-
|
15
|
-
class DeployConfig
|
16
|
-
attr_reader :property
|
17
|
-
def initialize(prop=nil)
|
18
|
-
@property = prop
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class PropagateService
|
23
|
-
attr_reader :property
|
24
|
-
def initialize(prop)
|
25
|
-
@property = prop
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class MigrateService
|
30
|
-
attr_reader :service_instance, :agent
|
31
|
-
def initialize(svc_inst, agent=nil)
|
32
|
-
@service_instance = svc_inst
|
33
|
-
@agent = agent
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
class CommandDelegator
|
40
|
-
|
41
|
-
attr_reader :command_queue
|
42
|
-
def initialize(command_queue)
|
43
|
-
@command_queue = command_queue
|
44
|
-
end
|
45
|
-
|
46
|
-
def nop
|
47
|
-
@command_queue.send_cmd(Commands::Nop.new)
|
48
|
-
end
|
49
|
-
|
50
|
-
def launch_cluster
|
51
|
-
@command_queue.send_cmd(Commands::ClusterLaunch.new)
|
52
|
-
end
|
53
|
-
|
54
|
-
def shutdown_cluster
|
55
|
-
@command_queue.send_cmd(Commands::ClusterShutdown.new)
|
56
|
-
end
|
57
|
-
def propagate_service(prop_name)
|
58
|
-
prop = nil
|
59
|
-
prop = master.service_cluster.properties[prop_name.to_s]
|
60
|
-
if prop.nil?
|
61
|
-
raise "UnknownProperty: #{prop_name}"
|
62
|
-
end
|
63
|
-
|
64
|
-
@command_queue.send_cmd(Commands::PropagateService.new(prop))
|
65
|
-
end
|
66
|
-
def migrate_service(svc_inst_id, agent_id=nil)
|
67
|
-
svc = master.service_cluster.instances[svc_inst_id]
|
68
|
-
if svc.nil?
|
69
|
-
raise "Unknown Service Instance: #{svc_inst_id}"
|
70
|
-
end
|
71
|
-
agent = nil
|
72
|
-
if agent_id
|
73
|
-
agent = master.agent_monitor.agents.has_key?(agent_id)
|
74
|
-
if agent.nil?
|
75
|
-
raise "Unknown Agent: #{agent_id}"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
@command_queue.send_cmd(Commands::MigrateService.new(svc, agent))
|
80
|
-
end
|
81
|
-
def deploy_config(prop_name=nil)
|
82
|
-
prop = nil
|
83
|
-
@command_queue.send_cmd(Commands::DeployConfig.new)
|
84
|
-
end
|
85
|
-
|
86
|
-
def status
|
87
|
-
EM.barrier {
|
88
|
-
master = Master.instance
|
89
|
-
|
90
|
-
sc = master.service_cluster
|
91
|
-
result = {
|
92
|
-
:rule_engine => {
|
93
|
-
:rules => sc.rule_engine.rules
|
94
|
-
},
|
95
|
-
:service_cluster => sc.dump_status,
|
96
|
-
:agent_monitor => master.agent_monitor.dump_status
|
97
|
-
}
|
98
|
-
result
|
99
|
-
}
|
100
|
-
end
|
101
|
-
|
102
|
-
def action_status
|
103
|
-
walk_subactions = proc { |a, level|
|
104
|
-
res = a.dump_attrs
|
105
|
-
unless a.subactions.empty?
|
106
|
-
res[:subactions] = a.subactions.collect { |s|
|
107
|
-
walk_subactions.call(s, level + 1)
|
108
|
-
}
|
109
|
-
end
|
110
|
-
res
|
111
|
-
}
|
112
|
-
|
113
|
-
EM.barrier {
|
114
|
-
result = {}
|
115
|
-
Master.instance.service_cluster.rule_engine.active_jobs.each { |id, v|
|
116
|
-
result[id]={:actions=>[], :created_at=>v[:created_at], :src_rule=>v[:src_rule].class.to_s}
|
117
|
-
|
118
|
-
result[id][:root_action] = walk_subactions.call(v[:root_action], 0)
|
119
|
-
}
|
120
|
-
|
121
|
-
result
|
122
|
-
}
|
123
|
-
end
|
124
|
-
|
125
|
-
|
126
|
-
private
|
127
|
-
def master
|
128
|
-
command_queue.master
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
end
|
data/lib/wakame/rule.rb
DELETED
@@ -1,116 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'thread'
|
3
|
-
require 'forwardable'
|
4
|
-
require 'timeout'
|
5
|
-
|
6
|
-
require 'wakame/util'
|
7
|
-
|
8
|
-
module Wakame
|
9
|
-
module Rule
|
10
|
-
module BasicActionSet
|
11
|
-
class Lock
|
12
|
-
def initialize
|
13
|
-
@mutex = Mutex.new
|
14
|
-
@cond = ConditionVariable.new
|
15
|
-
end
|
16
|
-
|
17
|
-
def signal
|
18
|
-
@mutex.synchronize {
|
19
|
-
@cond.signal
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
def wait(&blk)
|
24
|
-
if blk.nil?
|
25
|
-
i=0
|
26
|
-
blk = proc {
|
27
|
-
i += 1
|
28
|
-
i > 1 ? true : false
|
29
|
-
}
|
30
|
-
end
|
31
|
-
@mutex.synchronize {
|
32
|
-
@cond.wait(@mutex) while blk.call
|
33
|
-
}
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
class MockLock < Lock
|
38
|
-
def signal
|
39
|
-
end
|
40
|
-
|
41
|
-
def wait(&blk)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
def wait_lock
|
47
|
-
Lock.new
|
48
|
-
end
|
49
|
-
|
50
|
-
def start_instance(image_id, attr={})
|
51
|
-
Wakame.log.debug("#{self.class} called start_instance(#{image_id})")
|
52
|
-
|
53
|
-
attr[:user_data] = "node=agent\namqp_server=amqp://#{master.attr[:local_ipv4]}/"
|
54
|
-
Wakame.log.debug("user_data: #{attr[:user_data]}")
|
55
|
-
vm_manipulator = VmManipulator.create
|
56
|
-
res = vm_manipulator.start_instance(image_id, attr)
|
57
|
-
inst_id = res[:instance_id]
|
58
|
-
|
59
|
-
wait_condition { | cond |
|
60
|
-
cond.wait_event(Event::AgentMonitored) { |event|
|
61
|
-
event.agent.attr[:instance_id] == inst_id
|
62
|
-
}
|
63
|
-
|
64
|
-
cond.poll(5, 100) {
|
65
|
-
vm_manipulator.check_status(inst_id, :online)
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
inst_id
|
70
|
-
end
|
71
|
-
|
72
|
-
def self.deploy_configuration(service_instance)
|
73
|
-
Wakame.log.debug("Begin: #{self}.deploy_configuration(#{service_instance.property.class})")
|
74
|
-
|
75
|
-
begin
|
76
|
-
tmpl = Wakame::Template.new(service_instance)
|
77
|
-
tmpl.render_config
|
78
|
-
|
79
|
-
agent = service_instance.agent
|
80
|
-
src_path = tmpl.tmp_basedir.dup
|
81
|
-
src_path.sub!('/$', '') if File.directory? src_path
|
82
|
-
|
83
|
-
dest_path = File.expand_path("tmp/config/" + File.basename(tmpl.basedir), service_instance.agent.root_path)
|
84
|
-
Util.exec("rsync -e 'ssh -i #{Wakame.config.ssh_private_key} -o \"UserKnownHostsFile #{Wakame.config.ssh_known_hosts}\"' -au #{src_path}/ root@#{agent.agent_ip}:#{dest_path}")
|
85
|
-
#Util.exec("rsync -au #{src_path}/ #{dest_path}")
|
86
|
-
|
87
|
-
ensure
|
88
|
-
tmpl.cleanup if tmpl
|
89
|
-
end
|
90
|
-
|
91
|
-
Wakame.log.debug("End: #{self}.deploy_configuration(#{service_instance.property.class})")
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_agent_candidate(svc_prop, agent)
|
95
|
-
return false if agent.has_service_type?(svc_prop.class)
|
96
|
-
svc_prop.vm_spec.current.satisfy?(agent)
|
97
|
-
end
|
98
|
-
# Arrange an agent for the paticular service instance from agent pool.
|
99
|
-
def arrange_agent(svc_prop)
|
100
|
-
agent = nil
|
101
|
-
agent_monitor.each_online { |ag|
|
102
|
-
if test_agent_candidate(svc_prop, ag)
|
103
|
-
agent = ag
|
104
|
-
break
|
105
|
-
end
|
106
|
-
}
|
107
|
-
agent = agent[1] if agent
|
108
|
-
|
109
|
-
agent
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
end
|
116
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
|
2
|
-
module Wakame
|
3
|
-
module Triggers
|
4
|
-
class ProcessCommand < Trigger
|
5
|
-
def_attribute :status
|
6
|
-
def_attribute :job_id
|
7
|
-
def_attribute :completion_status
|
8
|
-
def_attribute :parent_action
|
9
|
-
def_attribute :acquire_lock, false
|
10
|
-
|
11
|
-
attr_reader :trigger
|
12
|
-
def register_hooks
|
13
|
-
@@command_thread ||= Thread.new {
|
14
|
-
while cmd = self.command_queue.deq_cmd
|
15
|
-
res = nil
|
16
|
-
begin
|
17
|
-
EM.barrier {
|
18
|
-
Wakame.log.debug("#{self.class}: Being processed the command: #{cmd.class}")
|
19
|
-
res = cmd.run(self)
|
20
|
-
res
|
21
|
-
}
|
22
|
-
rescue => e
|
23
|
-
Wakame.log.error(e)
|
24
|
-
res = e
|
25
|
-
ensure
|
26
|
-
self.command_queue.enq_result(res)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
}
|
30
|
-
|
31
|
-
#event_subscribe(Event::CommandReceived) { |event|
|
32
|
-
# event.command.run(self)
|
33
|
-
#}
|
34
|
-
end
|
35
|
-
|
36
|
-
def cleanup
|
37
|
-
@@command_thread.kill if @@command_thread.alive?
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/tests/test_rule_engine.rb
DELETED
@@ -1,127 +0,0 @@
|
|
1
|
-
|
2
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
3
|
-
$:.unshift(File.dirname(__FILE__))
|
4
|
-
|
5
|
-
require 'setup_master.rb'
|
6
|
-
|
7
|
-
require 'rubygems'
|
8
|
-
require 'eventmachine'
|
9
|
-
|
10
|
-
require 'test/unit'
|
11
|
-
require 'wakame'
|
12
|
-
require 'wakame/rule.rb'
|
13
|
-
|
14
|
-
WAKAME_ROOT="#{File.dirname(__FILE__)}/.."
|
15
|
-
|
16
|
-
Wakame::EventDispatcher
|
17
|
-
|
18
|
-
class TestRuleEngine < Test::Unit::TestCase
|
19
|
-
include Wakame::Rule
|
20
|
-
|
21
|
-
class Action1 < Action
|
22
|
-
def run
|
23
|
-
trigger_action(Action2.new)
|
24
|
-
flush_subactions
|
25
|
-
end
|
26
|
-
end
|
27
|
-
class Action2 < Action
|
28
|
-
def run
|
29
|
-
act3 = Action3.new
|
30
|
-
trigger_action(act3)
|
31
|
-
flush_subactions
|
32
|
-
end
|
33
|
-
end
|
34
|
-
class Action3 < Action
|
35
|
-
def run
|
36
|
-
puts "sleeping(2)..."
|
37
|
-
sleep 2
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class Rule1 < Rule
|
42
|
-
def register_hooks
|
43
|
-
trigger_action(Action1.new)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class DummyMaster
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_nested_actions
|
51
|
-
EM.run {
|
52
|
-
engine = RuleEngine.new(Wakame::Service::ServiceCluster.new(Object.new))
|
53
|
-
engine.register_rule(Rule1.new)
|
54
|
-
EM.add_timer(5) { EM.stop }
|
55
|
-
}
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_each_subaction
|
59
|
-
EM.run {
|
60
|
-
engine = RuleEngine.new(Wakame::Service::ServiceCluster.new(Object.new))
|
61
|
-
engine.register_rule(Rule1.new)
|
62
|
-
EM.add_timer(1) {
|
63
|
-
engine.active_jobs.each { |k, v|
|
64
|
-
v[:root_action].walk_subactions {|a|
|
65
|
-
puts a
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
}
|
70
|
-
EM.add_timer(5) { EM.stop }
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
class Rule2 < Rule
|
76
|
-
def register_hooks
|
77
|
-
act1 = Action1.new
|
78
|
-
job_id = trigger_action(act1)
|
79
|
-
puts job_id
|
80
|
-
|
81
|
-
EM.add_timer(1){
|
82
|
-
rule_engine.cancel_action(job_id)
|
83
|
-
}
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_cancel_action
|
88
|
-
EM.run {
|
89
|
-
engine = RuleEngine.new(Wakame::Service::ServiceCluster.new(Object.new))
|
90
|
-
engine.register_rule(Rule2.new)
|
91
|
-
EM.add_timer(5) { EM.stop }
|
92
|
-
}
|
93
|
-
end
|
94
|
-
|
95
|
-
|
96
|
-
class Action4 < Action
|
97
|
-
def run
|
98
|
-
trigger_action(Action1.new)
|
99
|
-
|
100
|
-
trigger_action(FailAction1.new)
|
101
|
-
|
102
|
-
flush_subactions
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
class FailAction1 < Action
|
107
|
-
def run
|
108
|
-
trigger_action(Action1.new)
|
109
|
-
raise StandardError
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
class Rule3 < Rule
|
114
|
-
def register_hooks
|
115
|
-
trigger_action(Action4.new)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_cancel_escalation
|
120
|
-
EM.run {
|
121
|
-
engine = RuleEngine.new(Wakame::Service::ServiceCluster.new(Object.new))
|
122
|
-
engine.register_rule(Rule3.new)
|
123
|
-
EM.add_timer(10) { EM.stop }
|
124
|
-
}
|
125
|
-
end
|
126
|
-
|
127
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
NameVirtualHost *:<%= property.listen_port %>
|
2
|
-
|
3
|
-
# Wild Card Virtual Host
|
4
|
-
#<VirtualHost *:<%= property.listen_port %>>
|
5
|
-
#DocumentRoot /var/www
|
6
|
-
#
|
7
|
-
#LogLevel warn
|
8
|
-
#CustomLog /var/log/apache2/access-app.log combined
|
9
|
-
#ErrorLog /var/log/apache2/error-app.log
|
10
|
-
#
|
11
|
-
#</VirtualHost>
|
12
|
-
|
13
|
-
<%- cluster.virtual_hosts.each { |vh| -%>
|
14
|
-
<VirtualHost *:<%= property.listen_port %>>
|
15
|
-
ServerName <%= vh.server_name %>
|
16
|
-
DocumentRoot /home/wakame/apps/development/test/public
|
17
|
-
RailsEnv development
|
18
|
-
|
19
|
-
LogLevel warn
|
20
|
-
CustomLog /var/log/apache2/access-app.log combined
|
21
|
-
ErrorLog /var/log/apache2/error-app.log
|
22
|
-
</VirtualHost>
|
23
|
-
<%- } -%>
|
@@ -1,54 +0,0 @@
|
|
1
|
-
NameVirtualHost *:<%= property.listen_port %>
|
2
|
-
|
3
|
-
# Wild Card Virtual Host
|
4
|
-
#<VirtualHost *:<%= property.listen_port %>>
|
5
|
-
#DocumentRoot /var/www/
|
6
|
-
#
|
7
|
-
#LogLevel warn
|
8
|
-
#CustomLog /var/log/apache2/access-lb.log combined
|
9
|
-
#ErrorLog /var/log/apache2/error-lb.log
|
10
|
-
#
|
11
|
-
#</VirtualHost>
|
12
|
-
|
13
|
-
<%- service_cluster.virtual_hosts.each { |vh| -%>
|
14
|
-
<VirtualHost *:<%= property.listen_port %>>
|
15
|
-
ServerName <%= vh.server_name %>
|
16
|
-
DocumentRoot /var/www/
|
17
|
-
|
18
|
-
LogLevel warn
|
19
|
-
CustomLog /var/log/apache2/<%= vh.server_name %>-access.log combined
|
20
|
-
ErrorLog /var/log/apache2/<%= vh.server_name %>-error.log
|
21
|
-
|
22
|
-
<Location /balancer-manager>
|
23
|
-
SetHandler balancer-manager
|
24
|
-
# Order deny,allow
|
25
|
-
# Deny from all
|
26
|
-
# Allow from 127.0.0.1 localhost.localdomain localhost ip6-localhost
|
27
|
-
</Location>
|
28
|
-
|
29
|
-
<Proxy balancer://cluster-www>
|
30
|
-
<%- service_cluster.each_www { |n|
|
31
|
-
next if n.status != STATUS_ONLINE
|
32
|
-
-%>
|
33
|
-
BalancerMember http://<%= n.agent.agent_ip %>:<%= n.property.listen_port %> loadfactor=10
|
34
|
-
<%- } -%>
|
35
|
-
</Proxy>
|
36
|
-
<Proxy balancer://cluster-app>
|
37
|
-
<%- service_cluster.each_app { |n|
|
38
|
-
next if n.status != STATUS_ONLINE
|
39
|
-
-%>
|
40
|
-
BalancerMember http://<%= n.agent.agent_ip %>:<%= n.property.listen_port %> loadfactor=10
|
41
|
-
<%- } -%>
|
42
|
-
</Proxy>
|
43
|
-
ProxyRequests Off
|
44
|
-
ProxyPreserveHost On
|
45
|
-
ProxyPassReverse / balancer://cluster-www/
|
46
|
-
ProxyPassReverse / balancer://cluster-app/
|
47
|
-
|
48
|
-
ProxyPassMatch ^(/(images|image|imgs|img|javascripts|javascript|js|stylesheets|css)/.*)$ balancer://cluster-www$1 lbmethod=byrequests timeout=10
|
49
|
-
ProxyPassMatch ^(/.*\.(htm|html|ico|jpg|jpeg|png|gif|swf|txt))$ balancer://cluster-www$1 lbmethod=byrequests timeout=10
|
50
|
-
ProxyPassMatch ^/balancer-manager.* !
|
51
|
-
ProxyPass / balancer://cluster-app/ lbmethod=byrequests timeout=10
|
52
|
-
|
53
|
-
</VirtualHost>
|
54
|
-
<%- } -%>
|
@@ -1,23 +0,0 @@
|
|
1
|
-
NameVirtualHost *:<%= property.listen_port %>
|
2
|
-
|
3
|
-
# Wild Card Virtual Host
|
4
|
-
#<VirtualHost *:<%= property.listen_port %>>
|
5
|
-
#DocumentRoot /var/www
|
6
|
-
#
|
7
|
-
#LogLevel warn
|
8
|
-
#CustomLog /var/log/apache2/access-www.log combined
|
9
|
-
#ErrorLog /var/log/apache2/error-www.log
|
10
|
-
#
|
11
|
-
#</VirtualHost>
|
12
|
-
|
13
|
-
<%- cluster.virtual_hosts.each { |vh| -%>
|
14
|
-
<VirtualHost *:<%= property.listen_port %>>
|
15
|
-
ServerName <%= vh.server_name %>
|
16
|
-
DocumentRoot /home/wakame/apps/development/test/public
|
17
|
-
|
18
|
-
LogLevel warn
|
19
|
-
CustomLog /var/log/apache2/access-www.log combined
|
20
|
-
ErrorLog /var/log/apache2/error-www.log
|
21
|
-
|
22
|
-
</VirtualHost>
|
23
|
-
<%- } -%>
|