Class: Fairy::CDirectProduct

Inherits:
CIOFilter show all
Extended by:
Forwardable
Defined in:
lib/fairy/master/c-direct-product.rb

Defined Under Namespace

Classes: CPostFilter, CPreFilter

Instance Attribute Summary collapse

Attributes inherited from CIOFilter

#input

Attributes included from CInputtable

#input

Instance Method Summary collapse

Methods inherited from CIOFilter

#node_class, #output=

Methods included from CInputtable

#break_running, #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_export_by, #each_node, #each_node_exist_only, #handle_exception, #input, #job_pool_dict, #job_pool_variable, #node_class_name, #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

#initialize(controller, opts, others, block_source) ⇒ CDirectProduct

Returns a new instance of CDirectProduct.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fairy/master/c-direct-product.rb', line 20

def initialize(controller, opts, others, block_source)
  super

  @others = others
  @block_source = block_source

  @main_prefilter = CPreFilter.new(@controller, @opts, block_source)
  @main_prefilter.main = self
  @other_prefilters = []
  @others.each do |other|
	prefilter = CPreFilter.new(@controller, @opts, block_source)
	prefilter.main = self
	@other_prefilters.push prefilter
  end
  @postfilter = CPostFilter.new(@controller, @opts, block_source)

  @prefilter_no_nodes = {}
  @prefilter_no_nodes_mutex = Mutex.new
  @prefilter_no_nodes_cv = ConditionVariable.new
end

Instance Attribute Details

#other_prefiltersObject (readonly)

Returns the value of attribute other_prefilters.



41
42
43
# File 'lib/fairy/master/c-direct-product.rb', line 41

def other_prefilters
  @other_prefilters
end

Instance Method Details

#all_prefiltersObject



43
44
45
# File 'lib/fairy/master/c-direct-product.rb', line 43

def all_prefilters
  [@main_prefilter, *@other_prefilters]
end

#each_assigned_filter(&block) ⇒ Object



51
52
53
# File 'lib/fairy/master/c-direct-product.rb', line 51

def each_assigned_filter(&block)
  @postfilter.each_assigned_filter &block
end

#input=(other) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/fairy/master/c-direct-product.rb', line 55

def input=(other)
  @main_prefilter.input = other
  @others.zip(@other_prefilters) do |o, prefilter|
	prefilter.input = o
  end

  @postfilter.input = @main_prefilter
end

#njob_creation_paramsObject



47
48
49
# File 'lib/fairy/master/c-direct-product.rb', line 47

def njob_creation_params
  [@block_source]
end

#no_of_exports_for_prefilter(prefilter) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/fairy/master/c-direct-product.rb', line 71

def no_of_exports_for_prefilter(prefilter)
  all_prefilters.reject{|f| prefilter==f}.inject(1){|dp, f|
	@prefilter_no_nodes_mutex.synchronize do
	  while (v = @prefilter_no_nodes[f]).nil?
 @prefilter_no_nodes_cv.wait(@prefilter_no_nodes_mutex)
	  end
	  dp *= v
	end
  }
end

#update_prefilter_no_nodes(prefilter) ⇒ Object



64
65
66
67
68
69
# File 'lib/fairy/master/c-direct-product.rb', line 64

def update_prefilter_no_nodes(prefilter)
  @prefilter_no_nodes_mutex.synchronize do
	@prefilter_no_nodes[prefilter] = prefilter.number_of_nodes
	@prefilter_no_nodes_cv.broadcast
  end
end