Module: ContainedMr::JobLogic
Overview
Instance Attribute Summary collapse
-
#id ⇒ String
readonly
The job’s unique identifier.
-
#item_count ⇒ Number
readonly
The number of mapper jobs that will be run.
-
#mapper_image_id ⇒ String
readonly
The unique ID of the Docker image used to run the mappers.
-
#name_prefix ⇒ String
readonly
Prepended to Docker objects, for identification purposes.
-
#reducer_image_id ⇒ String
readonly
The unique ID of the Docker image used to run the reducer.
-
#template ⇒ ContainedMr::Template
readonly
The template this job is derived from.
Instance Method Summary collapse
-
#mapper_container_options(i) ⇒ Hash<String, Object>
Params used to create a mapper container.
-
#mapper_image_tag ⇒ String
Tag applied to the Docker image used by the job’s mappers.
-
#mapper_runner(i) ⇒ ContainedMr::Runner
Returns the runner used for a mapper.
-
#reducer_container_options ⇒ Hash<String, Object>
Params used to create a reducer container.
-
#reducer_image_tag ⇒ String
Tag applied to the Docker image used by the job’s reducers.
-
#reducer_runner ⇒ ContainedMr::Runner
Returns the runner used for the reducer.
Instance Attribute Details
#id ⇒ String (readonly)
Returns the job’s unique identifier.
10 11 12 |
# File 'lib/contained_mr/job_logic.rb', line 10 def id @id end |
#item_count ⇒ Number (readonly)
Returns the number of mapper jobs that will be run.
13 14 15 |
# File 'lib/contained_mr/job_logic.rb', line 13 def item_count @item_count end |
#mapper_image_id ⇒ String (readonly)
Returns the unique ID of the Docker image used to run the mappers.
16 17 18 |
# File 'lib/contained_mr/job_logic.rb', line 16 def mapper_image_id @mapper_image_id end |
#name_prefix ⇒ String (readonly)
Returns prepended to Docker objects, for identification purposes.
7 8 9 |
# File 'lib/contained_mr/job_logic.rb', line 7 def name_prefix @name_prefix end |
#reducer_image_id ⇒ String (readonly)
Returns the unique ID of the Docker image used to run the reducer.
19 20 21 |
# File 'lib/contained_mr/job_logic.rb', line 19 def reducer_image_id @reducer_image_id end |
#template ⇒ ContainedMr::Template (readonly)
Returns the template this job is derived from.
4 5 6 |
# File 'lib/contained_mr/job_logic.rb', line 4 def template @template end |
Instance Method Details
#mapper_container_options(i) ⇒ Hash<String, Object>
Returns params used to create a mapper container.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/contained_mr/job_logic.rb', line 53 def (i) ulimits = @mapper_options[:ulimits].map do |k, v| { "Name" => k.to_s, "Soft" => v, "Hard" => v } end env = @template.mapper_env i env.push "affinity:image==#{mapper_image_tag}" { 'name' => "#{@name_prefix}_mapper.#{@id}.#{i}", 'Image' => mapper_image_tag, 'Hostname' => "#{i}.mapper", 'Domainname' => '', 'Labels' => { 'contained_mr.ctl' => @name_prefix }, 'Env' => env, 'Ulimits' => ulimits, 'NetworkDisabled' => true, 'ExposedPorts' => {}, 'HostConfig' => container_host_config(@mapper_options), } end |
#mapper_image_tag ⇒ String
Returns tag applied to the Docker image used by the job’s mappers.
43 44 45 |
# File 'lib/contained_mr/job_logic.rb', line 43 def mapper_image_tag "#{@name_prefix}/mapper.#{@id}" end |
#mapper_runner(i) ⇒ ContainedMr::Runner
Returns the runner used for a mapper.
26 27 28 29 30 31 |
# File 'lib/contained_mr/job_logic.rb', line 26 def mapper_runner(i) if i < 1 || i > @item_count raise ArgumentError, "Invalid mapper number #{i}" end @mappers[i - 1] end |
#reducer_container_options ⇒ Hash<String, Object>
Returns params used to create a reducer container.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/contained_mr/job_logic.rb', line 73 def ulimits = @reducer_options[:ulimits].map do |k, v| { "Name" => k.to_s, "Soft" => v, "Hard" => v } end env = @template.reducer_env env.push "affinity:image==#{reducer_image_tag}" { 'name' => "#{@name_prefix}_reducer.#{@id}", 'Image' => reducer_image_tag, 'Hostname' => 'reducer', 'Domainname' => '', 'Labels' => { 'contained_mr.ctl' => @name_prefix }, 'Env' => env, 'Ulimits' => ulimits, 'NetworkDisabled' => true, 'ExposedPorts' => {}, 'HostConfig' => container_host_config(@reducer_options), } end |
#reducer_image_tag ⇒ String
Returns tag applied to the Docker image used by the job’s reducers.
48 49 50 |
# File 'lib/contained_mr/job_logic.rb', line 48 def reducer_image_tag "#{@name_prefix}/reducer.#{@id}" end |
#reducer_runner ⇒ ContainedMr::Runner
Returns the runner used for the reducer.
37 38 39 |
# File 'lib/contained_mr/job_logic.rb', line 37 def reducer_runner @reducer end |