elasticity 3.0.4 → 4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmY0NTJjZmJkMmVhNTYwNTJlZmY3MjAwOTE0NDhmYjczY2MxNzAwOA==
4
+ MmZlODg3MzM2NmYzOGQyZjdiYjcyZjZkNTA2MThmMWZlZTQzYmM5Mw==
5
5
  data.tar.gz: !binary |-
6
- MmIwNDRmMjM3MTA3NzliZDM4ZWY4MGZmODRlNTYwODlhYTMwYmYwZQ==
6
+ ODA1ZWJiMDM5YzQ5YTBjY2Y3MzY0NGFmY2Y5MTA3MWFjNjAxNTUzNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzI5NzgyMjc5YTlmZjljMjY5MzQ2MzU4ZmZiOWFiYmViMDgwMmYyNDJiZjE2
10
- NzY4MTllZGFlN2Q1ZjcyNTVjZGIxYWQ2NTNmMmE4NDE2MTNmOTc1ODcyYjZl
11
- MTljMDM3OWZhNWM2OThkYjBkMjI1MGE4YzgyMWZkZjQ3M2ZlMDU=
9
+ OGRjMjY3Y2M3MWQxNTRjNmJiNDM1NGI3YTAyNDc5NTUxYmY2MjNkYzk0YmJj
10
+ ZjcxMDExYWNlMzY1M2MxODVkMWUyMmM5NmFhYzJjZTdlNmU5YmJmYzU4MWFj
11
+ YWIzM2ZkN2U3ZTZhMmZmYjc1NWYyODYzZjY1OTgyYjAxZTM4M2E=
12
12
  data.tar.gz: !binary |-
