Class: ContainedMr::Template

Inherits:
Object
  • Object
show all
Includes:
TemplateLogic
Defined in:
lib/contained_mr/template.rb

Overview

A template is used to spawn multiple Map-Reduce jobs.

Instance Attribute Summary

Attributes included from TemplateLogic

#id, #image_id, #item_count, #name_prefix

Instance Method Summary collapse

Methods included from TemplateLogic

#image_tag, #mapper_dockerfile, #mapper_env, #mapper_output_path, #new_job, #reducer_dockerfile, #reducer_env, #reducer_output_path

Constructor Details

#initialize(name_prefix, id, zip_io) ⇒ Template

Returns a new instance of Template.

See Also:

  • ContainedMr::Template.{ContainedMr{ContainedMr.new_template}


13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/contained_mr/template.rb', line 13

def initialize(name_prefix, id, zip_io)
  @name_prefix = name_prefix
  @id = id
  @image_id = nil
  @item_count = nil
  @_definition = nil

  tar_buffer = StringIO.new
  process_zip zip_io, tar_buffer
  tar_buffer.rewind
  build_image tar_buffer
end

Instance Method Details

#destroy!ContainedMr::Template

Tears down the template’s state.

This removes the template’s base Docker image.

Returns:



31
32
33
34
35
36
37
38
39
# File 'lib/contained_mr/template.rb', line 31

def destroy!
  unless @image_id.nil?
    # HACK(pwnall): Trick docker-api into issuing a DELETE request by tag.
    image = Docker::Image.new Docker.connection, 'id' => image_tag
    image.remove
    @image_id = nil
  end
  self
end

#job_classClass

The class instantiated by ContainedMr::TemplateLogic#new_job.

Returns:

  • (Class)

    by default Job; tests might want to stub this method and have it return Mock::Job



45
46
47
# File 'lib/contained_mr/template.rb', line 45

def job_class
  ContainedMr::Job
end