elasticity 6.0.5 → 6.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d313d736b8c2be8bda97c7cba0c200c611b5fc59
4
- data.tar.gz: e0c4afadd4d192770e3c79a67f5c62147425c1dd
3
+ metadata.gz: 9544e6d7a9f5c8b361f07657a2902a0006415c93
4
+ data.tar.gz: 2477d97b8f823248ae6f1d6061f092aa0e5e0747
5
5
  SHA512:
6
- metadata.gz: 2c3c35bdeb9408756f085cc9fc8550c6ca6165fec7134af6a8f639279128cb6bf2a84a067766891ead282e6532adbb5a1a2fa7aff6fa62ed65261171f8fb7f80
7
- data.tar.gz: cbab3121a67c1b7f0d3370f6ee662b7dd308fa0d8c57122e68db1f2b0b1e5a87119533968baadfae8c3e4a5bbd76a94ae28a49f362e276fb42d68e34e9d58e8f
6
+ metadata.gz: 356394fc7e44ec694f8c59f60a90b1f1daaa3a0c2f4b40f55532c89bfcbfce11b59ac70d385936dccb9fb08ee726f645a6b8e010c464dbd4ee147a5f2e174ed0
7
+ data.tar.gz: ffc3be6f66d3218e5a167afb3f4eb4431f0b86f6966d93f62c3ff86d54f4021485d100d04b16e73333970a2f708f2f4f7015977a339c7515bc790a9a1d2d1bf2
data/.ruby-version CHANGED
@@ -1,2 +1 @@
1
1
  2.0.0-p598
2
-
data/.travis.yml CHANGED
@@ -3,3 +3,8 @@ rvm:
3
3
  - 2.0
4
4
  - 2.1
5
5
  - 2.2
