elasticity 1.5 → 2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rspec +2 -1
- data/.rvmrc +1 -1
- data/HISTORY.md +47 -24
- data/LICENSE +1 -1
- data/README.md +165 -317
- data/Rakefile +4 -3
- data/elasticity.gemspec +3 -5
- data/lib/elasticity.rb +10 -5
- data/lib/elasticity/aws_request.rb +81 -20
- data/lib/elasticity/custom_jar_step.rb +33 -0
- data/lib/elasticity/emr.rb +45 -117
- data/lib/elasticity/hadoop_bootstrap_action.rb +27 -0
- data/lib/elasticity/hive_step.rb +57 -0
- data/lib/elasticity/job_flow.rb +109 -39
- data/lib/elasticity/job_flow_status.rb +53 -0
- data/lib/elasticity/job_flow_status_step.rb +35 -0
- data/lib/elasticity/job_flow_step.rb +17 -25
- data/lib/elasticity/pig_step.rb +82 -0
- data/lib/elasticity/support/conditional_raise.rb +23 -0
- data/lib/elasticity/version.rb +1 -1
- data/spec/lib/elasticity/aws_request_spec.rb +159 -51
- data/spec/lib/elasticity/custom_jar_step_spec.rb +59 -0
- data/spec/lib/elasticity/emr_spec.rb +231 -762
- data/spec/lib/elasticity/hadoop_bootstrap_action_spec.rb +26 -0
- data/spec/lib/elasticity/hive_step_spec.rb +74 -0
- data/spec/lib/elasticity/job_flow_integration_spec.rb +197 -0
- data/spec/lib/elasticity/job_flow_spec.rb +369 -138
- data/spec/lib/elasticity/job_flow_status_spec.rb +147 -0
- data/spec/lib/elasticity/job_flow_status_step_spec.rb +73 -0
- data/spec/lib/elasticity/job_flow_step_spec.rb +26 -64
- data/spec/lib/elasticity/pig_step_spec.rb +104 -0
- data/spec/lib/elasticity/support/conditional_raise_spec.rb +35 -0
- data/spec/spec_helper.rb +1 -50
- data/spec/support/be_a_hash_including_matcher.rb +35 -0
- metadata +101 -119
- data/.autotest +0 -2
- data/lib/elasticity/custom_jar_job.rb +0 -38
- data/lib/elasticity/hive_job.rb +0 -69
- data/lib/elasticity/pig_job.rb +0 -109
- data/lib/elasticity/simple_job.rb +0 -51
- data/spec/fixtures/vcr_cassettes/add_instance_groups/one_group_successful.yml +0 -44
- data/spec/fixtures/vcr_cassettes/add_instance_groups/one_group_unsuccessful.yml +0 -41
- data/spec/fixtures/vcr_cassettes/add_jobflow_steps/add_multiple_steps.yml +0 -266
- data/spec/fixtures/vcr_cassettes/custom_jar_job/cloudburst.yml +0 -41
- data/spec/fixtures/vcr_cassettes/describe_jobflows/all_jobflows.yml +0 -75
- data/spec/fixtures/vcr_cassettes/direct/terminate_jobflow.yml +0 -38
- data/spec/fixtures/vcr_cassettes/hive_job/hive_ads.yml +0 -41
- data/spec/fixtures/vcr_cassettes/modify_instance_groups/set_instances_to_3.yml +0 -38
- data/spec/fixtures/vcr_cassettes/pig_job/apache_log_reports.yml +0 -41
- data/spec/fixtures/vcr_cassettes/pig_job/apache_log_reports_with_bootstrap.yml +0 -41
- data/spec/fixtures/vcr_cassettes/run_jobflow/word_count.yml +0 -41
- data/spec/fixtures/vcr_cassettes/set_termination_protection/nonexistent_job_flows.yml +0 -41
- data/spec/fixtures/vcr_cassettes/set_termination_protection/protect_multiple_job_flows.yml +0 -38
- data/spec/fixtures/vcr_cassettes/terminate_jobflows/one_jobflow.yml +0 -38
- data/spec/lib/elasticity/custom_jar_job_spec.rb +0 -118
- data/spec/lib/elasticity/hive_job_spec.rb +0 -90
- data/spec/lib/elasticity/pig_job_spec.rb +0 -226
data/spec/spec_helper.rb
CHANGED
@@ -1,56 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
|
-
|
4
|
-
require 'vcr'
|
5
|
-
|
6
3
|
require 'elasticity'
|
7
4
|
|
8
5
|
ENV["RAILS_ENV"] ||= 'test'
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
uri_regexp_matcher = lambda do |real_request, recorded_request|
|
13
|
-
real_request.uri =~ recorded_request.uri
|
14
|
-
end
|
15
|
-
|
16
|
-
VCR.configure do |c|
|
17
|
-
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
18
|
-
c.hook_into :webmock
|
19
|
-
c.default_cassette_options = {
|
20
|
-
:match_requests_on => [:method, uri_regexp_matcher]
|
21
|
-
}
|
22
|
-
c.before_http_request do |_|
|
23
|
-
require_aws_credentials unless VCR.current_cassette.record_mode == :none
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
RSpec.configure do |c|
|
28
|
-
c.extend VCR::RSpec::Macros
|
29
|
-
end
|
30
|
-
|
31
|
-
AWS_ACCESS_KEY_ID = ENV['AWS_ACCESS_KEY_ID'] ||= 'default'
|
32
|
-
AWS_SECRET_KEY = ENV['AWS_SECRET_KEY'] ||= 'default'
|
33
|
-
|
34
|
-
def require_aws_credentials
|
35
|
-
if AWS_ACCESS_KEY_ID == 'default' && AWS_SECRET_KEY == 'default'
|
36
|
-
puts "\n\e[33m**********************************************************************************************"
|
37
|
-
puts "\e[32mIf you want to record new cassettes, you'll need to provide a set of AWS credentials so"
|
38
|
-
puts "Elasticity can interact with EMR. These keys can be found on your AWS Account > Security"
|
39
|
-
puts "Credentials page, at the following URL:"
|
40
|
-
puts ""
|
41
|
-
puts " \e[0;1mhttps://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&action=access-key"
|
42
|
-
puts ""
|
43
|
-
bourne = !ENV['SHELL'].nil? && ENV['SHELL'] =~ /(bash|ksh|zsh)/
|
44
|
-
if bourne
|
45
|
-
puts "\e[32mbash, zsh, ksh:"
|
46
|
-
puts " export AWS_ACCESS_KEY_ID=01234"
|
47
|
-
puts " export AWS_SECRET_KEY=56789"
|
48
|
-
else
|
49
|
-
puts "\e[32mcsh, tcsh:"
|
50
|
-
puts " setenv AWS_ACCESS_KEY_ID 01234"
|
51
|
-
puts " setenv AWS_SECRET_KEY 56789"
|
52
|
-
end
|
53
|
-
puts "\e[33m**********************************************************************************************\n"
|
54
|
-
exit
|
55
|
-
end
|
56
|
-
end
|
7
|
+
Dir[File.join(File.dirname(__FILE__), "support", "**", "*.rb")].each { |f| require f }
|
@@ -0,0 +1,35 @@
|
|
1
|
+
RSpec::Matchers.define :be_a_hash_including do |expected|
|
2
|
+
match do |actual|
|
3
|
+
next false unless actual.is_a? Hash
|
4
|
+
next false unless expected.is_a? Hash
|
5
|
+
expected.keys.each do |key|
|
6
|
+
break false if actual[key] != expected[key]
|
7
|
+
true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe :be_a_hash_including do
|
13
|
+
|
14
|
+
context 'when actual is not a Hash' do
|
15
|
+
subject { 'I AM NOT A HASH' }
|
16
|
+
it { should_not be_a_hash_including({}) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when expected is not a Hash' do
|
20
|
+
subject { {} }
|
21
|
+
it { should_not be_a_hash_including('') }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when expected is included in actual' do
|
25
|
+
subject {{:actual_key1 => 'value1'}}
|
26
|
+
it { should be_a_hash_including({:actual_key1 => 'value1'})}
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when expected is not included in actual' do
|
30
|
+
subject {{:actual_key1 => 'value1'}}
|
31
|
+
it { should_not be_a_hash_including({:actual_key3 => 'value3'})}
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
metadata
CHANGED
@@ -1,94 +1,87 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticity
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '2.0'
|
4
5
|
prerelease:
|
5
|
-
version: "1.5"
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Robert Slifka
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-07-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: rest-client
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
25
22
|
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: nokogiri
|
29
23
|
prerelease: false
|
30
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: nokogiri
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
31
33
|
none: false
|
32
|
-
requirements:
|
33
|
-
- -
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version:
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
36
38
|
type: :runtime
|
37
|
-
version_requirements: *id002
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: rake
|
40
39
|
prerelease: false
|
41
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
41
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version:
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
name: rspec
|
51
|
-
prerelease: false
|
52
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
53
49
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version:
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
58
54
|
type: :development
|
59
|
-
version_requirements: *id004
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: vcr
|
62
55
|
prerelease: false
|
63
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
57
|
none: false
|
65
|
-
requirements:
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
66
67
|
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.10.0
|
69
70
|
type: :development
|
70
|
-
version_requirements: *id005
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
|
-
name: webmock
|
73
71
|
prerelease: false
|
74
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
73
|
none: false
|
76
|
-
requirements:
|
74
|
+
requirements:
|
77
75
|
- - ~>
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version:
|
80
|
-
|
81
|
-
|
82
|
-
description: Programmatic access to Amazon's Elastic Map Reduce service, driven by the Sharethrough team's requirements for belting out EMR jobs.
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.10.0
|
78
|
+
description: Streamlined, Programmatic access to Amazon's Elastic Map Reduce service,
|
79
|
+
driven by the Sharethrough team's requirements for belting out EMR jobs.
|
83
80
|
email:
|
84
81
|
executables: []
|
85
|
-
|
86
82
|
extensions: []
|
87
|
-
|
88
83
|
extra_rdoc_files: []
|
89
|
-
|
90
|
-
files:
|
91
|
-
- .autotest
|
84
|
+
files:
|
92
85
|
- .gitignore
|
93
86
|
- .rspec
|
94
87
|
- .rvmrc
|
@@ -101,84 +94,73 @@ files:
|
|
101
94
|
- elasticity.gemspec
|
102
95
|
- lib/elasticity.rb
|
103
96
|
- lib/elasticity/aws_request.rb
|
104
|
-
- lib/elasticity/
|
97
|
+
- lib/elasticity/custom_jar_step.rb
|
105
98
|
- lib/elasticity/emr.rb
|
106
|
-
- lib/elasticity/
|
99
|
+
- lib/elasticity/hadoop_bootstrap_action.rb
|
100
|
+
- lib/elasticity/hive_step.rb
|
107
101
|
- lib/elasticity/job_flow.rb
|
102
|
+
- lib/elasticity/job_flow_status.rb
|
103
|
+
- lib/elasticity/job_flow_status_step.rb
|
108
104
|
- lib/elasticity/job_flow_step.rb
|
109
|
-
- lib/elasticity/
|
110
|
-
- lib/elasticity/
|
105
|
+
- lib/elasticity/pig_step.rb
|
106
|
+
- lib/elasticity/support/conditional_raise.rb
|
111
107
|
- lib/elasticity/version.rb
|
112
|
-
- spec/fixtures/vcr_cassettes/add_instance_groups/one_group_successful.yml
|
113
|
-
- spec/fixtures/vcr_cassettes/add_instance_groups/one_group_unsuccessful.yml
|
114
|
-
- spec/fixtures/vcr_cassettes/add_jobflow_steps/add_multiple_steps.yml
|
115
|
-
- spec/fixtures/vcr_cassettes/custom_jar_job/cloudburst.yml
|
116
|
-
- spec/fixtures/vcr_cassettes/describe_jobflows/all_jobflows.yml
|
117
|
-
- spec/fixtures/vcr_cassettes/direct/terminate_jobflow.yml
|
118
|
-
- spec/fixtures/vcr_cassettes/hive_job/hive_ads.yml
|
119
|
-
- spec/fixtures/vcr_cassettes/modify_instance_groups/set_instances_to_3.yml
|
120
|
-
- spec/fixtures/vcr_cassettes/pig_job/apache_log_reports.yml
|
121
|
-
- spec/fixtures/vcr_cassettes/pig_job/apache_log_reports_with_bootstrap.yml
|
122
|
-
- spec/fixtures/vcr_cassettes/run_jobflow/word_count.yml
|
123
|
-
- spec/fixtures/vcr_cassettes/set_termination_protection/nonexistent_job_flows.yml
|
124
|
-
- spec/fixtures/vcr_cassettes/set_termination_protection/protect_multiple_job_flows.yml
|
125
|
-
- spec/fixtures/vcr_cassettes/terminate_jobflows/one_jobflow.yml
|
126
108
|
- spec/lib/elasticity/aws_request_spec.rb
|
127
|
-
- spec/lib/elasticity/
|
109
|
+
- spec/lib/elasticity/custom_jar_step_spec.rb
|
128
110
|
- spec/lib/elasticity/emr_spec.rb
|
129
|
-
- spec/lib/elasticity/
|
111
|
+
- spec/lib/elasticity/hadoop_bootstrap_action_spec.rb
|
112
|
+
- spec/lib/elasticity/hive_step_spec.rb
|
113
|
+
- spec/lib/elasticity/job_flow_integration_spec.rb
|
130
114
|
- spec/lib/elasticity/job_flow_spec.rb
|
115
|
+
- spec/lib/elasticity/job_flow_status_spec.rb
|
116
|
+
- spec/lib/elasticity/job_flow_status_step_spec.rb
|
131
117
|
- spec/lib/elasticity/job_flow_step_spec.rb
|
132
|
-
- spec/lib/elasticity/
|
118
|
+
- spec/lib/elasticity/pig_step_spec.rb
|
119
|
+
- spec/lib/elasticity/support/conditional_raise_spec.rb
|
133
120
|
- spec/spec_helper.rb
|
134
|
-
|
121
|
+
- spec/support/be_a_hash_including_matcher.rb
|
135
122
|
homepage: http://www.github.com/rslifka/elasticity
|
136
123
|
licenses: []
|
137
|
-
|
138
124
|
post_install_message:
|
139
125
|
rdoc_options: []
|
140
|
-
|
141
|
-
require_paths:
|
126
|
+
require_paths:
|
142
127
|
- lib
|
143
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
129
|
none: false
|
145
|
-
requirements:
|
146
|
-
- -
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
version:
|
149
|
-
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
hash: 4070655408797594419
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
138
|
none: false
|
151
|
-
requirements:
|
152
|
-
- -
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
version:
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
segments:
|
144
|
+
- 0
|
145
|
+
hash: 4070655408797594419
|
155
146
|
requirements: []
|
156
|
-
|
157
147
|
rubyforge_project:
|
158
|
-
rubygems_version: 1.
|
148
|
+
rubygems_version: 1.8.24
|
159
149
|
signing_key:
|
160
150
|
specification_version: 3
|
161
|
-
summary:
|
162
|
-
test_files:
|
163
|
-
- spec/fixtures/vcr_cassettes/add_instance_groups/one_group_successful.yml
|
164
|
-
- spec/fixtures/vcr_cassettes/add_instance_groups/one_group_unsuccessful.yml
|
165
|
-
- spec/fixtures/vcr_cassettes/add_jobflow_steps/add_multiple_steps.yml
|
166
|
-
- spec/fixtures/vcr_cassettes/custom_jar_job/cloudburst.yml
|
167
|
-
- spec/fixtures/vcr_cassettes/describe_jobflows/all_jobflows.yml
|
168
|
-
- spec/fixtures/vcr_cassettes/direct/terminate_jobflow.yml
|
169
|
-
- spec/fixtures/vcr_cassettes/hive_job/hive_ads.yml
|
170
|
-
- spec/fixtures/vcr_cassettes/modify_instance_groups/set_instances_to_3.yml
|
171
|
-
- spec/fixtures/vcr_cassettes/pig_job/apache_log_reports.yml
|
172
|
-
- spec/fixtures/vcr_cassettes/pig_job/apache_log_reports_with_bootstrap.yml
|
173
|
-
- spec/fixtures/vcr_cassettes/run_jobflow/word_count.yml
|
174
|
-
- spec/fixtures/vcr_cassettes/set_termination_protection/nonexistent_job_flows.yml
|
175
|
-
- spec/fixtures/vcr_cassettes/set_termination_protection/protect_multiple_job_flows.yml
|
176
|
-
- spec/fixtures/vcr_cassettes/terminate_jobflows/one_jobflow.yml
|
151
|
+
summary: Streamlined, programmatic access to Amazon's Elastic Map Reduce service.
|
152
|
+
test_files:
|
177
153
|
- spec/lib/elasticity/aws_request_spec.rb
|
178
|
-
- spec/lib/elasticity/
|
154
|
+
- spec/lib/elasticity/custom_jar_step_spec.rb
|
179
155
|
- spec/lib/elasticity/emr_spec.rb
|
180
|
-
- spec/lib/elasticity/
|
156
|
+
- spec/lib/elasticity/hadoop_bootstrap_action_spec.rb
|
157
|
+
- spec/lib/elasticity/hive_step_spec.rb
|
158
|
+
- spec/lib/elasticity/job_flow_integration_spec.rb
|
181
159
|
- spec/lib/elasticity/job_flow_spec.rb
|
160
|
+
- spec/lib/elasticity/job_flow_status_spec.rb
|
161
|
+
- spec/lib/elasticity/job_flow_status_step_spec.rb
|
182
162
|
- spec/lib/elasticity/job_flow_step_spec.rb
|
183
|
-
- spec/lib/elasticity/
|
163
|
+
- spec/lib/elasticity/pig_step_spec.rb
|
164
|
+
- spec/lib/elasticity/support/conditional_raise_spec.rb
|
184
165
|
- spec/spec_helper.rb
|
166
|
+
- spec/support/be_a_hash_including_matcher.rb
|
data/.autotest
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
module Elasticity
|
2
|
-
|
3
|
-
class CustomJarJob < Elasticity::SimpleJob
|
4
|
-
|
5
|
-
def initialize(aws_access_key_id, aws_secret_access_key)
|
6
|
-
super
|
7
|
-
@name = "Elasticity Custom Jar Job"
|
8
|
-
end
|
9
|
-
|
10
|
-
def run(jar, arguments=nil)
|
11
|
-
jobflow_config = {
|
12
|
-
:name => @name,
|
13
|
-
:instances => {
|
14
|
-
:ec2_key_name => @ec2_key_name,
|
15
|
-
:hadoop_version => @hadoop_version,
|
16
|
-
:instance_count => @instance_count,
|
17
|
-
:master_instance_type => @master_instance_type,
|
18
|
-
:slave_instance_type => @slave_instance_type,
|
19
|
-
},
|
20
|
-
:steps => [
|
21
|
-
{
|
22
|
-
:action_on_failure => @action_on_failure,
|
23
|
-
:hadoop_jar_step => {
|
24
|
-
:jar => jar
|
25
|
-
},
|
26
|
-
:name => "Execute Custom Jar"
|
27
|
-
}
|
28
|
-
]
|
29
|
-
}
|
30
|
-
|
31
|
-
jobflow_config[:steps].first[:hadoop_jar_step][:args] = arguments if arguments
|
32
|
-
|
33
|
-
run_job(jobflow_config)
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
data/lib/elasticity/hive_job.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
module Elasticity
|
2
|
-
|
3
|
-
# HiveJob allows you quickly easily kick off a Hive jobflow without
|
4
|
-
# having to understand the entirety of the EMR API.
|
5
|
-
class HiveJob < Elasticity::SimpleJob
|
6
|
-
|
7
|
-
def initialize(aws_access_key_id, aws_secret_access_key)
|
8
|
-
super
|
9
|
-
@name = "Elasticity Hive Job"
|
10
|
-
end
|
11
|
-
|
12
|
-
# Run the specified Hive script with the specified variables.
|
13
|
-
#
|
14
|
-
# hive = Elasticity::HiveJob.new("access", "secret")
|
15
|
-
# jobflow_id = hive.run('s3n://slif-hive/test.q', {
|
16
|
-
# 'SCRIPTS' => 's3n://slif-test/scripts',
|
17
|
-
# 'OUTPUT' => 's3n://slif-test/output',
|
18
|
-
# 'XREFS' => 's3n://slif-test/xrefs'
|
19
|
-
# })
|
20
|
-
#
|
21
|
-
# The variables are accessible within your Hive scripts by using the
|
22
|
-
# standard ${NAME} syntax. E.g.
|
23
|
-
#
|
24
|
-
# ADD JAR ${SCRIPTS}/jsonserde.jar;
|
25
|
-
def run(hive_script, hive_variables={})
|
26
|
-
script_arguments = ["s3://elasticmapreduce/libs/hive/hive-script", "--run-hive-script", "--args"]
|
27
|
-
script_arguments.concat(["-f", hive_script])
|
28
|
-
hive_variables.each do |variable_name, value|
|
29
|
-
script_arguments.concat(["-d", "#{variable_name}=#{value}"])
|
30
|
-
end
|
31
|
-
jobflow_config = {
|
32
|
-
:name => @name,
|
33
|
-
:instances => {
|
34
|
-
:ec2_key_name => @ec2_key_name,
|
35
|
-
:hadoop_version => @hadoop_version,
|
36
|
-
:instance_count => @instance_count,
|
37
|
-
:master_instance_type => @master_instance_type,
|
38
|
-
:slave_instance_type => @slave_instance_type,
|
39
|
-
},
|
40
|
-
:steps => [
|
41
|
-
{
|
42
|
-
:action_on_failure => "TERMINATE_JOB_FLOW",
|
43
|
-
:hadoop_jar_step => {
|
44
|
-
:jar => "s3://elasticmapreduce/libs/script-runner/script-runner.jar",
|
45
|
-
:args => [
|
46
|
-
"s3://elasticmapreduce/libs/hive/hive-script",
|
47
|
-
"--base-path", "s3://elasticmapreduce/libs/hive/",
|
48
|
-
"--install-hive"
|
49
|
-
],
|
50
|
-
},
|
51
|
-
:name => "Setup Hive"
|
52
|
-
},
|
53
|
-
{
|
54
|
-
:action_on_failure => @action_on_failure,
|
55
|
-
:hadoop_jar_step => {
|
56
|
-
:jar => "s3://elasticmapreduce/libs/script-runner/script-runner.jar",
|
57
|
-
:args => script_arguments,
|
58
|
-
},
|
59
|
-
:name => "Run Hive Script"
|
60
|
-
}
|
61
|
-
]
|
62
|
-
}
|
63
|
-
|
64
|
-
run_job(jobflow_config)
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|