fairy 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. data/LICENSE +674 -0
  2. data/Makefile +116 -0
  3. data/README +15 -0
  4. data/bin/fairy +582 -0
  5. data/bin/fairy-cat +74 -0
  6. data/bin/fairy-cp +128 -0
  7. data/bin/fairy-rm +122 -0
  8. data/bin/subcmd/controller +41 -0
  9. data/bin/subcmd/inspector +81 -0
  10. data/bin/subcmd/master +43 -0
  11. data/bin/subcmd/node +47 -0
  12. data/bin/subcmd/processor +54 -0
  13. data/doc/programming-interface.html +240 -0
  14. data/doc/programming-interface.rd +300 -0
  15. data/etc/fairy.conf.tmpl +118 -0
  16. data/ext/simple_hash/extconf.rb +4 -0
  17. data/ext/simple_hash/simple_hash.c +42 -0
  18. data/fairy.gemspec +60 -0
  19. data/lib/fairy/client/addins.rb +20 -0
  20. data/lib/fairy/client/barrier.rb +29 -0
  21. data/lib/fairy/client/basic-group-by.rb +52 -0
  22. data/lib/fairy/client/cat.rb +41 -0
  23. data/lib/fairy/client/direct-product.rb +51 -0
  24. data/lib/fairy/client/equijoin.rb +79 -0
  25. data/lib/fairy/client/exec.rb +54 -0
  26. data/lib/fairy/client/filter.rb +62 -0
  27. data/lib/fairy/client/find.rb +35 -0
  28. data/lib/fairy/client/group-by.rb +194 -0
  29. data/lib/fairy/client/here.rb +84 -0
  30. data/lib/fairy/client/inject.rb +70 -0
  31. data/lib/fairy/client/input-file.rb +53 -0
  32. data/lib/fairy/client/input-iota.rb +49 -0
  33. data/lib/fairy/client/input-local-file.rb +188 -0
  34. data/lib/fairy/client/input-varray.rb +30 -0
  35. data/lib/fairy/client/input.rb +42 -0
  36. data/lib/fairy/client/io-filter.rb +26 -0
  37. data/lib/fairy/client/junction.rb +31 -0
  38. data/lib/fairy/client/map.rb +34 -0
  39. data/lib/fairy/client/merge-group-by.rb +71 -0
  40. data/lib/fairy/client/output-file.rb +64 -0
  41. data/lib/fairy/client/output-local-file.rb +60 -0
  42. data/lib/fairy/client/output-null.rb +47 -0
  43. data/lib/fairy/client/output-varray.rb +50 -0
  44. data/lib/fairy/client/output.rb +29 -0
  45. data/lib/fairy/client/roma-put.rb +62 -0
  46. data/lib/fairy/client/roma.rb +156 -0
  47. data/lib/fairy/client/seg-join.rb +61 -0
  48. data/lib/fairy/client/seg-map.rb +78 -0
  49. data/lib/fairy/client/seg-shuffle.rb +35 -0
  50. data/lib/fairy/client/seg-split.rb +27 -0
  51. data/lib/fairy/client/seg-zip.rb +60 -0
  52. data/lib/fairy/client/select.rb +38 -0
  53. data/lib/fairy/client/sort.rb +48 -0
  54. data/lib/fairy/client/sort18.rb +56 -0
  55. data/lib/fairy/client/sort19.rb +61 -0
  56. data/lib/fairy/client/there.rb +47 -0
  57. data/lib/fairy/client/top_n_into_roma.rb +34 -0
  58. data/lib/fairy/client/wc.rb +92 -0
  59. data/lib/fairy/controller.rb +1103 -0
  60. data/lib/fairy/logger.rb +107 -0
  61. data/lib/fairy/master/addins.rb +20 -0
  62. data/lib/fairy/master/atom.rb +17 -0
  63. data/lib/fairy/master/c-barrier.rb +283 -0
  64. data/lib/fairy/master/c-basic-group-by.rb +250 -0
  65. data/lib/fairy/master/c-cat.rb +159 -0
  66. data/lib/fairy/master/c-direct-product.rb +203 -0
  67. data/lib/fairy/master/c-exec.rb +68 -0
  68. data/lib/fairy/master/c-filter.rb +422 -0
  69. data/lib/fairy/master/c-find.rb +138 -0
  70. data/lib/fairy/master/c-group-by.rb +64 -0
  71. data/lib/fairy/master/c-here.rb +80 -0
  72. data/lib/fairy/master/c-inject.rb +119 -0
  73. data/lib/fairy/master/c-input-file.rb +46 -0
  74. data/lib/fairy/master/c-input-iota.rb +66 -0
  75. data/lib/fairy/master/c-input-local-file.rb +117 -0
  76. data/lib/fairy/master/c-input-varray.rb +53 -0
  77. data/lib/fairy/master/c-input.rb +24 -0
  78. data/lib/fairy/master/c-inputtable.rb +31 -0
  79. data/lib/fairy/master/c-inputtable18.rb +36 -0
  80. data/lib/fairy/master/c-inputtable19.rb +35 -0
  81. data/lib/fairy/master/c-io-filter.rb +28 -0
  82. data/lib/fairy/master/c-junction.rb +54 -0
  83. data/lib/fairy/master/c-map.rb +27 -0
  84. data/lib/fairy/master/c-merge-group-by.rb +241 -0
  85. data/lib/fairy/master/c-output-file.rb +84 -0
  86. data/lib/fairy/master/c-output-local-file.rb +19 -0
  87. data/lib/fairy/master/c-output-null.rb +45 -0
  88. data/lib/fairy/master/c-output-varray.rb +57 -0
  89. data/lib/fairy/master/c-output.rb +20 -0
  90. data/lib/fairy/master/c-seg-join.rb +141 -0
  91. data/lib/fairy/master/c-seg-map.rb +26 -0
  92. data/lib/fairy/master/c-seg-shuffle.rb +87 -0
  93. data/lib/fairy/master/c-seg-split.rb +110 -0
  94. data/lib/fairy/master/c-seg-zip.rb +132 -0
  95. data/lib/fairy/master/c-select.rb +27 -0
  96. data/lib/fairy/master/c-sort.rb +108 -0
  97. data/lib/fairy/master/c-there.rb +57 -0
  98. data/lib/fairy/master/c-wc.rb +232 -0
  99. data/lib/fairy/master/job-interpriter.rb +19 -0
  100. data/lib/fairy/master/scheduler.rb +24 -0
  101. data/lib/fairy/master.rb +329 -0
  102. data/lib/fairy/node/addins.rb +19 -0
  103. data/lib/fairy/node/p-barrier.rb +95 -0
  104. data/lib/fairy/node/p-basic-group-by.rb +252 -0
  105. data/lib/fairy/node/p-direct-product.rb +153 -0
  106. data/lib/fairy/node/p-exec.rb +30 -0
  107. data/lib/fairy/node/p-filter.rb +363 -0
  108. data/lib/fairy/node/p-find.rb +111 -0
  109. data/lib/fairy/node/p-group-by.rb +1534 -0
  110. data/lib/fairy/node/p-here.rb +21 -0
  111. data/lib/fairy/node/p-identity.rb +24 -0
  112. data/lib/fairy/node/p-inject.rb +127 -0
  113. data/lib/fairy/node/p-input-file.rb +108 -0
  114. data/lib/fairy/node/p-input-iota.rb +39 -0
  115. data/lib/fairy/node/p-input-local-file.rb +61 -0
  116. data/lib/fairy/node/p-input-varray.rb +26 -0
  117. data/lib/fairy/node/p-io-filter.rb +28 -0
  118. data/lib/fairy/node/p-map.rb +40 -0
  119. data/lib/fairy/node/p-merger-group-by.rb +48 -0
  120. data/lib/fairy/node/p-output-file.rb +104 -0
  121. data/lib/fairy/node/p-output-local-file.rb +14 -0
  122. data/lib/fairy/node/p-output-null.rb +32 -0
  123. data/lib/fairy/node/p-output-varray.rb +41 -0
  124. data/lib/fairy/node/p-seg-join.rb +82 -0
  125. data/lib/fairy/node/p-seg-map.rb +34 -0
  126. data/lib/fairy/node/p-seg-split.rb +61 -0
  127. data/lib/fairy/node/p-seg-zip.rb +79 -0
  128. data/lib/fairy/node/p-select.rb +40 -0
  129. data/lib/fairy/node/p-single-exportable.rb +90 -0
  130. data/lib/fairy/node/p-sort.rb +195 -0
  131. data/lib/fairy/node/p-task.rb +113 -0
  132. data/lib/fairy/node/p-there.rb +44 -0
  133. data/lib/fairy/node/p-wc.rb +266 -0
  134. data/lib/fairy/node.rb +187 -0
  135. data/lib/fairy/processor.rb +510 -0
  136. data/lib/fairy/share/base-app.rb +114 -0
  137. data/lib/fairy/share/block-source.rb +234 -0
  138. data/lib/fairy/share/conf.rb +396 -0
  139. data/lib/fairy/share/debug.rb +21 -0
  140. data/lib/fairy/share/encoding.rb +17 -0
  141. data/lib/fairy/share/fast-tempfile.rb +93 -0
  142. data/lib/fairy/share/file-place.rb +176 -0
  143. data/lib/fairy/share/hash-1.rb +20 -0
  144. data/lib/fairy/share/hash-md5.rb +28 -0
  145. data/lib/fairy/share/hash-murmur.rb +69 -0
  146. data/lib/fairy/share/hash-rb18.rb +20 -0
  147. data/lib/fairy/share/hash-simple-hash.rb +28 -0
  148. data/lib/fairy/share/inspector.rb +16 -0
  149. data/lib/fairy/share/lc/exceptions.rb +82 -0
  150. data/lib/fairy/share/lc/ja/exceptions.rb +81 -0
  151. data/lib/fairy/share/locale.rb +17 -0
  152. data/lib/fairy/share/log.rb +215 -0
  153. data/lib/fairy/share/pool-dictionary.rb +53 -0
  154. data/lib/fairy/share/port-marshaled-queue.rb +347 -0
  155. data/lib/fairy/share/port.rb +1697 -0
  156. data/lib/fairy/share/reference.rb +45 -0
  157. data/lib/fairy/share/stdout.rb +56 -0
  158. data/lib/fairy/share/tr.rb +16 -0
  159. data/lib/fairy/share/varray.rb +147 -0
  160. data/lib/fairy/share/vfile.rb +183 -0
  161. data/lib/fairy/version.rb +8 -0
  162. data/lib/fairy.rb +206 -0
  163. data/sample/grep.rb +46 -0
  164. data/sample/ping.rb +19 -0
  165. data/sample/sort.rb +102 -0
  166. data/sample/wordcount.rb +61 -0
  167. data/spec/README +12 -0
  168. data/spec/fairy1_spec.rb +31 -0
  169. data/spec/fairy2_spec.rb +42 -0
  170. data/spec/fairy3_spec.rb +126 -0
  171. data/spec/fairy4_spec.rb +63 -0
  172. data/spec/fairy5_spec.rb +45 -0
  173. data/spec/fairy6_spec.rb +52 -0
  174. data/spec/fairy7_spec.rb +58 -0
  175. data/spec/fairy8_spec.rb +48 -0
  176. data/spec/mkdat.rb +148 -0
  177. data/spec/run_all.sh +65 -0
  178. data/test/testc.rb +7111 -0
  179. data/tools/cap_recipe/Capfile +144 -0
  180. data/tools/cap_recipe/cluster.yml.sample +14 -0
  181. data/tools/fairy_perf_graph.rb +444 -0
  182. data/tools/git-tag +44 -0
  183. data/tools/log-analysis.rb +62 -0
  184. data/tools/svn-ls-diff +38 -0
  185. data/tools/svn-tags +37 -0
  186. metadata +298 -0
