Class: Elasticity::HiveStep

Inherits:
Object
  • 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_name, #aws_installation_steps, 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_step_nameObject



39
40
41
# File 'lib/elasticity/hive_step.rb', line 39

def self.aws_installation_step_name
  'Elasticity - Install Hive'
end

.aws_installation_stepsObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/elasticity/hive_step.rb', line 43

def self.aws_installation_steps
  steps = [
    {
      :action_on_failure => 'TERMINATE_JOB_FLOW',
      :hadoop_jar_step => {
        :jar => 's3://elasticmapreduce/libs/script-runner/script-runner.jar',
        :args => %w(s3://elasticmapreduce/libs/hive/hive-script --base-path s3://elasticmapreduce/libs/hive/ --install-hive --hive-versions latest)
      },
      :name => aws_installation_step_name
    }
  ]
  if Elasticity.configuration.hive_site
    steps << {
      :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-site',
          "--hive-site=#{Elasticity.configuration.hive_site}",
          '--hive-versions',
          'latest'
        ],
      },
      :name => 'Elasticity - Configure Hive via Hive Site'
    }
  end
  steps
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(_) ⇒ 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(_)
  args = %w(s3://elasticmapreduce/libs/hive/hive-script --base-path s3://elasticmapreduce/libs/hive/ --hive-versions latest --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