Class: Fairy::CMergeGroupBy
- Inherits:
-
CBasicGroupBy
- Object
- CFilter
- CIOFilter
- CBasicGroupBy
- Fairy::CMergeGroupBy
- Defined in:
- lib/fairy/master/c-merge-group-by.rb
Instance Attribute Summary
Attributes inherited from CIOFilter
Attributes included from CInputtable
Instance Method Summary collapse
- #add_exports(key, export, njob) ⇒ Object
- #each_export_by(njob, mapper, &block) ⇒ Object
- #node_class_name ⇒ Object
-
#start_watch_all_node_imported ⇒ Object
def start_watch_all_node_imported Thread.start do @nodes_status_mutex.synchronize do while !all_node_imported? @nodes_status_cv.wait(@nodes_status_mutex) end end @exports_queue.push nil for key, exports in @exports exports.push :END_OF_STREAM end end nil end.
- #start_watch_all_node_imported_ORG ⇒ Object
Methods inherited from CBasicGroupBy
#all_node_arrived?, #all_node_imported?, #bind_export, #each_assigned_filter, #initialize, #njob_creation_params, #start_create_nodes, #update_exports
Methods inherited from CIOFilter
Methods included from CInputtable
#break_running, #initialize, #inputtable?
Methods inherited from CFilter
#abort_create_node, #add_node, #assgin_number_of_nodes?, #bind_export, #break_create_node, #break_running, #create_and_add_node, #create_import, #create_node, #create_nodes, #def_job_pool_variable, #each_assigned_filter, #each_node, #each_node_exist_only, #handle_exception, #initialize, #input, #job_pool_dict, #job_pool_variable, #njob_creation_params, #nodes, #number_of_nodes, #number_of_nodes=, #pool_dict, #postmapping_policy, #start_create_nodes, #start_export, #start_watch_node_status, #update_status, watch_status, watch_status=, #watch_status?
Constructor Details
This class inherits a constructor from Fairy::CBasicGroupBy
Instance Method Details
#add_exports(key, export, njob) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fairy/master/c-merge-group-by.rb', line 44 def add_exports(key, export, njob) @exports_mutex.synchronize do export.no = @no_of_exports @no_of_exports += 1 unless expexp = @exports[key] policy = @opts[:postsuperqueue_queuing_policy] @exports[key] = expexp = Export.new(policy) expexp.no = @exports.size - 1 expexp.njob_id = self.class.name expexp.add_key key @exports_queue.push [expexp, njob] # @pre_exports_queue.push [expexp, njob] expexp.output_no_import = 1 end expexp.push_delayed_element {|context| policy = @opts[:subqueue_queuing_policy] imp = context.context_eval(%{Import.new(#{policy.inspect})}) imp.no = export.no imp.add_key(key) imp.set_log_callback(%q{|n, key| Log::verbose(self, "IMPORT POP key=#{key}: #{n}") }, nil, __FILE__, __LINE__ - 1) export.output = imp export.output_no_import = 1 imp } # export.start_export end end |
#each_export_by(njob, mapper, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fairy/master/c-merge-group-by.rb', line 20 def each_export_by(njob, mapper, &block) @each_export_by_thread_mutex.synchronize do return if @each_export_by_thread @each_export_by_thread = Thread.start{ # すべての njob がそろうまで待つ # 後段が先にスケジュールされてデッドロックするのを避けるため. number_of_nodes begin while pair = @exports_queue.pop exp, njob = pair Log::debug(self, "EXPORT_BY, #{exp.key}") block.call exp end rescue Log::fatal_exception raise end } end end |
#node_class_name ⇒ Object
16 17 18 |
# File 'lib/fairy/master/c-merge-group-by.rb', line 16 def node_class_name "PMergeGroupBy" end |
#start_watch_all_node_imported ⇒ Object
def start_watch_all_node_imported
Thread.start do
@nodes_status_mutex.synchronize do while !all_node_imported? @nodes_status_cv.wait(@nodes_status_mutex) end end @exports_queue.push nil for key, exports in @exports exports.push :END_OF_STREAM end
end
nil
end
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/fairy/master/c-merge-group-by.rb', line 116 def start_watch_all_node_imported Thread.start do # すべての njob がそろうまで待つ Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: S") number_of_nodes Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 1") Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 2") # すべての exports がそろうまで待つ @nodes_status_mutex.synchronize do while !all_node_imported? @nodes_status_cv.wait(@nodes_status_mutex) end end @exports_queue.push nil Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 4") for key, exports in @exports exports.push :END_OF_STREAM end Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: E") end nil end |
#start_watch_all_node_imported_ORG ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/fairy/master/c-merge-group-by.rb', line 142 def start_watch_all_node_imported_ORG Thread.start do # すべての njob がそろうまで待つ Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: S") number_of_nodes Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 1") # すでに存在するexportsを下流に送る @exports_mutex.synchronize do Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 1.1") @pre_exports_queue.push nil while pair = @pre_exports_queue.pop Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 1.L") @exports_queue.push pair end Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 1.E") end Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 2") # すべての exports がそろうまで待つ @nodes_status_mutex.synchronize do while !all_node_imported? @nodes_status_cv.wait(@nodes_status_mutex) end end Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 3") # 残りのexportsを下流に送る @pre_exports_queue.push nil while pair = @pre_exports_queue.pop Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 3.L") @exports_queue.push pair end @exports_queue.push nil Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: 4") for key, exports in @exports exports.push :END_OF_STREAM end Log::debug(self, "START_WATCH_ALL_NODE_IMPORTED: E") end nil end |