Class: Fairy::CCat

Inherits:
CIOFilter show all
Defined in:
lib/fairy/master/c-cat.rb

Defined Under Namespace

Classes: CPreCat

Instance Attribute Summary

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, #def_job_pool_variable, #each_assigned_filter, #each_export_by, #each_node, #each_node_exist_only, #handle_exception, #input, #job_pool_dict, #job_pool_variable, #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) ⇒ CCat

Returns a new instance of CCat.



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

def initialize(controller, opts, others)
  super
  
  @others = others
  @export_node_pairs_queues = nil
  @export_node_pairs_queues_mutex = Mutex.new
  @export_node_pairs_queues_cv = XThread::ConditionVariable.new

  @main_precat = CPreCat.new(controller, opts)

  @others_precat = @others.map{|o| 
  precat = CPreCat.new(controller, opts)
  precat.input = o
  precat
  }
end

Instance Method Details

#create_nodesObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/fairy/master/c-cat.rb', line 51

def create_nodes
  begin
  no = 0
  [@main_precat, *@others_precat].each do |input|
    @input = input
    input.output = @input
    @controller.assign_ntasks(self, @create_node_mutex) do
 |ntask, mapper, opts={}|
#     njob = create_and_add_node(processor, mapper)
 njob = create_node(ntask) {|node|
   if opts[:init_njob]
    opts[:init_njob].call(node)
   end
   mapper.bind_input(node)
   node.no = no
 }
 no += 1
 njob
    end
  end
  rescue BreakCreateNode
  # do nothing
  Log::debug self, "BREAK CREATE NODE: #{self}" 

  rescue AbortCreateNode
  Log::debug self, "Abort CREATE NODE: #{self}" 
  # do nothing

  rescue ERR::NodeNotArrived
  Log::debug self, "NODE NOT ARRIVED: #{file}"
  begin
    handle_exception($!)
  rescue
    Log::debug_exception(self)
  end
  Log::debug self, "NODE NOT ARRIVED2: #{file}"
  raise

  rescue ERR::CantExecSubcmd
  begin
    handle_exception($!)
  rescue
    Log::debug_exception(self)
  end
  Log::debug self, "CANT EXEC SUBCOMMAND: #{self}"
  raise

  rescue ERR::CantExecSubcmd
  begin
    handle_exception($!)
  rescue
    Log::debug_exception(self)
  end
  Log::debug self, "CANT EXEC SUBCOMMAND: #{self}"
  raise

  rescue Exception
  Log::warn_exception(self)
  raise
  ensure
  Log::debug self, "CREATE_NODES: #{self}.number_of_nodes=#{no}"
  add_node(nil)
  self.number_of_nodes = no
  end
end

#input=(input) ⇒ Object



45
46
47
48
49
# File 'lib/fairy/master/c-cat.rb', line 45

def input=(input)
  @main_precat.input = input
#      super(@main_precat)
  start_create_nodes
end

#njob_creation_paramsObject



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

def njob_creation_params
  []
end

#node_class_nameObject



37
38
39
# File 'lib/fairy/master/c-cat.rb', line 37

def node_class_name
  "PIdentity"
end