6
+ - 2.3.0
7
+ before_install:
8
+ - gem update --system
9
+ - gem --version
10
+ - gem install bundler
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 6.0.6 - February 29, 2016
2
+
3
+ - - Including PR [#20](https://github.com/rslifka/elasticity/pull/120) - "EMR Applications and support for release_label". Thank you [@robert2d](https://github.com/robert2d)!
4
+ -
1
5
  ## 6.0.5 - August 28, 2015
2
6
 
3
7
  - - Including PR [#119](https://github.com/rslifka/elasticity/pull/119) - "Error handling for API rate limiting". Thank you [@robert2d](https://github.com/robert2d)!
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Elasticity provides programmatic access to Amazon's Elastic Map Reduce service. The aim is to conveniently abstract away the complex EMR REST API and make working with job flows more productive and more enjoyable.
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/rslifka/elasticity.png)](http://travis-ci.org/rslifka/elasticity) 2.0.x, 2.1.x, 2.2.x
5
+ [![Build Status](https://secure.travis-ci.org/rslifka/elasticity.png)](http://travis-ci.org/rslifka/elasticity) 2.0.x, 2.1.x, 2.2.x, 2.3.x
6
6
 
7
7
  Elasticity provides two ways to access EMR:
8
8
 
@@ -115,10 +115,14 @@ jobflow.service_role = nil
115
115
 
116
116
  jobflow.action_on_failure = 'TERMINATE_JOB_FLOW'
117
117
  jobflow.keep_job_flow_alive_when_no_steps = false
118
- jobflow.ami_version = 'latest'
119
118
  jobflow.log_uri = nil
120
119
  jobflow.enable_debugging = false # Requires a log_uri to enable
121
120
 
121
+ # >= 4.0.0 release label is now the default
122
+ jobflow.release_label = '4.3.0'
123
+ # < 4.0.0 ... Haven't used this before? just set the release label then.
124
+ jobflow.ami_version = 'latest'
125
+
122
126
  jobflow.tags = {name: "app-name", department: 'marketing'}
123
127
  jobflow.ec2_key_name = nil
124
128
  jobflow.visible_to_all_users = false
@@ -129,6 +133,25 @@ jobflow.master_instance_type = 'm1.small'
129
133
  jobflow.slave_instance_type = 'm1.small'
130
134
  ```
131
135
 
136
+ ### EMR Applications (optional needs release_label >= 4.0.0)
137
+ With the release of EMR 4.0.0 you can now supply applications which EMR will install for you on boot(rather than a manual bootstrap action. Which you can still use if required). You must set the `release_label` for the jobflow(>=4.0.0)
138
+
139
+ ```ruby
140
+ jobflow.release_label = '4.3.0'
141
+ # the simple way
142
+ jobflow.add_application("Spark") # Pig, Hive, Mahout
143
+ # more verbose
144
+ spark = Elasticity::Application.new({
145
+ name: 'Spark',
146
+ arguments: '--webui-port 18080',
147
+ version: '1.0.1',
148
+ additional_info: '' # This option is for advanced users only. This is meta information about third-party applications that third-party vendors use for testing purposes.
149
+ })
150
+ jobflow.add_application(spark)
151
+ ```
152
+
153
+ Further reading: http://docs.aws.amazon.com/ElasticMapReduce/latest/ReleaseGuide/emr-configure-apps.html
154
+
132
155
  ## 4 - Configure Instance Groups (optional)
133
156
 
134
157
  Technically this is optional since Elasticity creates MASTER and CORE instance groups for you (one m1.small instance in each). If you'd like your jobs to finish in an appreciable amount of time, you'll want to at least add a few instances to the CORE group :)
data/lib/elasticity.rb CHANGED
@@ -15,6 +15,7 @@ require 'elasticity/emr'
15
15
  require 'elasticity/sync_to_s3'
16
16
 
17
17
  require 'elasticity/bootstrap_action'
18
+ require 'elasticity/application'
18
19
  require 'elasticity/hadoop_bootstrap_action'
19
20
  require 'elasticity/hadoop_file_bootstrap_action'
20
21
  require 'elasticity/ganglia_bootstrap_action'
@@ -0,0 +1,27 @@
1
+ module Elasticity
2
+ class Application
3
+
4
+ attr_accessor :name
5
+ attr_accessor :arguments
6
+ attr_accessor :version
7
+ attr_accessor :additional_info
8
+
9
+ def initialize(args)
10
+ @name = args[:name]
11
+ @arguments = args[:arguments]
12
+ @version = args[:version]
13
+ @additional_info = args[:additional_info]
14
+ end
15
+
16
+ def to_hash
17
+ application = {
18
+ name: @name
19
+ }
20
+ application[:args] = @arguments unless @arguments.nil? || @arguments.empty?
21
+ application[:version] = @version if @version
22
+ application[:additional_info] = @additional_info if @additional_info
23
+ application
24
+ end
25
+
26
+ end
27
+ end
@@ -107,4 +107,4 @@ module Elasticity
107
107
 
108
108
  end
109
109
 
110
- end
110
+ end
@@ -17,6 +17,7 @@ module Elasticity
17
17
  attr_accessor :master_instance_type
18
18
  attr_accessor :slave_instance_type
19
19
  attr_accessor :ami_version
20
+ attr_accessor :release_label
20
21
  attr_accessor :keep_job_flow_alive_when_no_steps
21
22
  attr_accessor :ec2_subnet_id
22
23
  attr_accessor :placement
@@ -26,11 +27,11 @@ module Elasticity
26
27
  attr_accessor :job_flow_role
27
28
  attr_accessor :service_role
28
29
  attr_accessor :jobflow_id
30
+ attr_accessor :aws_applications
29
31
 
30
32
  def initialize
31
33
  @action_on_failure = 'TERMINATE_JOB_FLOW'
32
34
  @name = 'Elasticity Job Flow'
33
- @ami_version = 'latest'
34
35
  @keep_job_flow_alive_when_no_steps = false
35
36
  self.placement = 'us-east-1a'
36
37
  @enable_debugging = false
@@ -38,6 +39,7 @@ module Elasticity
38
39
  @visible_to_all_users = false
39
40
 
40
41
  @bootstrap_actions = []
42
+ @aws_applications = []
41
43
  @jobflow_steps = []
42
44
  @installed_steps = []
43
45
 
@@ -106,6 +108,13 @@ module Elasticity
106
108
  @bootstrap_actions << bootstrap_action
107
109
  end
108
110
 
111
+ def add_application(application)
112
+ raise JobFlowRunningError, 'To add applications, please create a new job flow.' if is_jobflow_running?
113
+ application = Application.new(name: application) if application.is_a?(String)
114
+ fail "application is not an Elasticity::Application" unless application.is_a?(Application)
115
+ @aws_applications << application
116
+ end
117
+
109
118
  def set_master_instance_group(instance_group)
110
119
  instance_group.role = 'MASTER'
111
120
  @instance_groups[:master] = instance_group
@@ -184,6 +193,7 @@ module Elasticity
184
193
 
185
194
  def jobflow_config
186
195
  config = jobflow_preamble
196
+ validate_and_apply_ami_or_release_version(config)
187
197
  steps = jobflow_steps
188
198
  steps.insert(0, Elasticity::SetupHadoopDebuggingStep.new.to_aws_step(self)) if @enable_debugging
189
199
  config[:steps] = steps
@@ -191,10 +201,23 @@ module Elasticity
191
201
  config[:tags] = jobflow_tags if @tags
192
202
  config[:job_flow_role] = @job_flow_role if @job_flow_role
193
203
  config[:service_role] = @service_role if @service_role
194
- config[:bootstrap_actions] = @bootstrap_actions.map{|a| a.to_aws_bootstrap_action} unless @bootstrap_actions.empty?
204
+ config[:bootstrap_actions] = @bootstrap_actions.map(&:to_aws_bootstrap_action) unless @bootstrap_actions.empty?
205
+ config[:applications] = @aws_applications.map(&:to_hash) if valid_aws_applications?
195
206
  config
196
207
  end
197
208
 
209
+ def valid_aws_applications?
210
+ !@aws_applications.empty?
211
+ end
212
+
213
+ def validate_and_apply_ami_or_release_version(config)
214
+ fail "Please use an EMR release_label not ami_version" if !@aws_applications.empty? && !@ami_version.nil?
215
+ fail "Please set the EMR release_label" if !@aws_applications.empty? && @release_label.nil?
216
+ config[:ami_version] = 'latest' if @ami_version.nil? && release_label.nil?
217
+ config[:ami_version] = @ami_version unless @ami_version.nil?
218
+ config[:release_label] = @release_label unless @release_label.nil?
219
+ end
220
+
198
221
  def jobflow_tags
199
222
  @tags.map do |key, value|
200
223
  {
@@ -207,7 +230,6 @@ module Elasticity
207
230
  def jobflow_preamble
208
231
  preamble = {
209
232
  :name => @name,
210
- :ami_version => @ami_version,
211
233
  :visible_to_all_users => @visible_to_all_users,
212
234
  :instances => {
213
235
  :keep_job_flow_alive_when_no_steps => @keep_job_flow_alive_when_no_steps,
@@ -1,3 +1,3 @@
1
1
  module Elasticity
2
- VERSION = '6.0.5'
2
+ VERSION = '6.0.6'
3
3
  end
@@ -0,0 +1,24 @@
1
+ describe Elasticity::Application do
2
+
3
+ let(:config) do
4
+ {
5
+ name: 'name',
6
+ version: '1.0.0',
7
+ arguments: 'arguments',
8
+ additional_info: 'additional_info'
9
+ }
10
+ end
11
+
12
+ subject { described_class.new(config) }
13
+
14
+ describe '#to_hash' do
15
+ it 'has all configuration' do
16
+ expect(subject.to_hash).to eq(
17
+ name: "name",
18
+ args: "arguments",
19
+ version: "1.0.0",
20
+ additional_info: "additional_info"
21
+ )
22
+ end
23
+ end
24
+ end
@@ -13,7 +13,9 @@ describe Elasticity::JobFlow do
13
13
  expect(subject.log_uri).to eql(nil)
14
14
  expect(subject.master_instance_type).to eql('m1.small')
15
15
  expect(subject.slave_instance_type).to eql('m1.small')
16
- expect(subject.ami_version).to eql('latest')
16
+ expect(subject.ami_version).to eql(nil)
17
+ expect(subject.release_label).to eql(nil)
18
+ expect(subject.aws_applications).to eql([])
17
19
  expect(subject.keep_job_flow_alive_when_no_steps).to eql(false)
18
20
  expect(subject.ec2_subnet_id).to eql(nil)
19
21
  expect(subject.placement).to eql('us-east-1a')
@@ -455,6 +457,50 @@ describe Elasticity::JobFlow do
455
457
 
456
458
  end
457
459
 
460
+ describe 'aws_applications' do
461
+ let(:application) { Elasticity::Application.new({}) }
462
+ let(:emr) { double(Elasticity::EMR, run_job_flow: true) }
463
+
464
+ before do
465
+ subject.stub(:emr).and_return(emr)
466
+ end
467
+
468
+ context 'with applications' do
469
+ context 'no release_label' do
470
+ it 'fails' do
471
+ subject.instance_variable_set(:@aws_applications, [application])
472
+ expect { subject.run }.to raise_error(RuntimeError, 'Please set the EMR release_label')
473
+ end
474
+ end
475
+
476
+ context 'ami_version set' do
477
+ it 'fails' do
478
+ subject.instance_variable_set(:@aws_applications, [application])
479
+ subject.instance_variable_set(:@ami_version, 'latest')
480
+ expect { subject.run }.to raise_error(RuntimeError, 'Please use an EMR release_label not ami_version')
481
+ end
482
+ end
483
+
484
+ context 'release_label set' do
485
+ it 'succeeds' do
486
+ subject.instance_variable_set(:@aws_applications, [application])
487
+ subject.instance_variable_set(:@release_label, '4.0.0')
488
+ subject.run
489
+ expect(subject.send(:jobflow_config)[:release_label]).to eql('4.0.0')
490
+ end
491
+ end
492
+ end
493
+
494
+ context 'with no applications' do
495
+ it 'sets default ami version and config doesn\'t contain applications' do
496
+ subject.run
497
+ config = subject.send(:jobflow_config)
498
+ expect(config[:ami_version]).to eql('latest')
499
+ expect(config[:applications]).to eql(nil)
500
+ end
501
+ end
502
+ end
503
+
458
504
  end
459
505
 
460
506
  describe '#jobflow_instance_groups' do
@@ -515,7 +561,6 @@ describe Elasticity::JobFlow do
515
561
  let(:basic_preamble) do
516
562
  {
517
563
  :name => 'Elasticity Job Flow',
518
- :ami_version => 'latest',
519
564
  :visible_to_all_users => false,
520
565
  :instances => {
521
566
  :keep_job_flow_alive_when_no_steps => false,
@@ -801,5 +846,4 @@ describe Elasticity::JobFlow do
801
846
  end
802
847
 
803
848
  end
804
-
805
849
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticity
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.5
4
+ version: 6.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Slifka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-28 00:00:00.000000000 Z
11
+ date: 2016-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -142,6 +142,7 @@ files:
142
142
  - Rakefile
143
143
  - elasticity.gemspec
144
144
  - lib/elasticity.rb
145
+ - lib/elasticity/application.rb
145
146
  - lib/elasticity/aws_request_v4.rb
146
147
  - lib/elasticity/aws_session.rb
147
148
  - lib/elasticity/aws_utils.rb
@@ -167,6 +168,7 @@ files:
167
168
  - lib/elasticity/version.rb
168
169
  - spec/factories/cluster_status_factory.rb
169
170
  - spec/factories/cluster_step_status_factory.rb
171
+ - spec/lib/elasticity/application_spec.rb
170
172
  - spec/lib/elasticity/aws_request_v4_spec.rb
171
173
  - spec/lib/elasticity/aws_session_spec.rb
172
174
  - spec/lib/elasticity/aws_utils_spec.rb
@@ -212,13 +214,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
214
  version: '0'
213
215
  requirements: []
214
216
  rubyforge_project:
215
- rubygems_version: 2.4.6
217
+ rubygems_version: 2.0.14
216
218
  signing_key:
217
219
  specification_version: 4
218
220
  summary: Streamlined, programmatic access to Amazon's Elastic Map Reduce service.
219
221
  test_files:
220
222
  - spec/factories/cluster_status_factory.rb
221
223
  - spec/factories/cluster_step_status_factory.rb
224
+ - spec/lib/elasticity/application_spec.rb
222
225
  - spec/lib/elasticity/aws_request_v4_spec.rb
223
226
  - spec/lib/elasticity/aws_session_spec.rb
224
227
  - spec/lib/elasticity/aws_utils_spec.rb