fairy 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +674 -0
- data/Makefile +116 -0
- data/README +15 -0
- data/bin/fairy +582 -0
- data/bin/fairy-cat +74 -0
- data/bin/fairy-cp +128 -0
- data/bin/fairy-rm +122 -0
- data/bin/subcmd/controller +41 -0
- data/bin/subcmd/inspector +81 -0
- data/bin/subcmd/master +43 -0
- data/bin/subcmd/node +47 -0
- data/bin/subcmd/processor +54 -0
- data/doc/programming-interface.html +240 -0
- data/doc/programming-interface.rd +300 -0
- data/etc/fairy.conf.tmpl +118 -0
- data/ext/simple_hash/extconf.rb +4 -0
- data/ext/simple_hash/simple_hash.c +42 -0
- data/fairy.gemspec +60 -0
- data/lib/fairy/client/addins.rb +20 -0
- data/lib/fairy/client/barrier.rb +29 -0
- data/lib/fairy/client/basic-group-by.rb +52 -0
- data/lib/fairy/client/cat.rb +41 -0
- data/lib/fairy/client/direct-product.rb +51 -0
- data/lib/fairy/client/equijoin.rb +79 -0
- data/lib/fairy/client/exec.rb +54 -0
- data/lib/fairy/client/filter.rb +62 -0
- data/lib/fairy/client/find.rb +35 -0
- data/lib/fairy/client/group-by.rb +194 -0
- data/lib/fairy/client/here.rb +84 -0
- data/lib/fairy/client/inject.rb +70 -0
- data/lib/fairy/client/input-file.rb +53 -0
- data/lib/fairy/client/input-iota.rb +49 -0
- data/lib/fairy/client/input-local-file.rb +188 -0
- data/lib/fairy/client/input-varray.rb +30 -0
- data/lib/fairy/client/input.rb +42 -0
- data/lib/fairy/client/io-filter.rb +26 -0
- data/lib/fairy/client/junction.rb +31 -0
- data/lib/fairy/client/map.rb +34 -0
- data/lib/fairy/client/merge-group-by.rb +71 -0
- data/lib/fairy/client/output-file.rb +64 -0
- data/lib/fairy/client/output-local-file.rb +60 -0
- data/lib/fairy/client/output-null.rb +47 -0
- data/lib/fairy/client/output-varray.rb +50 -0
- data/lib/fairy/client/output.rb +29 -0
- data/lib/fairy/client/roma-put.rb +62 -0
- data/lib/fairy/client/roma.rb +156 -0
- data/lib/fairy/client/seg-join.rb +61 -0
- data/lib/fairy/client/seg-map.rb +78 -0
- data/lib/fairy/client/seg-shuffle.rb +35 -0
- data/lib/fairy/client/seg-split.rb +27 -0
- data/lib/fairy/client/seg-zip.rb +60 -0
- data/lib/fairy/client/select.rb +38 -0
- data/lib/fairy/client/sort.rb +48 -0
- data/lib/fairy/client/sort18.rb +56 -0
- data/lib/fairy/client/sort19.rb +61 -0
- data/lib/fairy/client/there.rb +47 -0
- data/lib/fairy/client/top_n_into_roma.rb +34 -0
- data/lib/fairy/client/wc.rb +92 -0
- data/lib/fairy/controller.rb +1103 -0
- data/lib/fairy/logger.rb +107 -0
- data/lib/fairy/master/addins.rb +20 -0
- data/lib/fairy/master/atom.rb +17 -0
- data/lib/fairy/master/c-barrier.rb +283 -0
- data/lib/fairy/master/c-basic-group-by.rb +250 -0
- data/lib/fairy/master/c-cat.rb +159 -0
- data/lib/fairy/master/c-direct-product.rb +203 -0
- data/lib/fairy/master/c-exec.rb +68 -0
- data/lib/fairy/master/c-filter.rb +422 -0
- data/lib/fairy/master/c-find.rb +138 -0
- data/lib/fairy/master/c-group-by.rb +64 -0
- data/lib/fairy/master/c-here.rb +80 -0
- data/lib/fairy/master/c-inject.rb +119 -0
- data/lib/fairy/master/c-input-file.rb +46 -0
- data/lib/fairy/master/c-input-iota.rb +66 -0
- data/lib/fairy/master/c-input-local-file.rb +117 -0
- data/lib/fairy/master/c-input-varray.rb +53 -0
- data/lib/fairy/master/c-input.rb +24 -0
- data/lib/fairy/master/c-inputtable.rb +31 -0
- data/lib/fairy/master/c-inputtable18.rb +36 -0
- data/lib/fairy/master/c-inputtable19.rb +35 -0
- data/lib/fairy/master/c-io-filter.rb +28 -0
- data/lib/fairy/master/c-junction.rb +54 -0
- data/lib/fairy/master/c-map.rb +27 -0
- data/lib/fairy/master/c-merge-group-by.rb +241 -0
- data/lib/fairy/master/c-output-file.rb +84 -0
- data/lib/fairy/master/c-output-local-file.rb +19 -0
- data/lib/fairy/master/c-output-null.rb +45 -0
- data/lib/fairy/master/c-output-varray.rb +57 -0
- data/lib/fairy/master/c-output.rb +20 -0
- data/lib/fairy/master/c-seg-join.rb +141 -0
- data/lib/fairy/master/c-seg-map.rb +26 -0
- data/lib/fairy/master/c-seg-shuffle.rb +87 -0
- data/lib/fairy/master/c-seg-split.rb +110 -0
- data/lib/fairy/master/c-seg-zip.rb +132 -0
- data/lib/fairy/master/c-select.rb +27 -0
- data/lib/fairy/master/c-sort.rb +108 -0
- data/lib/fairy/master/c-there.rb +57 -0
- data/lib/fairy/master/c-wc.rb +232 -0
- data/lib/fairy/master/job-interpriter.rb +19 -0
- data/lib/fairy/master/scheduler.rb +24 -0
- data/lib/fairy/master.rb +329 -0
- data/lib/fairy/node/addins.rb +19 -0
- data/lib/fairy/node/p-barrier.rb +95 -0
- data/lib/fairy/node/p-basic-group-by.rb +252 -0
- data/lib/fairy/node/p-direct-product.rb +153 -0
- data/lib/fairy/node/p-exec.rb +30 -0
- data/lib/fairy/node/p-filter.rb +363 -0
- data/lib/fairy/node/p-find.rb +111 -0
- data/lib/fairy/node/p-group-by.rb +1534 -0
- data/lib/fairy/node/p-here.rb +21 -0
- data/lib/fairy/node/p-identity.rb +24 -0
- data/lib/fairy/node/p-inject.rb +127 -0
- data/lib/fairy/node/p-input-file.rb +108 -0
- data/lib/fairy/node/p-input-iota.rb +39 -0
- data/lib/fairy/node/p-input-local-file.rb +61 -0
- data/lib/fairy/node/p-input-varray.rb +26 -0
- data/lib/fairy/node/p-io-filter.rb +28 -0
- data/lib/fairy/node/p-map.rb +40 -0
- data/lib/fairy/node/p-merger-group-by.rb +48 -0
- data/lib/fairy/node/p-output-file.rb +104 -0
- data/lib/fairy/node/p-output-local-file.rb +14 -0
- data/lib/fairy/node/p-output-null.rb +32 -0
- data/lib/fairy/node/p-output-varray.rb +41 -0
- data/lib/fairy/node/p-seg-join.rb +82 -0
- data/lib/fairy/node/p-seg-map.rb +34 -0
- data/lib/fairy/node/p-seg-split.rb +61 -0
- data/lib/fairy/node/p-seg-zip.rb +79 -0
- data/lib/fairy/node/p-select.rb +40 -0
- data/lib/fairy/node/p-single-exportable.rb +90 -0
- data/lib/fairy/node/p-sort.rb +195 -0
- data/lib/fairy/node/p-task.rb +113 -0
- data/lib/fairy/node/p-there.rb +44 -0
- data/lib/fairy/node/p-wc.rb +266 -0
- data/lib/fairy/node.rb +187 -0
- data/lib/fairy/processor.rb +510 -0
- data/lib/fairy/share/base-app.rb +114 -0
- data/lib/fairy/share/block-source.rb +234 -0
- data/lib/fairy/share/conf.rb +396 -0
- data/lib/fairy/share/debug.rb +21 -0
- data/lib/fairy/share/encoding.rb +17 -0
- data/lib/fairy/share/fast-tempfile.rb +93 -0
- data/lib/fairy/share/file-place.rb +176 -0
- data/lib/fairy/share/hash-1.rb +20 -0
- data/lib/fairy/share/hash-md5.rb +28 -0
- data/lib/fairy/share/hash-murmur.rb +69 -0
- data/lib/fairy/share/hash-rb18.rb +20 -0
- data/lib/fairy/share/hash-simple-hash.rb +28 -0
- data/lib/fairy/share/inspector.rb +16 -0
- data/lib/fairy/share/lc/exceptions.rb +82 -0
- data/lib/fairy/share/lc/ja/exceptions.rb +81 -0
- data/lib/fairy/share/locale.rb +17 -0
- data/lib/fairy/share/log.rb +215 -0
- data/lib/fairy/share/pool-dictionary.rb +53 -0
- data/lib/fairy/share/port-marshaled-queue.rb +347 -0
- data/lib/fairy/share/port.rb +1697 -0
- data/lib/fairy/share/reference.rb +45 -0
- data/lib/fairy/share/stdout.rb +56 -0
- data/lib/fairy/share/tr.rb +16 -0
- data/lib/fairy/share/varray.rb +147 -0
- data/lib/fairy/share/vfile.rb +183 -0
- data/lib/fairy/version.rb +8 -0
- data/lib/fairy.rb +206 -0
- data/sample/grep.rb +46 -0
- data/sample/ping.rb +19 -0
- data/sample/sort.rb +102 -0
- data/sample/wordcount.rb +61 -0
- data/spec/README +12 -0
- data/spec/fairy1_spec.rb +31 -0
- data/spec/fairy2_spec.rb +42 -0
- data/spec/fairy3_spec.rb +126 -0
- data/spec/fairy4_spec.rb +63 -0
- data/spec/fairy5_spec.rb +45 -0
- data/spec/fairy6_spec.rb +52 -0
- data/spec/fairy7_spec.rb +58 -0
- data/spec/fairy8_spec.rb +48 -0
- data/spec/mkdat.rb +148 -0
- data/spec/run_all.sh +65 -0
- data/test/testc.rb +7111 -0
- data/tools/cap_recipe/Capfile +144 -0
- data/tools/cap_recipe/cluster.yml.sample +14 -0
- data/tools/fairy_perf_graph.rb +444 -0
- data/tools/git-tag +44 -0
- data/tools/log-analysis.rb +62 -0
- data/tools/svn-ls-diff +38 -0
- data/tools/svn-tags +37 -0
- metadata +298 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/master/c-io-filter"
|
7
|
+
require "fairy/master/c-inputtable"
|
8
|
+
|
9
|
+
module Fairy
|
10
|
+
class CMap<CIOFilter
|
11
|
+
Controller.def_export self
|
12
|
+
|
13
|
+
DeepConnect.def_single_method_spec(self, "REF new(REF, VAL, REF)")
|
14
|
+
def initialize(controller, opts, block_source)
|
15
|
+
super
|
16
|
+
@block_source = block_source
|
17
|
+
end
|
18
|
+
|
19
|
+
def node_class_name
|
20
|
+
"PMap"
|
21
|
+
end
|
22
|
+
|
23
|
+
def njob_creation_params
|
24
|
+
[@block_source]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,241 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/master/c-io-filter"
|
7
|
+
require "fairy/master/c-inputtable"
|
8
|
+
require "fairy/master/c-basic-group-by"
|
9
|
+
|
10
|
+
require "fairy/share/port"
|
11
|
+
|
12
|
+
module Fairy
|
13
|
+
class CMergeGroupBy<CBasicGroupBy
|
14
|
+
Controller.def_export self
|
15
|
+
|
16
|
+
def node_class_name
|
17
|
+
"PMergeGroupBy"
|
18
|
+
end
|
19
|
+
|
20
|
+
def each_export_by(njob, mapper, &block)
|
21
|
+
@each_export_by_thread_mutex.synchronize do
|
22
|
+
return if @each_export_by_thread
|
23
|
+
|
24
|
+
@each_export_by_thread = Thread.start{
|
25
|
+
# すべての njob がそろうまで待つ
|
26
|
+
# 後段が先にスケジュールされてデッドロックするのを避けるため.
|
27
|
+
number_of_nodes
|
28
|
+
|
29
|
+
begin
|
30
|
+
while pair = @exports_queue.pop
|
31
|
+
exp, njob = pair
|
32
|
+
Log::debug(self, "EXPORT_BY, #{exp.key}")
|
33
|
+
block.call exp
|
34
|
+
end
|
35
|
+
rescue
|
36
|
+
Log::fatal_exception
|
37
|
+
raise
|
38
|
+
end
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
def add_exports(key, export, njob)
|
45
|
+
@exports_mutex.synchronize do
|
46
|
+
export.no = @no_of_exports
|
47
|
+
@no_of_exports += 1
|
48
|
+
unless expexp = @exports[key]
|
49
|
+
policy = @opts[:postsuperqueue_queuing_policy]
|
50
|
+
@exports[key] = expexp = Export.new(policy)
|
51
|
+
expexp.no = @exports.size - 1
|
52
|
+
expexp.njob_id = self.class.name
|
53
|
+
expexp.add_key key
|
54
|
+
@exports_queue.push [expexp, njob]
|
55
|
+
# @pre_exports_queue.push [expexp, njob]
|
56
|
+
expexp.output_no_import = 1
|
57
|
+
end
|
58
|
+
expexp.push_delayed_element {|context|
|
59
|
+
policy = @opts[:subqueue_queuing_policy]
|
60
|
+
imp = context.context_eval(%{Import.new(#{policy.inspect})})
|
61
|
+
imp.no = export.no
|
62
|
+
imp.add_key(key)
|
63
|
+
imp.set_log_callback(%q{|n, key|
|
64
|
+
Log::verbose(self, "IMPORT POP key=#{key}: #{n}")
|
65
|
+
}, nil, __FILE__, __LINE__ - 1)
|
66
|
+
|
67
|
+
export.output = imp
|
68
|
+
export.output_no_import = 1
|
69
|
+
imp
|
70
|
+
}
|
71
|
+
# export.start_export
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# def add_exports(key, export, njob)
|
76
|
+
# @exports_mutex.synchronize do
|
77
|
+
# export.no = @no_of_exports
|
78
|
+
# @no_of_exports += 1
|
79
|
+
# unless expexp = @exports[key]
|
80
|
+
# policy = @opts[:postsuperqueue_queuing_policy]
|
81
|
+
# @exports[key] = expexp = Export.new(policy)
|
82
|
+
# expexp.no = @exports.size - 1
|
83
|
+
# expexp.add_key key
|
84
|
+
# @pre_exports_queue.push [expexp, njob]
|
85
|
+
# expexp.output_no_import = 1
|
86
|
+
# end
|
87
|
+
# policy = @opts[:subqueue_queuing_policy]
|
88
|
+
# imp = Import.new(policy)
|
89
|
+
# imp.no = export.no
|
90
|
+
# imp.add_key(key)
|
91
|
+
# imp.set_log_callback do |n|
|
92
|
+
# Log::verbose(self, "IMPORT POP: #{n}")
|
93
|
+
# end
|
94
|
+
|
95
|
+
# export.output = imp
|
96
|
+
# expexp.push imp
|
97
|
+
# export.output_no_import = 1
|
98
|
+
# end
|
99
|
+
# end
|
100
|
+
|
101
|
+
# def start_watch_all_node_imported
|
102
|
+
# Thread.start do
|
103
|
+
# @nodes_status_mutex.synchronize do
|
104
|
+
# while !all_node_imported?
|
105
|
+
# @nodes_status_cv.wait(@nodes_status_mutex)
|
106
|
+
# end
|
107
|
+
# end
|
108
|
+
# @exports_queue.push nil
|
109
|
+
# for key, exports in @exports
|
110
|
+
# exports.push :END_OF_STREAM
|
111
|
+
# end
|
112
|
+
# end
|
113
|
+
# nil
|
114
|
+
# end
|
115
|
+
|
116
|
+
def start_watch_all_node_imported
|
117
|
+
Thread.start do
|
118
|
+
# すべての njob がそろうまで待つ
|
119
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: S")
|
120
|
+
number_of_nodes
|
121
|
+
|
122
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 1")
|
123
|
+
|
124
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 2")
|
125
|
+
# すべての exports がそろうまで待つ
|
126
|
+
@nodes_status_mutex.synchronize do
|
127
|
+
while !all_node_imported?
|
128
|
+
@nodes_status_cv.wait(@nodes_status_mutex)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
@exports_queue.push nil
|
132
|
+
|
133
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 4")
|
134
|
+
for key, exports in @exports
|
135
|
+
exports.push :END_OF_STREAM
|
136
|
+
end
|
137
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: E")
|
138
|
+
end
|
139
|
+
nil
|
140
|
+
end
|
141
|
+
|
142
|
+
def start_watch_all_node_imported_ORG
|
143
|
+
Thread.start do
|
144
|
+
# すべての njob がそろうまで待つ
|
145
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: S")
|
146
|
+
number_of_nodes
|
147
|
+
|
148
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 1")
|
149
|
+
# すでに存在するexportsを下流に送る
|
150
|
+
@exports_mutex.synchronize do
|
151
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 1.1")
|
152
|
+
@pre_exports_queue.push nil
|
153
|
+
while pair = @pre_exports_queue.pop
|
154
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 1.L")
|
155
|
+
@exports_queue.push pair
|
156
|
+
end
|
157
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 1.E")
|
158
|
+
end
|
159
|
+
|
160
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 2")
|
161
|
+
# すべての exports がそろうまで待つ
|
162
|
+
@nodes_status_mutex.synchronize do
|
163
|
+
while !all_node_imported?
|
164
|
+
@nodes_status_cv.wait(@nodes_status_mutex)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 3")
|
169
|
+
# 残りのexportsを下流に送る
|
170
|
+
@pre_exports_queue.push nil
|
171
|
+
while pair = @pre_exports_queue.pop
|
172
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 3.L")
|
173
|
+
@exports_queue.push pair
|
174
|
+
end
|
175
|
+
@exports_queue.push nil
|
176
|
+
|
177
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 4")
|
178
|
+
for key, exports in @exports
|
179
|
+
exports.push :END_OF_STREAM
|
180
|
+
end
|
181
|
+
Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: E")
|
182
|
+
end
|
183
|
+
nil
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
# class BPostFilter<BFilter
|
188
|
+
# Controller.def_export self
|
189
|
+
|
190
|
+
# def initialize(controller, opts, block_source)
|
191
|
+
# super
|
192
|
+
# @block_source = block_source
|
193
|
+
|
194
|
+
# @input2node = {}
|
195
|
+
# @input_queue = PortQueue.new
|
196
|
+
# @output_queue = PortQueue.new
|
197
|
+
# end
|
198
|
+
|
199
|
+
# def input=(input)
|
200
|
+
# @input = input
|
201
|
+
# start_get_exports
|
202
|
+
# start
|
203
|
+
# end
|
204
|
+
|
205
|
+
# def start_get_exports
|
206
|
+
# Thread.start do
|
207
|
+
# @input.each_export do |export, node, key|
|
208
|
+
# @input2node[export] = node
|
209
|
+
# @input_queue.push [export
|
210
|
+
# end
|
211
|
+
# @input_queue.push nil
|
212
|
+
# end
|
213
|
+
# end
|
214
|
+
|
215
|
+
# def start
|
216
|
+
# Thread.start do
|
217
|
+
# begin
|
218
|
+
# @block.call(@input_queue, @output_queue)
|
219
|
+
# @output_queue.push nil
|
220
|
+
# ensure
|
221
|
+
# if @end_block_source
|
222
|
+
# bsource = BSource.new(@end_block_source, @context, self)
|
223
|
+
# bsource.evaluate
|
224
|
+
# end
|
225
|
+
# end
|
226
|
+
# end
|
227
|
+
# nil
|
228
|
+
# end
|
229
|
+
|
230
|
+
# def each_export(&block)
|
231
|
+
# @input.each_export do |export, node, key|
|
232
|
+
|
233
|
+
# for exp in @output_queue
|
234
|
+
# node = @input2node[exp]
|
235
|
+
# block.call exp, node
|
236
|
+
# end
|
237
|
+
# end
|
238
|
+
# end
|
239
|
+
|
240
|
+
end
|
241
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/master/c-output"
|
7
|
+
|
8
|
+
module Fairy
|
9
|
+
class COutputFile<COutput
|
10
|
+
Controller.def_export self
|
11
|
+
|
12
|
+
def initialize(controller, opts)
|
13
|
+
super
|
14
|
+
@vfile = nil
|
15
|
+
|
16
|
+
# @one_file_by_procs = @opts[:one_file_by_process]
|
17
|
+
end
|
18
|
+
|
19
|
+
def output(vf)
|
20
|
+
@vfile = vf
|
21
|
+
end
|
22
|
+
|
23
|
+
def node_class_name
|
24
|
+
"POutputFile"
|
25
|
+
end
|
26
|
+
|
27
|
+
def njob_creation_params
|
28
|
+
[@vfile]
|
29
|
+
end
|
30
|
+
|
31
|
+
# processorで1ファイルにまとめる機能は廃止
|
32
|
+
|
33
|
+
# def create_nodes
|
34
|
+
# return create_node_one_file if @one_file_by_procs
|
35
|
+
# no = 0
|
36
|
+
# @input.each_export do |input_export, input_njob|
|
37
|
+
# njob = create_and_add_node(input_export, input_njob)
|
38
|
+
# njob.add_input(nil)
|
39
|
+
# no += 1
|
40
|
+
# end
|
41
|
+
# self.number_of_nodes = no
|
42
|
+
# end
|
43
|
+
|
44
|
+
# def create_node_one_file
|
45
|
+
# no = 0
|
46
|
+
# input_processors = {}
|
47
|
+
# @input.each_export do |input_export, input_njob|
|
48
|
+
# if njob = input_processors[input_njob.processor]
|
49
|
+
# njob.add_input(input_export)
|
50
|
+
# else
|
51
|
+
# njob = create_and_add_node(input_export, input_njob)
|
52
|
+
# input_processors[njob.processor] = njob
|
53
|
+
# no += 1
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
# for p, njob in input_processors
|
57
|
+
# njob.add_input(nil)
|
58
|
+
# end
|
59
|
+
# self.number_of_nodes = no
|
60
|
+
# end
|
61
|
+
|
62
|
+
|
63
|
+
def wait_all_output_finished
|
64
|
+
@nodes_status_mutex.synchronize do
|
65
|
+
while !all_node_outputted?
|
66
|
+
@nodes_status_cv.wait(@nodes_status_mutex)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def all_node_outputted?
|
72
|
+
|
73
|
+
return false unless @number_of_nodes
|
74
|
+
|
75
|
+
all_outputted = true
|
76
|
+
each_node(:exist_only) do |node|
|
77
|
+
st = @nodes_status[node]
|
78
|
+
all_outputted &&= [:ST_FINISH, :ST_OUTPUT_FINISH].include?(st)
|
79
|
+
end
|
80
|
+
all_outputted
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require "fairy/master/c-here"
|
4
|
+
|
5
|
+
module Fairy
|
6
|
+
class COutputLocalFile<CHere
|
7
|
+
Controller.def_export(self)
|
8
|
+
|
9
|
+
def node_class_name
|
10
|
+
"POutputLocalFile"
|
11
|
+
end
|
12
|
+
|
13
|
+
def output(filename)
|
14
|
+
@filename = filename
|
15
|
+
backend.output(self)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/master/c-output"
|
7
|
+
|
8
|
+
module Fairy
|
9
|
+
class COutputNull<COutput
|
10
|
+
Controller.def_export self
|
11
|
+
|
12
|
+
def initialize(controller, opts)
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def node_class_name
|
17
|
+
"POutputNull"
|
18
|
+
end
|
19
|
+
|
20
|
+
# def njob_creation_params
|
21
|
+
# end
|
22
|
+
|
23
|
+
def number_of_nodes=(no_nodes)
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def wait_all_output_finished
|
28
|
+
@nodes_status_mutex.synchronize do
|
29
|
+
while !all_node_outputted?
|
30
|
+
@nodes_status_cv.wait(@nodes_status_mutex)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def all_node_outputted?
|
36
|
+
return false unless @nodes_mutex.synchronize{@number_of_nodes}
|
37
|
+
|
38
|
+
each_node(:exist_only) do |node|
|
39
|
+
st = @nodes_status[node]
|
40
|
+
return false unless [:ST_FINISH, :ST_OUTPUT_FINISH].include?(st)
|
41
|
+
end
|
42
|
+
true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/master/c-output"
|
7
|
+
|
8
|
+
require "fairy/share/varray"
|
9
|
+
|
10
|
+
module Fairy
|
11
|
+
class COutputVArray<COutput
|
12
|
+
Controller.def_export self
|
13
|
+
|
14
|
+
def initialize(controller, opts)
|
15
|
+
super
|
16
|
+
@varray = VArray.new(nil)
|
17
|
+
|
18
|
+
@node_id = 0
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :varray
|
22
|
+
|
23
|
+
def node_class_name
|
24
|
+
"POutputVArray"
|
25
|
+
end
|
26
|
+
|
27
|
+
def njob_creation_params
|
28
|
+
@node_id += 1
|
29
|
+
[@node_id-1]
|
30
|
+
# []
|
31
|
+
end
|
32
|
+
|
33
|
+
def number_of_nodes=(no_nodes)
|
34
|
+
super
|
35
|
+
@varray.arrays_size = no_nodes
|
36
|
+
end
|
37
|
+
|
38
|
+
def wait_all_output_finished
|
39
|
+
@nodes_status_mutex.synchronize do
|
40
|
+
while !all_node_outputted?
|
41
|
+
@nodes_status_cv.wait(@nodes_status_mutex)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def all_node_outputted?
|
47
|
+
return false unless @nodes_mutex.synchronize{@number_of_nodes}
|
48
|
+
|
49
|
+
each_node(:exist_only) do |node|
|
50
|
+
st = @nodes_status[node]
|
51
|
+
return false unless [:ST_FINISH, :ST_OUTPUT_FINISH].include?(st)
|
52
|
+
end
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|