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

Instance Method Summary collapse

Instance Attribute Details

#idString (readonly)



7
8
9
# File 'lib/contained_mr/template_logic.rb', line 7

def id
  @id
end

#image_idString (readonly)



14
15
16
# File 'lib/contained_mr/template_logic.rb', line 14

def image_id
  @image_id
end

#item_countNumber (readonly)



10
11
12
# File 'lib/contained_mr/template_logic.rb', line 10

def item_count
  @item_count
end

#name_prefixString (readonly)



4
5
6
# File 'lib/contained_mr/template_logic.rb', line 4

def name_prefix
  @name_prefix
end

Instance Method Details

#image_tagString



40
41
42
# File 'lib/contained_mr/template_logic.rb', line 40

def image_tag
  "#{@name_prefix}/base.#{@id}"
end

#mapper_dockerfileString

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_pathString



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, json_options)
  job_class.new self, id, json_options
end

#reducer_dockerfileString

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_envArray<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_pathString



65
66
67
# File 'lib/contained_mr/template_logic.rb', line 65

def reducer_output_path
  (@_definition['reducer'] || {})['output'] || '/output'
end