Class: Hasta::EmrNode

Inherits:
Object
  • Object
show all
Defined in:
lib/hasta/emr_node.rb

Overview

Models the Amazon Data Pipeline configuration details for the EMR job that is being tested

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ EmrNode

Returns a new instance of EmrNode.



63
64
65
# File 'lib/hasta/emr_node.rb', line 63

def initialize(attributes)
  @attributes = attributes
end

Class Method Details

.from_json(json, scheduled_start_time = Time.now) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hasta/emr_node.rb', line 9

def from_json(json, scheduled_start_time = Time.now)
  command_line = parse_step_line(json['step'])

  new(
    :id => json['id'],
    :input_paths => command_line['input'],
    :output_path => command_line['output'].first,
    :mapper => command_line['mapper'].first,
    :reducer => command_line['reducer'].first,
    :cache_files => command_line['cacheFile'],
    :env => command_line['cmdenv'],
    :scheduled_start_time => scheduled_start_time
  )
end

Instance Method Details

#cache_filesObject



87
88
89
90
# File 'lib/hasta/emr_node.rb', line 87

def cache_files
  files = attributes[:cache_files]
  @cache_files ||= Hash[files.map { |value| interpolate(value).split('#').reverse }]
end

#envObject



92
93
94
# File 'lib/hasta/emr_node.rb', line 92

def env
  @env ||= Hash[attributes[:env].map { |value| value.split('=') }]
end

#idObject



67
68
69
# File 'lib/hasta/emr_node.rb', line 67

def id
  attributes[:id]
end

#input_pathsObject



71
72
73
# File 'lib/hasta/emr_node.rb', line 71

def input_paths
  @input_path ||= attributes[:input_paths].map { |path| interpolate(path) }
end

#mapperObject



79
80
81
# File 'lib/hasta/emr_node.rb', line 79

def mapper
  attributes[:mapper]
end

#output_pathObject



75
76
77
# File 'lib/hasta/emr_node.rb', line 75

def output_path
  @output_path ||= interpolate(attributes[:output_path])
end

#reducerObject



83
84
85
# File 'lib/hasta/emr_node.rb', line 83

def reducer
  attributes[:reducer]
end