xpflow 0.1b
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/xpflow +96 -0
- data/lib/colorado.rb +198 -0
- data/lib/json/add/core.rb +243 -0
- data/lib/json/add/rails.rb +8 -0
- data/lib/json/common.rb +423 -0
- data/lib/json/editor.rb +1369 -0
- data/lib/json/ext.rb +28 -0
- data/lib/json/pure/generator.rb +442 -0
- data/lib/json/pure/parser.rb +320 -0
- data/lib/json/pure.rb +15 -0
- data/lib/json/version.rb +8 -0
- data/lib/json.rb +62 -0
- data/lib/mime/types.rb +881 -0
- data/lib/mime-types.rb +3 -0
- data/lib/restclient/abstract_response.rb +106 -0
- data/lib/restclient/exceptions.rb +193 -0
- data/lib/restclient/net_http_ext.rb +55 -0
- data/lib/restclient/payload.rb +235 -0
- data/lib/restclient/raw_response.rb +34 -0
- data/lib/restclient/request.rb +316 -0
- data/lib/restclient/resource.rb +169 -0
- data/lib/restclient/response.rb +24 -0
- data/lib/restclient.rb +174 -0
- data/lib/xpflow/bash.rb +341 -0
- data/lib/xpflow/bundle.rb +113 -0
- data/lib/xpflow/cmdline.rb +249 -0
- data/lib/xpflow/collection.rb +122 -0
- data/lib/xpflow/concurrency.rb +79 -0
- data/lib/xpflow/data.rb +393 -0
- data/lib/xpflow/dsl.rb +816 -0
- data/lib/xpflow/engine.rb +574 -0
- data/lib/xpflow/ensemble.rb +135 -0
- data/lib/xpflow/events.rb +56 -0
- data/lib/xpflow/experiment.rb +65 -0
- data/lib/xpflow/exts/facter.rb +30 -0
- data/lib/xpflow/exts/g5k.rb +931 -0
- data/lib/xpflow/exts/g5k_use.rb +50 -0
- data/lib/xpflow/exts/gui.rb +140 -0
- data/lib/xpflow/exts/model.rb +155 -0
- data/lib/xpflow/graph.rb +1603 -0
- data/lib/xpflow/graph_xpflow.rb +251 -0
- data/lib/xpflow/import.rb +196 -0
- data/lib/xpflow/library.rb +349 -0
- data/lib/xpflow/logging.rb +153 -0
- data/lib/xpflow/manager.rb +147 -0
- data/lib/xpflow/nodes.rb +1250 -0
- data/lib/xpflow/runs.rb +773 -0
- data/lib/xpflow/runtime.rb +125 -0
- data/lib/xpflow/scope.rb +168 -0
- data/lib/xpflow/ssh.rb +186 -0
- data/lib/xpflow/stat.rb +50 -0
- data/lib/xpflow/stdlib.rb +381 -0
- data/lib/xpflow/structs.rb +369 -0
- data/lib/xpflow/taktuk.rb +193 -0
- data/lib/xpflow/templates/ssh-config.basic +14 -0
- data/lib/xpflow/templates/ssh-config.inria +18 -0
- data/lib/xpflow/templates/ssh-config.proxy +13 -0
- data/lib/xpflow/templates/taktuk +6590 -0
- data/lib/xpflow/templates/utils/batch +4 -0
- data/lib/xpflow/templates/utils/bootstrap +12 -0
- data/lib/xpflow/templates/utils/hostname +3 -0
- data/lib/xpflow/templates/utils/ping +3 -0
- data/lib/xpflow/templates/utils/rsync +12 -0
- data/lib/xpflow/templates/utils/scp +17 -0
- data/lib/xpflow/templates/utils/scp_many +8 -0
- data/lib/xpflow/templates/utils/ssh +3 -0
- data/lib/xpflow/templates/utils/ssh-interactive +4 -0
- data/lib/xpflow/templates/utils/taktuk +19 -0
- data/lib/xpflow/threads.rb +187 -0
- data/lib/xpflow/utils.rb +569 -0
- data/lib/xpflow/visual.rb +230 -0
- data/lib/xpflow/with_g5k.rb +7 -0
- data/lib/xpflow.rb +349 -0
- metadata +135 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/bin/bash -eu
|
2
|
+
|
3
|
+
if [ $# -ne 2 ]; then
|
4
|
+
echo "Give src dir and dst dir."
|
5
|
+
exit 1
|
6
|
+
fi
|
7
|
+
|
8
|
+
src="$1"
|
9
|
+
dst="$2"
|
10
|
+
|
11
|
+
switch=""
|
12
|
+
|
13
|
+
if [ -d "$src" ]; then
|
14
|
+
switch="-r"
|
15
|
+
fi
|
16
|
+
|
17
|
+
exec scp -F <%= path %>/ssh-config ${switch} ${src} this:${dst}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/bin/bash -eu
|
2
|
+
#
|
3
|
+
# this assumes that taktuk is installed on nodes
|
4
|
+
|
5
|
+
if [ $# -eq 0 ]; then
|
6
|
+
echo "No file given."
|
7
|
+
exit 1
|
8
|
+
fi
|
9
|
+
|
10
|
+
list_local=${1}
|
11
|
+
shift
|
12
|
+
|
13
|
+
tmpdir=$(<%= path %>/ssh mktemp -d)
|
14
|
+
list_remote=${tmpdir}/hostfile
|
15
|
+
|
16
|
+
# <%= path %>/batch 3 # pipe connection for 3 seconds
|
17
|
+
<%= path %>/scp ${list_local} ${list_remote}
|
18
|
+
<%= path %>/ssh taktuk -f ${list_remote} "$@"
|
19
|
+
# <%= path %>/ssh rm -rf ${tmpdir}
|
@@ -0,0 +1,187 @@
|
|
1
|
+
|
2
|
+
require 'thread'
|
3
|
+
|
4
|
+
module XPFlow
|
5
|
+
|
6
|
+
$xpflow_global_mutex = Mutex.new
|
7
|
+
|
8
|
+
def self.global_synchronize(&block)
|
9
|
+
return $xpflow_global_mutex.synchronize(&block)
|
10
|
+
end
|
11
|
+
|
12
|
+
$xpflow_global_counters = {}
|
13
|
+
|
14
|
+
def self.global_counter(label = :global)
|
15
|
+
value = global_synchronize do
|
16
|
+
h = $xpflow_global_counters
|
17
|
+
if h.key?(label)
|
18
|
+
h[label] += 1
|
19
|
+
else
|
20
|
+
h[label] = 0
|
21
|
+
end
|
22
|
+
h[label]
|
23
|
+
end
|
24
|
+
return value
|
25
|
+
end
|
26
|
+
|
27
|
+
# Implements a pool of threads.
|
28
|
+
# The threads can execute blocks of code
|
29
|
+
|
30
|
+
class ThreadPool
|
31
|
+
|
32
|
+
def initialize(size)
|
33
|
+
@size = size
|
34
|
+
@queue = Queue.new
|
35
|
+
@threads = size.times.map do
|
36
|
+
Thread.new do
|
37
|
+
worker
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def worker
|
43
|
+
while true
|
44
|
+
el = @queue.pop
|
45
|
+
break if el.nil?
|
46
|
+
block, args = el
|
47
|
+
block.call(*args)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def execute(*args, &block)
|
52
|
+
@queue.push([ block, args ])
|
53
|
+
end
|
54
|
+
|
55
|
+
def join(yes_or_no = true)
|
56
|
+
@size.times { @queue.push(nil) }
|
57
|
+
@threads.each { |t| t.join } if yes_or_no
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class OrderedArray
|
62
|
+
|
63
|
+
def initialize
|
64
|
+
@queue = []
|
65
|
+
@lock = Mutex.new
|
66
|
+
@cond = ConditionVariable.new
|
67
|
+
end
|
68
|
+
|
69
|
+
def give(i, x)
|
70
|
+
@lock.synchronize do
|
71
|
+
@queue.push([i, x])
|
72
|
+
@cond.broadcast
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def take(n)
|
77
|
+
@lock.synchronize do
|
78
|
+
while @queue.length < n
|
79
|
+
@cond.wait(@lock)
|
80
|
+
end
|
81
|
+
arr = @queue.sort { |x, y| x.first <=> y.first }.map { |i, x| x }
|
82
|
+
arr
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
# Let's one thread wait for a value
|
89
|
+
# Do not call 'take' multiple times.
|
90
|
+
|
91
|
+
class Meeting
|
92
|
+
|
93
|
+
def initialize(run)
|
94
|
+
@lock = Mutex.new
|
95
|
+
@cond = ConditionVariable.new
|
96
|
+
@queue = []
|
97
|
+
@run = run
|
98
|
+
end
|
99
|
+
|
100
|
+
def give(x)
|
101
|
+
@lock.synchronize do
|
102
|
+
@queue.push(x)
|
103
|
+
@cond.broadcast
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def _take(n)
|
108
|
+
flatten = (n < 0)
|
109
|
+
n = n.abs
|
110
|
+
@lock.synchronize do
|
111
|
+
while @queue.length < n
|
112
|
+
@cond.wait(@lock)
|
113
|
+
end
|
114
|
+
arr = @queue.shift(n)
|
115
|
+
arr = arr.first if flatten
|
116
|
+
arr
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def take(n)
|
121
|
+
begin
|
122
|
+
return _take(n)
|
123
|
+
rescue Interrupt => e
|
124
|
+
raise RunMsgError.new(@run, "Thread rendez-vous has been interrupted.")
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
# Collects exceptions (using 'push' method)
|
131
|
+
# and rethrows them collectively as RunError.
|
132
|
+
|
133
|
+
class ExceptionBag
|
134
|
+
|
135
|
+
def initialize
|
136
|
+
@lock = Mutex.new
|
137
|
+
@bag = []
|
138
|
+
end
|
139
|
+
|
140
|
+
def push(x)
|
141
|
+
@lock.synchronize do
|
142
|
+
@bag.push(x)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def raise_if_needed(run)
|
147
|
+
@lock.synchronize do
|
148
|
+
copy = @bag.map.to_a
|
149
|
+
raise RunError.new(run, copy) if copy.length > 0
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
class Threads
|
156
|
+
|
157
|
+
def self.defaults
|
158
|
+
return { :join => true }
|
159
|
+
end
|
160
|
+
|
161
|
+
def self.merge_opts(x, y)
|
162
|
+
return x.merge(y) { |k, old, new|
|
163
|
+
(new.nil? ? old : new)
|
164
|
+
}
|
165
|
+
end
|
166
|
+
|
167
|
+
def self.run(run, list, opts = {}, &block)
|
168
|
+
opts = merge_opts(defaults(), opts)
|
169
|
+
bag = ExceptionBag.new
|
170
|
+
size = [ list.length, opts[:pool] ].min
|
171
|
+
pool = ThreadPool.new(size)
|
172
|
+
list.each_with_index do |el, i|
|
173
|
+
pool.execute(el, i) do |x, it|
|
174
|
+
begin
|
175
|
+
block.call(x, it)
|
176
|
+
rescue RunError => e
|
177
|
+
bag.push(e)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
pool.join(opts[:join])
|
182
|
+
bag.raise_if_needed(run)
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|