dtr 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +21 -0
- data/README.rdoc +39 -28
- data/Rakefile +1 -1
- data/TODO +1 -3
- data/bin/dtr +20 -13
- data/dtr.gemspec +3 -3
- data/lib/dtr.rb +2 -2
- data/lib/dtr/agent.rb +12 -5
- data/lib/dtr/agent/brain.rb +45 -19
- data/lib/dtr/agent/herald.rb +8 -10
- data/lib/dtr/agent/process_root.rb +23 -0
- data/lib/dtr/agent/rails_ext.rb +57 -0
- data/lib/dtr/agent/runner.rb +19 -39
- data/lib/dtr/agent/sync_codebase.rb +10 -19
- data/lib/dtr/agent/sync_logger.rb +1 -0
- data/lib/dtr/agent/worker.rb +13 -61
- data/lib/dtr/agent/working_env_ext.rb +51 -17
- data/lib/dtr/agent/working_status.rb +34 -0
- data/lib/dtr/facade.rb +19 -17
- data/lib/dtr/master.rb +2 -0
- data/lib/dtr/monitor.rb +2 -2
- data/lib/dtr/raketasks.rb +14 -19
- data/lib/dtr/shared.rb +1 -0
- data/lib/dtr/shared/adapter.rb +2 -101
- data/lib/dtr/shared/adapter/base.rb +118 -0
- data/lib/dtr/shared/adapter/mortality.rb +41 -0
- data/lib/dtr/shared/configuration.rb +32 -14
- data/lib/dtr/shared/root.rb +20 -0
- data/lib/dtr/shared/sync_codebase/master_ext.rb +2 -2
- data/lib/dtr/shared/sync_codebase/sync_service.rb +7 -4
- data/lib/dtr/shared/utils/cmd.rb +4 -2
- data/lib/dtr/shared/utils/env_store.rb +16 -24
- data/lib/dtr/shared/working_env.rb +8 -0
- data/lib/dtr/test_unit/drb_test_runner.rb +1 -1
- data/lib/dtr/test_unit/thread_safe_test_result.rb +56 -3
- data/test/acceptance/dtr_package_task_test.rb +3 -3
- data/test/acceptance/general_test.rb +3 -3
- data/test/acceptance/rails_ext_test.rb +86 -0
- data/test/acceptance/raketasks_test.rb +14 -0
- data/test/acceptance/sync_codebase_test.rb +8 -31
- data/test/acceptance/sync_logger_test.rb +6 -3
- data/test/agent_helper.rb +24 -16
- data/test/logger_stub.rb +3 -3
- data/test/test_helper.rb +12 -9
- data/test/unit/adapter_test.rb +1 -1
- data/test/unit/configuration_test.rb +36 -4
- data/test/unit/database_initializer_test.rb +36 -0
- data/test/unit/facade_test.rb +11 -1
- data/test/unit/thread_safe_test_result_test.rb +41 -0
- data/test/unit/working_env_test.rb +11 -21
- data/testdata/rails_projects/simple_project/README +256 -0
- data/testdata/rails_projects/simple_project/Rakefile +10 -0
- data/testdata/rails_projects/simple_project/app/controllers/application.rb +15 -0
- data/testdata/rails_projects/simple_project/app/controllers/products_controller.rb +5 -0
- data/testdata/rails_projects/simple_project/app/helpers/application_helper.rb +3 -0
- data/testdata/rails_projects/simple_project/app/helpers/products_helper.rb +2 -0
- data/testdata/rails_projects/simple_project/app/models/product.rb +5 -0
- data/testdata/rails_projects/simple_project/app/views/products/index.rhtml +7 -0
- data/testdata/rails_projects/simple_project/config/boot.rb +109 -0
- data/testdata/rails_projects/simple_project/config/database.yml +19 -0
- data/testdata/rails_projects/simple_project/config/database.yml.mysql +12 -0
- data/testdata/rails_projects/simple_project/config/environment.rb +67 -0
- data/testdata/rails_projects/simple_project/config/environments/development.rb +17 -0
- data/testdata/rails_projects/simple_project/config/environments/production.rb +22 -0
- data/testdata/rails_projects/simple_project/config/environments/test.rb +22 -0
- data/testdata/rails_projects/simple_project/config/initializers/inflections.rb +10 -0
- data/testdata/rails_projects/simple_project/config/initializers/mime_types.rb +5 -0
- data/testdata/rails_projects/simple_project/config/initializers/new_rails_defaults.rb +17 -0
- data/testdata/rails_projects/simple_project/config/routes.rb +43 -0
- data/testdata/rails_projects/simple_project/db/migrate/20081027133744_create_products.rb +13 -0
- data/testdata/rails_projects/simple_project/db/schema.rb +21 -0
- data/testdata/rails_projects/simple_project/doc/README_FOR_APP +2 -0
- data/testdata/rails_projects/simple_project/public/404.html +30 -0
- data/testdata/rails_projects/simple_project/public/422.html +30 -0
- data/testdata/rails_projects/simple_project/public/500.html +30 -0
- data/testdata/rails_projects/simple_project/public/dispatch.cgi +10 -0
- data/testdata/rails_projects/simple_project/public/dispatch.fcgi +24 -0
- data/testdata/rails_projects/simple_project/public/dispatch.rb +10 -0
- data/testdata/rails_projects/simple_project/public/favicon.ico +0 -0
- data/testdata/rails_projects/simple_project/public/images/rails.png +0 -0
- data/testdata/rails_projects/simple_project/public/index.html +274 -0
- data/testdata/rails_projects/simple_project/public/javascripts/application.js +2 -0
- data/testdata/rails_projects/simple_project/public/javascripts/controls.js +963 -0
- data/testdata/rails_projects/simple_project/public/javascripts/dragdrop.js +972 -0
- data/testdata/rails_projects/simple_project/public/javascripts/effects.js +1120 -0
- data/testdata/rails_projects/simple_project/public/javascripts/prototype.js +4225 -0
- data/testdata/rails_projects/simple_project/public/robots.txt +5 -0
- data/testdata/rails_projects/simple_project/script/about +4 -0
- data/testdata/rails_projects/simple_project/script/console +3 -0
- data/testdata/rails_projects/simple_project/script/dbconsole +3 -0
- data/testdata/rails_projects/simple_project/script/destroy +3 -0
- data/testdata/rails_projects/simple_project/script/generate +3 -0
- data/testdata/rails_projects/simple_project/script/performance/benchmarker +3 -0
- data/testdata/rails_projects/simple_project/script/performance/profiler +3 -0
- data/testdata/rails_projects/simple_project/script/performance/request +3 -0
- data/testdata/rails_projects/simple_project/script/plugin +3 -0
- data/testdata/rails_projects/simple_project/script/process/inspector +3 -0
- data/testdata/rails_projects/simple_project/script/process/reaper +3 -0
- data/testdata/rails_projects/simple_project/script/process/spawner +3 -0
- data/testdata/rails_projects/simple_project/script/runner +3 -0
- data/testdata/rails_projects/simple_project/script/server +3 -0
- data/testdata/rails_projects/simple_project/test/fixtures/products.yml +9 -0
- data/testdata/rails_projects/simple_project/test/functional/products_controller_test.rb +11 -0
- data/testdata/rails_projects/simple_project/test/test_helper.rb +38 -0
- data/testdata/rails_projects/simple_project/test/unit/product_test.rb +27 -0
- data/testdata/raketasks/Rakefile +1 -1
- metadata +90 -5
- data/testdata/verify_dir_pwd/Rakefile +0 -6
- data/testdata/verify_dir_pwd/verify_dir_pwd_test_case.rb +0 -10
data/lib/dtr/master.rb
CHANGED
@@ -24,7 +24,9 @@ module DTR
|
|
24
24
|
DTR.info {""}
|
25
25
|
DTR.info {"--------------------beautiful line--------------------------"}
|
26
26
|
DTR.info {"Master process started at #{Time.now}"}
|
27
|
+
DTR.info {"Master heartbeat interval: #{DTR.configuration.master_heartbeat_interval}"}
|
27
28
|
|
29
|
+
DTR.root = Dir.pwd
|
28
30
|
DTR.configuration.with_rinda_server do
|
29
31
|
provide_working_env WorkingEnv.new
|
30
32
|
with_wakeup_agents(&block)
|
data/lib/dtr/monitor.rb
CHANGED
@@ -23,7 +23,7 @@ module DTR
|
|
23
23
|
include Adapter::Master
|
24
24
|
|
25
25
|
def start
|
26
|
-
|
26
|
+
Process.fork do
|
27
27
|
monitor
|
28
28
|
end
|
29
29
|
end
|
@@ -44,7 +44,7 @@ module DTR
|
|
44
44
|
include Service::Agent
|
45
45
|
|
46
46
|
def start
|
47
|
-
|
47
|
+
Process.fork do
|
48
48
|
begin
|
49
49
|
loop do
|
50
50
|
monitor
|
data/lib/dtr/raketasks.rb
CHANGED
@@ -18,6 +18,7 @@ require 'rake/testtask'
|
|
18
18
|
require 'rake/tasklib'
|
19
19
|
|
20
20
|
require 'dtr'
|
21
|
+
require 'dtr/shared/root'
|
21
22
|
require 'dtr/shared/ruby_ext'
|
22
23
|
require 'dtr/shared/utils'
|
23
24
|
require 'dtr/shared/sync_codebase/package'
|
@@ -85,23 +86,17 @@ module DTR
|
|
85
86
|
|
86
87
|
desc "Run tests with DTR injected"
|
87
88
|
task @name do
|
88
|
-
|
89
|
+
start_agent
|
89
90
|
run_code = ''
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
" #{option_list}"
|
100
|
-
end
|
101
|
-
ensure
|
102
|
-
if defined?(@agent)
|
103
|
-
DTR.kill_process @agent
|
104
|
-
end
|
91
|
+
RakeFileUtils.verbose(@verbose) do
|
92
|
+
run_code = rake_loader
|
93
|
+
@ruby_opts.unshift( "-I#{lib_path}" )
|
94
|
+
@ruby_opts.unshift( "-w" ) if @warning
|
95
|
+
|
96
|
+
ruby @ruby_opts.join(" ") +
|
97
|
+
" \"#{run_code}\" " +
|
98
|
+
file_list.unshift('dtr/test_unit_injection.rb').collect { |fn| "\"#{fn}\"" }.join(' ') +
|
99
|
+
" #{option_list}"
|
105
100
|
end
|
106
101
|
end
|
107
102
|
self
|
@@ -113,9 +108,9 @@ module DTR
|
|
113
108
|
runner_names = []
|
114
109
|
self.processes.to_i.times {|i| runner_names << "runner#{i}"}
|
115
110
|
|
116
|
-
DTR.
|
117
|
-
|
118
|
-
DTR.
|
111
|
+
DTR.agent_runners = runner_names if DTR.agent_runners.blank?
|
112
|
+
Thread.start do
|
113
|
+
DTR.run_script('DTR::Agent.start(:hypnotize_once)')
|
119
114
|
end
|
120
115
|
end
|
121
116
|
end
|
data/lib/dtr/shared.rb
CHANGED
data/lib/dtr/shared/adapter.rb
CHANGED
@@ -12,104 +12,5 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require '
|
16
|
-
|
17
|
-
module DTR
|
18
|
-
module Adapter
|
19
|
-
WAKEUP_MESSAGE = 'wakeup'
|
20
|
-
SLEEP_MESSAGE = 'sleep'
|
21
|
-
|
22
|
-
module Follower
|
23
|
-
def wakeup?
|
24
|
-
msg, host, group = listen
|
25
|
-
if group == DTR.configuration.group && msg == Adapter::WAKEUP_MESSAGE
|
26
|
-
ip, port = host.split(':')
|
27
|
-
DTR.configuration.rinda_server_port = port.to_i
|
28
|
-
DTR.configuration.broadcast_list = [ip]
|
29
|
-
@wakeup_for_host = host
|
30
|
-
true
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def sleep?
|
35
|
-
return true unless defined?(@wakeup_for_host)
|
36
|
-
Timeout.timeout(DTR.configuration.follower_listen_heartbeat_timeout) do
|
37
|
-
until (msg, host = listen) && host == @wakeup_for_host; end
|
38
|
-
msg == Adapter::SLEEP_MESSAGE
|
39
|
-
end
|
40
|
-
rescue Timeout::Error => e
|
41
|
-
DTR.info {"Timeout while listening command"}
|
42
|
-
true
|
43
|
-
end
|
44
|
-
|
45
|
-
def relax
|
46
|
-
if defined?(@soc) && @soc
|
47
|
-
@soc.close rescue nil
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
def listen
|
53
|
-
unless defined?(@soc)
|
54
|
-
@soc = UDPSocket.open
|
55
|
-
@soc.bind('', DTR.configuration.agent_listen_port)
|
56
|
-
DTR.info("DTR Agent is listening on port #{DTR.configuration.agent_listen_port}")
|
57
|
-
end
|
58
|
-
message, client_address = @soc.recvfrom(400)
|
59
|
-
cmd, port, group = message.split
|
60
|
-
|
61
|
-
hostname = client_address[2]
|
62
|
-
host_ip = client_address[3]
|
63
|
-
DTR.info {"Received: #{cmd} for group #{group} from #{hostname}(#{host_ip}):#{port}"}
|
64
|
-
[cmd, "#{host_ip}:#{port}", group]
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
module Master
|
69
|
-
def hypnotize_agents
|
70
|
-
yell_agents("#{Adapter::SLEEP_MESSAGE} #{DTR.configuration.rinda_server_port}")
|
71
|
-
end
|
72
|
-
|
73
|
-
def with_wakeup_agents(&block)
|
74
|
-
heartbeat = Thread.new do
|
75
|
-
loop do
|
76
|
-
do_wakeup_agents
|
77
|
-
sleep(DTR.configuration.master_heartbeat_interval)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
#heartbeat thread should have high priority for agent is listening
|
81
|
-
heartbeat.priority = Thread.current.priority + 10
|
82
|
-
block.call
|
83
|
-
ensure
|
84
|
-
#kill heartbeat first, so that agents wouldn't be wakeup after hypnotized
|
85
|
-
Thread.kill heartbeat rescue nil
|
86
|
-
hypnotize_agents rescue nil
|
87
|
-
end
|
88
|
-
|
89
|
-
def do_wakeup_agents
|
90
|
-
yell_agents("#{Adapter::WAKEUP_MESSAGE} #{DTR.configuration.rinda_server_port} #{DTR.configuration.group}")
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
def yell_agents(msg)
|
95
|
-
DTR.info {"yell agents #{msg}: #{DTR.configuration.broadcast_list.inspect}"}
|
96
|
-
DTR.configuration.broadcast_list.each do |it|
|
97
|
-
broadcast(it, msg)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def broadcast(it, msg)
|
102
|
-
soc = UDPSocket.open
|
103
|
-
begin
|
104
|
-
soc.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
|
105
|
-
DTR.debug {"broadcast sending #{msg} to #{it}"}
|
106
|
-
soc.send(msg, 0, it, DTR.configuration.agent_listen_port)
|
107
|
-
rescue
|
108
|
-
nil
|
109
|
-
ensure
|
110
|
-
soc.close
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
15
|
+
require 'dtr/shared/adapter/base'
|
16
|
+
require 'dtr/shared/adapter/mortality'
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# Copyright (c) 2007-2008 Li Xiao <iam@li-xiao.com>
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'timeout'
|
16
|
+
|
17
|
+
module DTR
|
18
|
+
module Adapter
|
19
|
+
WAKEUP_MESSAGE = 'wakeup'
|
20
|
+
SLEEP_MESSAGE = 'sleep'
|
21
|
+
|
22
|
+
module Follower
|
23
|
+
def wakeup?
|
24
|
+
msg, host, group = listen
|
25
|
+
if group == DTR.configuration.group && msg == Adapter::WAKEUP_MESSAGE
|
26
|
+
ip, port = host.split(':')
|
27
|
+
DTR.configuration.rinda_server_port = port.to_i
|
28
|
+
DTR.configuration.broadcast_list = [ip]
|
29
|
+
DTR.configuration.save
|
30
|
+
DTR.info {"=> Rinda server port: #{DTR.configuration.rinda_server_port}"}
|
31
|
+
DTR.info {"=> Broadcast list: #{DTR.configuration.broadcast_list.inspect}"}
|
32
|
+
@wakeup_for_host = host
|
33
|
+
true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def sleep?
|
38
|
+
return true unless defined?(@wakeup_for_host)
|
39
|
+
Timeout.timeout(DTR.configuration.follower_listen_heartbeat_timeout) do
|
40
|
+
until (msg, host = listen) && host == @wakeup_for_host; end
|
41
|
+
msg == Adapter::SLEEP_MESSAGE
|
42
|
+
end
|
43
|
+
rescue Timeout::Error => e
|
44
|
+
DTR.info {"Timeout while listening command"}
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
def relax
|
49
|
+
if defined?(@soc) && @soc
|
50
|
+
@soc.close rescue nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def listen
|
56
|
+
unless defined?(@soc)
|
57
|
+
@soc = UDPSocket.open
|
58
|
+
@soc.bind('', DTR.configuration.agent_listen_port)
|
59
|
+
DTR.info("DTR Agent is listening on port #{DTR.configuration.agent_listen_port}")
|
60
|
+
end
|
61
|
+
message, client_address = @soc.recvfrom(400)
|
62
|
+
cmd, port, group = message.split
|
63
|
+
|
64
|
+
hostname = client_address[2]
|
65
|
+
host_ip = client_address[3]
|
66
|
+
DTR.info {"Received: #{cmd} for group #{group} from #{hostname}(#{host_ip}):#{port}"}
|
67
|
+
[cmd, "#{host_ip}:#{port}", group]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
module Master
|
72
|
+
def hypnotize_agents
|
73
|
+
yell_agents("#{Adapter::SLEEP_MESSAGE} #{DTR.configuration.rinda_server_port}")
|
74
|
+
end
|
75
|
+
|
76
|
+
def with_wakeup_agents(&block)
|
77
|
+
heartbeat = Thread.new do
|
78
|
+
loop do
|
79
|
+
do_wakeup_agents
|
80
|
+
sleep(DTR.configuration.master_heartbeat_interval)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
#heartbeat thread should have high priority for agent is listening
|
84
|
+
heartbeat.priority = Thread.current.priority + 10
|
85
|
+
block.call
|
86
|
+
ensure
|
87
|
+
#kill heartbeat first, so that agents wouldn't be wakeup after hypnotized
|
88
|
+
Thread.kill heartbeat rescue nil
|
89
|
+
hypnotize_agents rescue nil
|
90
|
+
end
|
91
|
+
|
92
|
+
def do_wakeup_agents
|
93
|
+
yell_agents("#{Adapter::WAKEUP_MESSAGE} #{DTR.configuration.rinda_server_port} #{DTR.configuration.group}")
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
def yell_agents(msg)
|
98
|
+
DTR.info {"yell agents #{msg}: #{DTR.configuration.broadcast_list.inspect}"}
|
99
|
+
DTR.configuration.broadcast_list.each do |it|
|
100
|
+
broadcast(it, msg)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def broadcast(it, msg)
|
105
|
+
soc = UDPSocket.open
|
106
|
+
begin
|
107
|
+
soc.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
|
108
|
+
DTR.debug {"broadcast sending #{msg} to #{it}"}
|
109
|
+
soc.send(msg, 0, it, DTR.configuration.agent_listen_port)
|
110
|
+
rescue
|
111
|
+
nil
|
112
|
+
ensure
|
113
|
+
soc.close
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Copyright (c) 2007-2008 Li Xiao <iam@li-xiao.com>
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'timeout'
|
16
|
+
|
17
|
+
module DTR
|
18
|
+
module Adapter
|
19
|
+
DEAD_MESSAGE = 'die'
|
20
|
+
|
21
|
+
module Follower
|
22
|
+
private
|
23
|
+
|
24
|
+
def listen_with_dead_message
|
25
|
+
cmd, host, group = listen_without_dead_message
|
26
|
+
if cmd == Adapter::DEAD_MESSAGE && group == DTR.configuration.group
|
27
|
+
DTR.info{"Master need me die. So I am dieing."}
|
28
|
+
raise Interrupt, "Master need me die."
|
29
|
+
end
|
30
|
+
[cmd, host, group]
|
31
|
+
end
|
32
|
+
alias_method_chain :listen, :dead_message
|
33
|
+
end
|
34
|
+
|
35
|
+
module Master
|
36
|
+
def group_agents_should_die(group = DTR.configuration.group)
|
37
|
+
yell_agents("#{Adapter::DEAD_MESSAGE} #{DTR.configuration.rinda_server_port} #{group}")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -41,32 +41,50 @@ module DTR
|
|
41
41
|
include Singleton
|
42
42
|
include Service::Rinda
|
43
43
|
|
44
|
-
attr_accessor :broadcast_list, :rinda_server_port, :agent_listen_port, :master_heartbeat_interval, :follower_listen_heartbeat_timeout
|
44
|
+
attr_accessor :broadcast_list, :rinda_server_port, :agent_listen_port, :master_heartbeat_interval, :follower_listen_heartbeat_timeout, :agent_env_setup_cmd, :agent_runners
|
45
45
|
attr_reader :group
|
46
46
|
|
47
47
|
def initialize
|
48
|
+
@store = EnvStore.new
|
49
|
+
load
|
50
|
+
end
|
51
|
+
|
52
|
+
def refresh
|
53
|
+
@store.destroy if @store
|
54
|
+
@store = EnvStore.new
|
48
55
|
load
|
49
56
|
end
|
50
57
|
|
51
58
|
def load
|
52
|
-
store = EnvStore.new
|
53
59
|
# always have 'localhost' in broadcast_list, for our master process would start rinda server locally,
|
54
60
|
# and dtr should work well on local machine when the machine leaves dtr grid network environment.
|
55
|
-
@broadcast_list = ['localhost'].concat(store[:broadcast_list] || []).uniq
|
56
|
-
@rinda_server_port = 3344
|
57
|
-
@agent_listen_port = store[:agent_listen_port] || 7788
|
58
|
-
@master_heartbeat_interval = store[:master_heartbeat_interval] || 10
|
59
|
-
@follower_listen_heartbeat_timeout = store[:follower_listen_heartbeat_timeout] || 15
|
60
|
-
@group = store[:group]
|
61
|
+
@broadcast_list = ['localhost'].concat(@store[:broadcast_list] || []).uniq
|
62
|
+
@rinda_server_port = @store[:rinda_server_port] || 3344
|
63
|
+
@agent_listen_port = @store[:agent_listen_port] || 7788
|
64
|
+
@master_heartbeat_interval = @store[:master_heartbeat_interval] || 10
|
65
|
+
@follower_listen_heartbeat_timeout = @store[:follower_listen_heartbeat_timeout] || 15
|
66
|
+
@group = @store[:group]
|
67
|
+
@agent_env_setup_cmd = @store[:agent_env_setup_cmd]
|
68
|
+
@agent_runners = @store[:agent_runners]
|
61
69
|
end
|
62
70
|
|
63
71
|
def save
|
64
|
-
store =
|
65
|
-
store[:
|
66
|
-
store[:agent_listen_port] = @agent_listen_port
|
67
|
-
store[:master_heartbeat_interval] = @master_heartbeat_interval
|
68
|
-
store[:follower_listen_heartbeat_timeout] = @follower_listen_heartbeat_timeout
|
69
|
-
store[:group] = @group
|
72
|
+
@store[:broadcast_list] = @broadcast_list
|
73
|
+
@store[:rinda_server_port] = @rinda_server_port
|
74
|
+
@store[:agent_listen_port] = @agent_listen_port
|
75
|
+
@store[:master_heartbeat_interval] = @master_heartbeat_interval
|
76
|
+
@store[:follower_listen_heartbeat_timeout] = @follower_listen_heartbeat_timeout
|
77
|
+
@store[:group] = @group
|
78
|
+
@store[:agent_env_setup_cmd] = @agent_env_setup_cmd
|
79
|
+
@store[:agent_runners] = @agent_runners
|
80
|
+
end
|
81
|
+
|
82
|
+
def working_env
|
83
|
+
@store[:working_env]
|
84
|
+
end
|
85
|
+
|
86
|
+
def working_env=(env)
|
87
|
+
@store[:working_env] = env
|
70
88
|
end
|
71
89
|
|
72
90
|
def group=(group)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Copyright (c) 2007-2008 Li Xiao <iam@li-xiao.com>
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module DTR
|
16
|
+
module Root
|
17
|
+
attr_accessor :root
|
18
|
+
end
|
19
|
+
extend Root
|
20
|
+
end
|
@@ -26,12 +26,12 @@ module DTR
|
|
26
26
|
def with_dtr_master_with_sync_codebase(&block)
|
27
27
|
with_dtr_master_without_sync_codebase do
|
28
28
|
DTR.do_println("Packaging codebase")
|
29
|
-
raise 'Packaging for dtr task failed, see log for details!' unless Cmd.execute('rake
|
29
|
+
raise 'Packaging for dtr task failed, see log for details!' unless Cmd.execute('rake --trace dtr_repackage')
|
30
30
|
begin
|
31
31
|
provide_file CopiablePackage.new
|
32
32
|
block.call
|
33
33
|
ensure
|
34
|
-
Cmd.execute('rake
|
34
|
+
Cmd.execute('rake --trace dtr_clobber_package')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|