Module: ContainedMr::TemplateLogic
- Included in:
- Mock::Template, Template
- Defined in:
- lib/contained_mr/template_logic.rb
Overview
Logic shared by Template and Mock::Template.
Instance Attribute Summary collapse
-
#id ⇒ String
readonly
The template’s unique identifier.
-
#image_id ⇒ String
readonly
Image_id the unique ID of the Docker image used as a base for images built by jobs derived from this template.
-
#item_count ⇒ Number
readonly
The number of mapper jobs specified by this template.
-
#name_prefix ⇒ String
readonly
Prepended to Docker objects, for identification purposes.
Instance Method Summary collapse
-
#image_tag ⇒ String
Tag applied to the template’s base Docker image.
-
#mapper_dockerfile ⇒ String
Computes the Dockerfile used to build a job’s mapper image.
-
#mapper_env(i) ⇒ Array<String>
Computes the environment variables to be set in a mapper container.
-
#mapper_output_path ⇒ String
The map output’s path in the mapper Docker container.
-
#new_job(id, json_options) ⇒ ContainedMr::Job
Creates a job using this template.
-
#reducer_dockerfile ⇒ String
Computes the Dockerfile used to build a job’s reducer image.
-
#reducer_env ⇒ Array<String>
Computes the environment variables to be set in the reducer container.
-
#reducer_output_path ⇒ String
The reducer output’s path in the reducer Docker container.
Instance Attribute Details
#id ⇒ String (readonly)
Returns the template’s unique identifier.
7 8 9 |
# File 'lib/contained_mr/template_logic.rb', line 7 def id @id end |
#image_id ⇒ String (readonly)
Returns image_id the unique ID of the Docker image used as a base for images built by jobs derived from this template.
14 15 16 |
# File 'lib/contained_mr/template_logic.rb', line 14 def image_id @image_id end |
#item_count ⇒ Number (readonly)
Returns the number of mapper jobs specified by this template.
10 11 12 |
# File 'lib/contained_mr/template_logic.rb', line 10 def item_count @item_count end |
#name_prefix ⇒ String (readonly)
Returns prepended to Docker objects, for identification purposes.
4 5 6 |
# File 'lib/contained_mr/template_logic.rb', line 4 def name_prefix @name_prefix end |
Instance Method Details
#image_tag ⇒ String
Returns tag applied to the template’s base Docker image.
40 41 42 |
# File 'lib/contained_mr/template_logic.rb', line 40 def image_tag "#{@name_prefix}/base.#{@id}" end |
#mapper_dockerfile ⇒ String
Computes the Dockerfile used to build a job’s mapper image.
28 29 30 |
# File 'lib/contained_mr/template_logic.rb', line 28 def mapper_dockerfile job_dockerfile @_definition['mapper'] || {}, 'input' end |
#mapper_env(i) ⇒ Array<String>
Computes the environment variables to be set in a mapper container.
48 49 50 |
# File 'lib/contained_mr/template_logic.rb', line 48 def mapper_env(i) [ "ITEM=#{i}", "ITEMS=#{@item_count.to_s}" ] end |
#mapper_output_path ⇒ String
Returns the map output’s path in the mapper Docker container.
60 61 62 |
# File 'lib/contained_mr/template_logic.rb', line 60 def mapper_output_path (@_definition['mapper'] || {})['output'] || '/output' end |
#new_job(id, json_options) ⇒ ContainedMr::Job
Creates a job using this template.
21 22 23 |
# File 'lib/contained_mr/template_logic.rb', line 21 def new_job(id, ) job_class.new self, id, end |
#reducer_dockerfile ⇒ String
Computes the Dockerfile used to build a job’s reducer image.
35 36 37 |
# File 'lib/contained_mr/template_logic.rb', line 35 def reducer_dockerfile job_dockerfile @_definition['reducer'] || {}, '.' end |
#reducer_env ⇒ Array<String>
Computes the environment variables to be set in the reducer container.
55 56 57 |
# File 'lib/contained_mr/template_logic.rb', line 55 def reducer_env [ "ITEMS=#{@item_count.to_s}" ] end |
#reducer_output_path ⇒ String
Returns the reducer output’s path in the reducer Docker container.
65 66 67 |
# File 'lib/contained_mr/template_logic.rb', line 65 def reducer_output_path (@_definition['reducer'] || {})['output'] || '/output' end |