Class: Elasticity::PigStep

Inherits:
Object
  • Object
show all
Includes:
JobFlowStep
Defined in:
lib/elasticity/pig_step.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from JobFlowStep

#aws_installation_step_name, #aws_installation_steps, included, #requires_installation?, steps_requiring_installation

Constructor Details

#initialize(script) ⇒ PigStep

Returns a new instance of PigStep



12
13
14
15
16
17
# File 'lib/elasticity/pig_step.rb', line 12

def initialize(script)
  @name = "Elasticity Pig Step (#{script})"
  @script = script
  @variables = {}
  @action_on_failure = 'TERMINATE_JOB_FLOW'
end

Instance Attribute Details

#action_on_failureObject

Returns the value of attribute action_on_failure



10
11
12
# File 'lib/elasticity/pig_step.rb', line 10

def action_on_failure
  @action_on_failure
end

#nameObject

Returns the value of attribute name



7
8
9
# File 'lib/elasticity/pig_step.rb', line 7

def name
  @name
end

#scriptObject

Returns the value of attribute script



8
9
10
# File 'lib/elasticity/pig_step.rb', line 8

def script
  @script
end

#variablesObject

Returns the value of attribute variables



9
10
11
# File 'lib/elasticity/pig_step.rb', line 9

def variables
  @variables
end

Class Method Details

.aws_installation_step_nameObject



40
41
42
# File 'lib/elasticity/pig_step.rb', line 40

def self.aws_installation_step_name
  'Elasticity - Install Pig'
end

.aws_installation_stepsObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/elasticity/pig_step.rb', line 44

def self.aws_installation_steps
  [
    {
      :action_on_failure => 'TERMINATE_JOB_FLOW',
      :hadoop_jar_step => {
        :jar => 's3://elasticmapreduce/libs/script-runner/script-runner.jar',
        :args => [
          's3://elasticmapreduce/libs/pig/pig-script',
          '--base-path',
          's3://elasticmapreduce/libs/pig/',
          '--install-pig'
        ],
      },
      :name => aws_installation_step_name
    }
  ]
end

.requires_installation?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/elasticity/pig_step.rb', line 36

def self.requires_installation?
  true
end

Instance Method Details

#to_aws_step(job_flow) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/elasticity/pig_step.rb', line 19

def to_aws_step(job_flow)
  args = %w(s3://elasticmapreduce/libs/pig/pig-script --run-pig-script --args)
  @variables.keys.sort.each do |name|
    args.concat(['-p', "#{name}=#{@variables[name]}"])
  end
  args.concat(['-p', "E_PARALLELS=#{parallels(job_flow.slave_instance_type, job_flow.instance_count)}"])
  args << @script
  {
    :action_on_failure => @action_on_failure,
    :hadoop_jar_step => {
      :jar => 's3://elasticmapreduce/libs/script-runner/script-runner.jar',
      :args => args,
    },
    :name => @name
  }
end