Module: ContainedMr::RunnerLogic

Included in:
Mock::Runner, Runner
Defined in:
lib/contained_mr/runner_logic.rb

Overview

Logic shared by Runner and Mock::Runner.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#container_idString (readonly)

Returns the unique ID of the Docker container used to run the mapper / reducer; this is nil.

Returns:

  • (String)

    the unique ID of the Docker container used to run the mapper / reducer; this is nil



22
23
24
# File 'lib/contained_mr/runner_logic.rb', line 22

def container_id
  @container_id
end

#ended_atTime (readonly)

Returns the time when the mapper or reducer stops running or is killed.

Returns:

  • (Time)

    the time when the mapper or reducer stops running or is killed



6
7
8
# File 'lib/contained_mr/runner_logic.rb', line 6

def ended_at
  @ended_at
end

#outputString (readonly)

Returns the contents of the file.

Returns:

  • (String)

    the contents of the file



18
19
20
# File 'lib/contained_mr/runner_logic.rb', line 18

def output
  @output
end

#started_atTime (readonly)

Returns the time when the mapper or reducer starts running.

Returns:

  • (Time)

    the time when the mapper or reducer starts running



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

def started_at
  @started_at
end

#status_codeNumber (readonly)

Returns the time.

Returns:

  • (Number)

    the time



8
9
10
# File 'lib/contained_mr/runner_logic.rb', line 8

def status_code
  @status_code
end

#stderrString (readonly)

Returns the data written by the mapper or reducer to stderr.

Returns:

  • (String)

    the data written by the mapper or reducer to stderr



16
17
18
# File 'lib/contained_mr/runner_logic.rb', line 16

def stderr
  @stderr
end

#stdoutString (readonly)

Returns the data written by the mapper or reducer to stdout.

Returns:

  • (String)

    the data written by the mapper or reducer to stdout



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

def stdout
  @stdout
end

#timed_outBoolean (readonly)

Returns true if the mapper or reducer was terminated due to running for too long.

Returns:

  • (Boolean)

    true if the mapper or reducer was terminated due to running for too long



11
12
13
# File 'lib/contained_mr/runner_logic.rb', line 11

def timed_out
  @timed_out
end

Instance Method Details

#json_fileHash<Symbol, Object>

The information written to the mapper status files given to the reducer.

This is saved in files named 1.json, 2.json, … provided to the reducer.

Returns:

  • (Hash<Symbol, Object>)

    JSON-compatible representation of the runner’s information



35
36
37
# File 'lib/contained_mr/runner_logic.rb', line 35

def json_file
  { ran_for: ran_for, exit_code: status_code, timed_out: timed_out }
end

#ran_forNumber

Returns the container’s running time, in seconds.

Returns:

  • (Number)

    the container’s running time, in seconds



25
26
27
# File 'lib/contained_mr/runner_logic.rb', line 25

def ran_for
  started_at && ended_at && (ended_at - started_at)
end