13
- NmU2N2MxM2EyODdhZGMyYzQ2MTA1YmQ4ZGFiMTI2MTM3ZGQ0Mzg0MGM3ODg3
14
- MjQ2NTljMTg5NzYxODZhM2UyNzQ2NTZjMTU1MmIxOTRmNWJiNmVmYmNlMTBi
15
- MDg3ZjlmZTE1ZTUyODBmMDQ0MjI0NzBhN2ZmOGFhMGRmZTI2MmU=
13
+ OWNjMjg3ZTI5NzJhNWVhZmQ2NDg0ZDViZmRhMDEwYWQ1ZTI4YWJjNTEwODE1
14
+ YmFjNzRlYWFjZTM4YjNhOTE2ZjhjNjQxOTE3MDI3ZDUyMTFjNGJkOTUwOGY5
15
+ NzlkZTQ4NjE1Nzk5MzE5M2VmOWMyMGEyM2RhYjM0ZGY4M2FmYWU=
@@ -2,5 +2,5 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - 2.1.0
6
- - 2.1.1
5
+ - 2.1.1
6
+ - jruby-19mode
data/HISTORY.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 4.0 - May 21, 2014
2
+
3
+ - Fix for issue [#69](https://github.com/rslifka/elasticity/issues/69). The AWS region was previously being derived from the placement. With the advent of VPC/subnet IDs being set, placement is not always relevant (as the VPC subnet ID implicitly defines a placement). Since region cannot be derived it is now available directly on `JobFlow`.
4
+ - Fix for issue [#79](https://github.com/rslifka/elasticity/issues/70). Removing the ability to set the now deprecated Hadoop version. It is now set via specifying the AMI version. See the [EMR docs](http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/emr-plan-hadoop-version.html) for more details.
5
+ - Building against JRuby 1.8. While I don't necessarily have the resources to optimize for JRuby compatibility (given that I know next to nothing about it :) I'll use this as a canary to tackle any low-hanging issues that may arise.
6
+
1
7
  ## 3.0.4 - April 30, 2014
2
8
 
3
9
  - Fix for issues [#65](https://github.com/rslifka/elasticity/issues/65) and [#66](https://github.com/rslifka/elasticity/issues/66).
data/README.md CHANGED
@@ -1,10 +1,8 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/elasticity.png)](http://badge.fury.io/rb/elasticity)
2
2
 
3
- **(April 10, 2014)** Taking requests! I have a few ideas for what might be cool features though I'd rather work on what the community wants. Go ahead and file an issue!
4
-
5
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.
6
4
 
7
- [![Build Status](https://secure.travis-ci.org/rslifka/elasticity.png)](http://travis-ci.org/rslifka/elasticity) 1.9.3, 2.0.0, 2.1.0, 2.1.1
5
+ [![Build Status](https://secure.travis-ci.org/rslifka/elasticity.png)](http://travis-ci.org/rslifka/elasticity) 1.9.3, 2.0.0, 2.1.0, 2.1.1, JRuby 1.9
8
6
 
9
7
  Elasticity provides two ways to access EMR:
10
8
 
@@ -20,7 +18,7 @@ gem install elasticity
20
18
  or in your Gemfile
21
19
 
22
20
  ```
23
- gem 'elasticity', '~> 3.0'
21
+ gem 'elasticity', '~> 4.0'
24
22
  ```
25
23
 
26
24
  This will ensure that you protect yourself from API changes, which will only be made in major revisions.
@@ -112,13 +110,13 @@ jobflow.ec2_subnet_id = nil
112
110
  jobflow.action_on_failure = 'TERMINATE_JOB_FLOW'
113
111
  jobflow.keep_job_flow_alive_when_no_steps = false
114
112
  jobflow.ami_version = 'latest'
115
- jobflow.hadoop_version = '1.0.3'
116
113
  jobflow.log_uri = nil
117
114
  jobflow.enable_debugging = false # Requires a log_uri to enable
118
115
 
119
116
  jobflow.ec2_key_name = nil
120
117
  jobflow.visible_to_all_users = false
121
118
  jobflow.placement = 'us-east-1a'
119
+ jobflow.region = 'us-east-1'
122
120
  jobflow.instance_count = 2
123
121
  jobflow.master_instance_type = 'm1.small'
124
122
  jobflow.slave_instance_type = 'm1.small'
@@ -412,7 +410,7 @@ Unfortunately, the documentation is sometimes incorrect and sometimes missing.
412
410
  # License
413
411
 
414
412
  ```
415
- Copyright 2011-2013 Robert Slifka
413
+ Copyright 2011-2014 Robert Slifka
416
414
 
417
415
  Licensed under the Apache License, Version 2.0 (the "License");
418
416
  you may not use this file except in compliance with the License.
@@ -2,6 +2,8 @@ module Elasticity
2
2
 
3
3
  class MissingKeyError < StandardError;
4
4
  end
5
+ class MissingRegionError < StandardError;
6
+ end
5
7
 
6
8
  class AwsRequest
7
9
 
@@ -14,6 +16,11 @@ module Elasticity
14
16
  # :region - AWS region (e.g. us-west-1)
15
17
  # :secure - true or false, default true.
16
18
  def initialize(access=nil, secret=nil, options={})
19
+ # There is a cryptic error if this isn't set
20
+ if options.has_key?(:region) && options[:region] == nil
21
+ raise MissingRegionError, 'A valid :region is required to connect to EMR'
22
+ end
23
+
17
24
  @access_key = get_access_key(access)
18
25
  @secret_key = get_secret_key(secret)
19
26
  @host = "elasticmapreduce.#{{:region => 'us-east-1'}.merge(options)[:region]}.amazonaws.com"
@@ -4,13 +4,13 @@ module Elasticity
4
4
  class JobFlowNotStartedError < StandardError; end
5
5
  class JobFlowMissingStepsError < StandardError; end
6
6
  class LogUriMissingError < StandardError; end
7
+ class UnknownPlacementError < StandardError; end
7
8
 
8
9
  class JobFlow
9
10
 
10
11
  attr_accessor :action_on_failure
11
12
  attr_accessor :ec2_key_name
12
13
  attr_accessor :name
13
- attr_accessor :hadoop_version
14
14
  attr_accessor :instance_count
15
15
  attr_accessor :log_uri
16
16
  attr_accessor :master_instance_type
@@ -19,6 +19,7 @@ module Elasticity
19
19
  attr_accessor :keep_job_flow_alive_when_no_steps
20
20
  attr_accessor :ec2_subnet_id
21
21
  attr_accessor :placement
22
+ attr_accessor :region
22
23
  attr_accessor :visible_to_all_users
23
24
  attr_accessor :enable_debugging
24
25
 
@@ -27,11 +28,10 @@ module Elasticity
27
28
 
28
29
  def initialize(access=nil, secret=nil)
29
30
  @action_on_failure = 'TERMINATE_JOB_FLOW'
30
- @hadoop_version = '1.0.3'
31
31
  @name = 'Elasticity Job Flow'
32
32
  @ami_version = 'latest'
33
33
  @keep_job_flow_alive_when_no_steps = false
34
- @placement = 'us-east-1a'
34
+ self.placement = 'us-east-1a'
35
35
  @enable_debugging = false
36
36
 
37
37
  @access_key = access
@@ -61,6 +61,20 @@ module Elasticity
61
61
  end
62
62
  end
63
63
 
64
+ def placement=(new_placement)
65
+ @placement = new_placement
66
+ return unless @placement
67
+
68
+ # The region has to be set so we know where to launch the job flow, and it has
69
+ # to be in sync with the placement. Not setting this will lead to strange, difficult to
70
+ # track errors, for example the job flow won't exist where you think it should, etc.
71
+ if @placement =~ /\w+-\w+-\d+/
72
+ @region = @placement.match(/(\w+-\w+-\d+)/)[0]
73
+ else
74
+ raise UnknownPlacementError, "'#{@placement}' is not a valid EMR placement"
75
+ end
76
+ end
77
+
64
78
  def enable_debugging=(enabled)
65
79
  if enabled
66
80
  raise LogUriMissingError, 'To enable debugging, please set a #log_uri' unless @log_uri
@@ -158,7 +172,6 @@ module Elasticity
158
172
  end
159
173
 
160
174
  def emr
161
- @region ||= @placement.match(/(\w+-\w+-\d+)/)[0]
162
175
  @emr ||= Elasticity::EMR.new(@access_key, @secret_key, :region => @region)
163
176
  end
164
177
 
@@ -183,7 +196,6 @@ module Elasticity
183
196
  :visible_to_all_users => @visible_to_all_users,
184
197
  :instances => {
185
198
  :keep_job_flow_alive_when_no_steps => @keep_job_flow_alive_when_no_steps,
186
- :hadoop_version => @hadoop_version,
187
199
  :instance_groups => jobflow_instance_groups,
188
200
  :placement => {
189
201
  :availability_zone => @placement
@@ -1,3 +1,3 @@
1
1
  module Elasticity
2
- VERSION = '3.0.4'
2
+ VERSION = '4.0'
3
3
  end
@@ -21,6 +21,14 @@ describe Elasticity::AwsRequest do
21
21
  end
22
22
  end
23
23
 
24
+ context 'when :region is nil' do
25
+ it 'should be an error' do
26
+ expect {
27
+ Elasticity::AwsRequest.new('_', '_', :region => nil)
28
+ }.to raise_error Elasticity::MissingRegionError, 'A valid :region is required to connect to EMR'
29
+ end
30
+ end
31
+
24
32
  context 'when either access or secret key is not provided or nil' do
25
33
 
26
34
  context 'when the proper environment variables are set' do
@@ -31,7 +31,6 @@ describe 'Elasticity::JobFlow Integration Examples' do
31
31
  :visible_to_all_users => false,
32
32
  :instances => {
33
33
  :keep_job_flow_alive_when_no_steps => false,
34
- :hadoop_version => '1.0.3',
35
34
  :instance_groups => [
36
35
  {
37
36
  :instance_count => 1,
@@ -119,7 +118,6 @@ describe 'Elasticity::JobFlow Integration Examples' do
119
118
  :visible_to_all_users => false,
120
119
  :instances => {
121
120
  :keep_job_flow_alive_when_no_steps => false,
122
- :hadoop_version => '1.0.3',
123
121
  :instance_groups => [
124
122
  {
125
123
  :instance_count => 1,
@@ -206,7 +204,6 @@ describe 'Elasticity::JobFlow Integration Examples' do
206
204
  :visible_to_all_users => false,
207
205
  :instances => {
208
206
  :keep_job_flow_alive_when_no_steps => false,
209
- :hadoop_version => '1.0.3',
210
207
  :instance_groups => [
211
208
  {
212
209
  :instance_count => 1,
@@ -9,7 +9,6 @@ describe Elasticity::JobFlow do
9
9
  its(:action_on_failure) { should == 'TERMINATE_JOB_FLOW' }
10
10
  its(:ec2_key_name) { should == nil }
11
11
  its(:ec2_subnet_id) { should == nil }
12
- its(:hadoop_version) { should == '1.0.3' }
13
12
  its(:instance_count) { should == 2 }
14
13
  its(:log_uri) { should == nil }
15
14
  its(:master_instance_type) { should == 'm1.small' }
@@ -20,6 +19,7 @@ describe Elasticity::JobFlow do
20
19
  its(:placement) { should == 'us-east-1a' }
21
20
  its(:visible_to_all_users) { should == false }
22
21
  its(:enable_debugging) { should == false }
22
+ its(:region) { should == 'us-east-1' }
23
23
 
24
24
  describe '.initialize' do
25
25
  it 'should set the access and secret keys to nil by default' do
@@ -33,6 +33,41 @@ describe Elasticity::JobFlow do
33
33
  end
34
34
  end
35
35
 
36
+ describe '#placement=' do
37
+
38
+ context 'when the placement is set' do
39
+
40
+ context 'when the placement is valid' do
41
+ before do
42
+ subject.placement = 'us-west-1a'
43
+ end
44
+
45
+ it 'should set the region' do
46
+ subject.region.should == 'us-west-1'
47
+ end
48
+ end
49
+
50
+ context 'when the placement is not valid' do
51
+ it 'should set the region' do
52
+ expect {
53
+ subject.placement = 'BAD_PLACEMENT'
54
+ }.to raise_error(Elasticity::UnknownPlacementError, "'BAD_PLACEMENT' is not a valid EMR placement")
55
+ end
56
+ end
57
+
58
+ end
59
+
60
+ context 'when the placement is not set' do
61
+ before do
62
+ subject.placement = nil
63
+ end
64
+ it 'should not modify the region' do
65
+ subject.region.should == 'us-east-1'
66
+ end
67
+ end
68
+
69
+ end
70
+
36
71
  describe '#enable_debugging=' do
37
72
 
38
73
  context 'when a log_uri is present' do
@@ -136,7 +171,7 @@ describe Elasticity::JobFlow do
136
171
  end
137
172
 
138
173
  it 'should unset placement (which has a default value) because having both set is EMR-invalid' do
139
- subject.placement = 'TEST_PLACEMENT'
174
+ subject.placement = 'us-east-1d'
140
175
 
141
176
  subject.ec2_subnet_id = '_'
142
177
  subject.placement.should == nil
@@ -406,7 +441,6 @@ describe Elasticity::JobFlow do
406
441
  :visible_to_all_users => false,
407
442
  :instances => {
408
443
  :keep_job_flow_alive_when_no_steps => false,
409
- :hadoop_version => '1.0.3',
410
444
  :instance_groups => ['INSTANCE_GROUP_CONFIGURATION'],
411
445
  :placement => {
412
446
  :availability_zone => 'us-east-1a'
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: 3.0.4
4
+ version: '4.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Slifka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-30 00:00:00.000000000 Z
11
+ date: 2014-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client