Class: Elasticity::HiveStep

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from JobFlowStep

#aws_installation_step, included, #requires_installation?, steps_requiring_installation

Constructor Details

#initialize(script) ⇒ HiveStep

Returns a new instance of HiveStep.



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

def initialize(script)
  @name = "Elasticity Hive 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/hive_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/hive_step.rb', line 7

def name
  @name
end

#scriptObject

Returns the value of attribute script.



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

def script
  @script
end

#variablesObject

Returns the value of attribute variables.



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

def variables
  @variables
end

Class Method Details

.aws_installation_stepObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/elasticity/hive_step.rb', line 39

def self.aws_installation_step
  {
    :action_on_failure => 'TERMINATE_JOB_FLOW',
    :hadoop_jar_step => {
      :jar => 's3://elasticmapreduce/libs/script-runner/script-runner.jar',
      :args => [
        's3://elasticmapreduce/libs/hive/hive-script',
          '--base-path',
          's3://elasticmapreduce/libs/hive/',
          '--install-hive',
          '--hive-versions',
          'latest'
      ],
    },
    :name => 'Elasticity - Install Hive'
  }
end

.requires_installation?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/elasticity/hive_step.rb', line 35

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
# File 'lib/elasticity/hive_step.rb', line 19

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