@@ -0,0 +1,138 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (C) 2007-2010 Rakuten, Inc.
4
+ #
5
+
6
+ require "forwardable"
7
+
8
+ require "deep-connect"
9
+
10
+ require "fairy/master/c-io-filter"
11
+
12
+ module Fairy
13
+ class CFind<CIOFilter
14
+ extend Forwardable
15
+
16
+ Controller.def_export self
17
+
18
+ def initialize(controller, opts, block_source)
19
+ super
20
+
21
+ @block_source = block_source
22
+
23
+ @clocal_find = CLocalFind.new(controller, opts, block_source)
24
+ @cfind_result = CFindResult.new(controller, opts, self)
25
+
26
+ end
27
+
28
+ def_delegator :@cfind_result, :value
29
+ def_delegator :@cfind_result, :output=
30
+
31
+ def input=(input)
32
+ @clocal_find.input = input
33
+ @cfind_result.input = @clocal_find
34
+ end
35
+
36
+ def update_find
37
+ @clocal_find.break_running
38
+ end
39
+
40
+ class CLocalFind<CIOFilter
41
+ def initialize(controller, opts, block_source)
42
+ super
43
+ @block_source = block_source
44
+
45
+ @no = 0
46
+ @first_node = nil
47
+ @first_node_mutex = Mutex.new
48
+ end
49
+
50
+ def node_class_name
51
+ "PLocalFind"
52
+ end
53
+
54
+ def njob_creation_params
55
+ [@block_source]
56
+ end
57
+
58
+ def each_assigned_filter(&block)
59
+ super
60
+
61
+ @first_node.export.output_no_import = @no
62
+ end
63
+
64
+ def each_export_by(njob, mapper, &block)
65
+ @first_node_mutex.synchronize do
66
+ @no += 1
67
+ if @first_node
68
+ njob.export.output = @first_node.export.output
69
+ njob.export.no = @no - 1
70
+ else
71
+ super
72
+ @first_node = njob
73
+ end
74
+ end
75
+ end
76
+
77
+ def bind_export(exp, imp)
78
+ # do nothing.
79
+ end
80
+
81
+ # def each_export(&block)
82
+ # no = 0
83
+ # first_node = nil
84
+ # each_node do |node|
85
+ # no += 1
86
+ # if first_node
87
+ # node.export.output = first_node.export.output
88
+ # else
89
+ # first_node = node
90
+ # block.call node.export, node
91
+ # end
92
+ # end
93
+ # first_node.export.output_no_import = no
94
+ # end
95
+
96
+ # def find_break
97
+ # # create node 中ならそれをとめる
98
+ # break_create_node
99
+ # # 各tasklettをとめる
100
+ # each_node do |tasklet|
101
+ # tasklet.find_break
102
+ # end
103
+ # end
104
+
105
+ end
106
+
107
+ class CFindResult<CIOFilter
108
+ def initialize(controller, opts, bfind)
109
+ super
110
+ @bfind = bfind
111
+
112
+ @find_mutex = Mutex.new
113
+ @findp = false
114
+ end
115
+
116
+ def node_class_name
117
+ "PFindResult"
118
+ end
119
+
120
+ def njob_creation_params
121
+ []
122
+ end
123
+
124
+ def value
125
+ each_node{|node| return node.value}
126
+ end
127
+
128
+ def update_find
129
+ @find_mutex.synchronize do
130
+ if !@findp
131
+ @findp = true
132
+ @bfind.update_find
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,64 @@
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
+ module Fairy
11
+ class CGroupBy<CBasicGroupBy
12
+ Controller.def_export self
13
+
14
+ def initialize(controller, opts, block_source)
15
+ super
16
+
17
+ @hash_seed = controller.hash_seed
18
+ end
19
+
20
+ attr_reader :hash_seed
21
+
22
+ def node_class_name
23
+ "PGroupBy"
24
+ end
25
+
26
+ class CPostFilter<CIOFilter
27
+ Controller.def_export self
28
+
29
+ def initialize(controller, opts, block_source)
30
+ super
31
+ @block_source = block_source
32
+ end
33
+
34
+ def node_class_name
35
+ "PGroupBy::PPostFilter"
36
+ end
37
+
38
+ def njob_creation_params
39
+ [@block_source]
40
+ end
41
+
42
+ def create_import(processor)
43
+ policy = @opts[:postfilter_prequeuing_policy]
44
+ policy ||= @opts[:prequeuing_policy]
45
+
46
+ processor.create_import(policy)
47
+ end
48
+ end
49
+
50
+ # class BPostAfterModFilter<BFilter
51
+ # Controller.def_export self
52
+
53
+ # def initialize(controller, opts, block_source)
54
+ # super
55
+ # @block_source = block_source
56
+ # end
57
+
58
+ # def node_class_name
59
+ # "NPostAfterModFilter"
60
+ # end
61
+ # end
62
+
63
+ end
64
+ end
@@ -0,0 +1,80 @@
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
+ require "fairy/share/port"
10
+
11
+
12
+ module Fairy
13
+ class CHere<CIOFilter
14
+ Controller.def_export self
15
+
16
+ def node_class_name
17
+ "PHere"
18
+ end
19
+
20
+ def create_and_add_node(ntask, mapper, opts={})
21
+ node = create_node(ntask) {|node|
22
+ if opts[:init_njob]
23
+ opts[:init_njob].call(node)
24
+ end
25
+ mapper.bind_input(node)
26
+ # exp = node.start_export
27
+ }
28
+ node
29
+ end
30
+
31
+ def each(&block)
32
+ policy = @opts[:prequeuing_policy]
33
+ each_node do |node|
34
+ node.start_export
35
+ import = Import.new(policy)
36
+ import.set_log_callback do |n, key|
37
+ Log::verbose(self, "IMPORT POP key=#{key}: #{n}")
38
+ end
39
+ import.no_import = 1
40
+ node.export.output = import
41
+ import.each do |e|
42
+ block.call e
43
+ end
44
+ end
45
+ end
46
+ DeepConnect.def_method_spec(self, "each(){DVAL}")
47
+
48
+ def each_buf(&block)
49
+ threshold = @opts[:pool_threshold] || CONF.HERE_POOL_THRESHOLD
50
+ chunk = []
51
+
52
+ policy = @opts[:prequeuing_policy]
53
+ each_node do |node|
54
+ node.start_export
55
+ import = Import.new(policy)
56
+ import.set_log_callback do |n, key|
57
+ Log::verbose(self, "IMPORT POP key=#{key}: #{n}")
58
+ end
59
+ import.no_import = 1
60
+ node.export.output = import
61
+
62
+ import.each do |e|
63
+ #[REQ#89]
64
+
65
+ chunk.push e
66
+ if chunk.size > threshold
67
+ block.call chunk
68
+ chunk.clear
69
+ end
70
+ end
71
+ end
72
+ if !chunk.empty?
73
+ block.call chunk
74
+ end
75
+ end
76
+ DeepConnect.def_method_spec(self, "each_buf(){DVAL}")
77
+ end
78
+ end
79
+
80
+
@@ -0,0 +1,119 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (C) 2007-2010 Rakuten, Inc.
4
+ #
5
+
6
+ require "forwardable"
7
+
8
+ require "deep-connect"
9
+
10
+ require "fairy/master/c-io-filter"
11
+
12
+ module Fairy
13
+ class CInject<CIOFilter
14
+ extend Forwardable
15
+
16
+ Controller.def_export self
17
+
18
+ def initialize(controller, opts, block_source)
19
+ super
20
+
21
+ @block_source = block_source
22
+
23
+ @clocal_inject = CLocalInject.new(controller, opts, block_source)
24
+ @cwide_inject = CWideInject.new(controller, opts, block_source)
25
+
26
+ end
27
+
28
+ def_delegator :@cwide_inject, :value
29
+ def_delegator :@cwide_inject, :output=
30
+ def_delegator :@cwide_inject, :each_assigned_filter
31
+ def_delegator :@cwide_inject, :each_export_by
32
+ def_delegator :@cwide_inject, :bind_export
33
+
34
+
35
+ def input=(input)
36
+ @clocal_inject.input = input
37
+ @cwide_inject.input = @clocal_inject
38
+ end
39
+
40
+ class CLocalInject<CIOFilter
41
+ def initialize(controller, opts, block_source)
42
+ super
43
+ @block_source = block_source
44
+
45
+ @no = 0
46
+ @first_node = nil
47
+ @first_node_mutex = Mutex.new
48
+ end
49
+
50
+ def node_class_name
51
+ "PLocalInject"
52
+ end
53
+
54
+ def njob_creation_params
55
+ [@block_source]
56
+ end
57
+
58
+ def each_assigned_filter(&block)
59
+ super
60
+
61
+ @first_node.export.output_no_import = @no
62
+ end
63
+
64
+ def each_export_by(njob, mapper, &block)
65
+ @first_node_mutex.synchronize do
66
+ @no += 1
67
+ if @first_node
68
+ njob.export.output = @first_node.export.output
69
+ njob.export.no = @no - 1
70
+ else
71
+ super
72
+ @first_node = njob
73
+ end
74
+ end
75
+ end
76
+
77
+ def bind_export(exp, imp)
78
+ # do nothing.
79
+ end
80
+
81
+
82
+ # def each_export(&block)
83
+
84
+ # no = 0
85
+ # first_node = nil
86
+ # each_node do |node|
87
+ # no += 1
88
+ # if first_node
89
+ # node.export.output = first_node.export.output
90
+ # else
91
+ # first_node = node
92
+ # block.call node.export, node
93
+ # end
94
+ # end
95
+ # first_node.export.output_no_import = no
96
+ # end
97
+
98
+ end
99
+
100
+ class CWideInject<CIOFilter
101
+ def initialize(controller, opts, block_source)
102
+ super
103
+ @block_source = block_source
104
+ end
105
+
106
+ def node_class_name
107
+ "PWideInject"
108
+ end
109
+
110
+ def njob_creation_params
111
+ [@block_source]
112
+ end
113
+
114
+ def value
115
+ each_node{|node| return node.value}
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,46 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (C) 2007-2010 Rakuten, Inc.
4
+ #
5
+
6
+ require "uri"
7
+
8
+ require "fairy/master/c-input"
9
+ require "fairy/share/vfile"
10
+ require "fairy/share/file-place"
11
+
12
+ module Fairy
13
+ class CInputFile<CInput
14
+ Controller.def_export self
15
+
16
+ def CInputFile.open(controller, opts, descripter)
17
+ bfile = CInputFile.new(controller, opts)
18
+ bfile.open(desctipter)
19
+ bfile
20
+ end
21
+ DeepConnect.def_single_method_spec(self, "REF open(REF, VAL, VAL)")
22
+
23
+ def node_class_name
24
+ "PInputFile"
25
+ end
26
+
27
+ def open(vf)
28
+ @vfile = vf
29
+ @cfile_place = CFilePlace.new(@vfile)
30
+
31
+ start_create_nodes
32
+ end
33
+ DeepConnect.def_method_spec(self, "REF open(DVAL)")
34
+
35
+ def input
36
+ @cfile_place
37
+ end
38
+
39
+ # def create_and_add_node(processor, mapper)
40
+ # node = super
41
+ # node.open(mapper.input.path)
42
+ # node
43
+ # end
44
+
45
+ end
46
+ end