elasticity 5.0.3 → 6.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +26 -0
  3. data/README.md +35 -28
  4. data/elasticity.gemspec +2 -2
  5. data/lib/elasticity.rb +5 -3
  6. data/lib/elasticity/aws_request_v4.rb +15 -3
  7. data/lib/elasticity/aws_session.rb +4 -23
  8. data/lib/elasticity/aws_utils.rb +0 -29
  9. data/lib/elasticity/cluster_status.rb +38 -0
  10. data/lib/elasticity/cluster_step_status.rb +51 -0
  11. data/lib/elasticity/emr.rb +208 -78
  12. data/lib/elasticity/job_flow.rb +16 -17
  13. data/lib/elasticity/version.rb +1 -1
  14. data/spec/factories/cluster_status_factory.rb +12 -0
  15. data/spec/factories/cluster_step_status_factory.rb +17 -0
  16. data/spec/lib/elasticity/aws_request_v4_spec.rb +54 -4
  17. data/spec/lib/elasticity/aws_session_spec.rb +22 -88
  18. data/spec/lib/elasticity/aws_utils_spec.rb +0 -46
  19. data/spec/lib/elasticity/bootstrap_action_spec.rb +7 -3
  20. data/spec/lib/elasticity/cluster_status_spec.rb +98 -0
  21. data/spec/lib/elasticity/cluster_step_status_spec.rb +80 -0
  22. data/spec/lib/elasticity/custom_jar_step_spec.rb +10 -7
  23. data/spec/lib/elasticity/emr_spec.rb +422 -132
  24. data/spec/lib/elasticity/ganglia_bootstrap_action_spec.rb +8 -3
  25. data/spec/lib/elasticity/hadoop_bootstrap_action_spec.rb +8 -3
  26. data/spec/lib/elasticity/hadoop_file_bootstrap_action_spec.rb +7 -3
  27. data/spec/lib/elasticity/hive_step_spec.rb +21 -17
  28. data/spec/lib/elasticity/instance_group_spec.rb +9 -5
  29. data/spec/lib/elasticity/job_flow_integration_spec.rb +4 -4
  30. data/spec/lib/elasticity/job_flow_spec.rb +102 -76
  31. data/spec/lib/elasticity/job_flow_step_spec.rb +1 -1
  32. data/spec/lib/elasticity/looper_spec.rb +1 -1
  33. data/spec/lib/elasticity/pig_step_spec.rb +13 -9
  34. data/spec/lib/elasticity/s3distcp_step_spec.rb +7 -5
  35. data/spec/lib/elasticity/script_step_spec.rb +11 -6
  36. data/spec/lib/elasticity/setup_hadoop_debugging_step_spec.rb +9 -5
  37. data/spec/lib/elasticity/streaming_step_spec.rb +13 -9
  38. data/spec/spec_helper.rb +8 -0
  39. data/spec/support/factory_girl.rb +8 -0
  40. metadata +24 -21
  41. data/lib/elasticity/aws_request_v2.rb +0 -42
  42. data/lib/elasticity/job_flow_status.rb +0 -91
  43. data/lib/elasticity/job_flow_status_step.rb +0 -38
  44. data/spec/lib/elasticity/aws_request_v2_spec.rb +0 -38
  45. data/spec/lib/elasticity/job_flow_status_spec.rb +0 -265
  46. data/spec/lib/elasticity/job_flow_status_step_spec.rb +0 -80
@@ -29,7 +29,7 @@ describe Elasticity::JobFlowStep do
29
29
 
30
30
  describe '.requires_installation?' do
31
31
  it 'should be false by default' do
32
- FakeStep.requires_installation?.should be_false
32
+ expect(FakeStep.requires_installation?).to be false
33
33
  end
34
34
  end
35
35
 
@@ -77,7 +77,7 @@ describe Elasticity::Looper do
77
77
 
78
78
  it 'does not communicate that waiting is about to occur' do
79
79
  client = double(:client, on_retry_check: false, on_wait: nil)
80
- client.should_not receive(:on_wait)
80
+ client.should_not_receive(:on_wait)
81
81
  l = Elasticity::Looper.new(client.method(:on_retry_check), client.method(:on_wait))
82
82
  l.go
83
83
  end
@@ -6,15 +6,19 @@ describe Elasticity::PigStep do
6
6
 
7
7
  it { should be_a Elasticity::JobFlowStep }
8
8
 
9
- its(:name) { should == 'Elasticity Pig Step (script.pig)' }
10
- its(:script) { should == 'script.pig' }
11
- its(:variables) { should == {} }
12
- its(:action_on_failure) { should == 'TERMINATE_JOB_FLOW' }
9
+ describe '.initialize' do
10
+ it 'should set the fields appropriately' do
11
+ expect(subject.name).to eql('Elasticity Pig Step (script.pig)')
12
+ expect(subject.script).to eql('script.pig')
13
+ expect(subject.variables).to eql({})
14
+ expect(subject.action_on_failure).to eql('TERMINATE_JOB_FLOW')
15
+ end
16
+ end
13
17
 
14
18
  describe '#to_aws_step' do
15
19
 
16
20
  it 'should convert to aws step format' do
17
- step = subject.to_aws_step(Elasticity::JobFlow.new('access', 'secret'))
21
+ step = subject.to_aws_step(Elasticity::JobFlow.new)
18
22
  step[:name].should == 'Elasticity Pig Step (script.pig)'
19
23
  step[:action_on_failure].should == 'TERMINATE_JOB_FLOW'
20
24
  step[:hadoop_jar_step][:jar].should == 's3://elasticmapreduce/libs/script-runner/script-runner.jar'
@@ -29,7 +33,7 @@ describe Elasticity::PigStep do
29
33
 
30
34
  describe 'E_PARALLELS' do
31
35
  it 'should include the correct value of E_PARALLELS' do
32
- job_flow = Elasticity::JobFlow.new('access', 'secret')
36
+ job_flow = Elasticity::JobFlow.new
33
37
  job_flow.instance_count = 8
34
38
  {
35
39
  '_' => 7,
@@ -49,7 +53,7 @@ describe Elasticity::PigStep do
49
53
  let(:ps_with_no_variables) { Elasticity::PigStep.new('script.pig') }
50
54
 
51
55
  it 'should convert to aws step format' do
52
- step = ps_with_no_variables.to_aws_step(Elasticity::JobFlow.new('access', 'secret'))
56
+ step = ps_with_no_variables.to_aws_step(Elasticity::JobFlow.new)
53
57
  step[:hadoop_jar_step][:args][5].should == 'script.pig'
54
58
  end
55
59
  end
@@ -65,7 +69,7 @@ describe Elasticity::PigStep do
65
69
  end
66
70
 
67
71
  it 'should convert to aws step format' do
68
- step = ps_with_variables.to_aws_step(Elasticity::JobFlow.new('access', 'secret'))
72
+ step = ps_with_variables.to_aws_step(Elasticity::JobFlow.new)
69
73
  step[:hadoop_jar_step][:args][3..9].should == [
70
74
  '-p', 'VAR1=VALUE1',
71
75
  '-p', 'VAR2=VALUE2',
@@ -79,7 +83,7 @@ describe Elasticity::PigStep do
79
83
 
80
84
  describe '.requires_installation?' do
81
85
  it 'should require installation' do
82
- Elasticity::PigStep.requires_installation?.should be_true
86
+ expect(Elasticity::PigStep.requires_installation?).to be true
83
87
  end
84
88
  end
85
89
 
@@ -1,10 +1,12 @@
1
1
  describe Elasticity::S3DistCpStep do
2
2
 
3
- it { should be_a Elasticity::CustomJarStep }
3
+ it 'should be a CustomJarStep' do
4
+ expect(subject).to be_a(Elasticity::CustomJarStep)
5
+ end
4
6
 
5
- its(:name) { should == 'Elasticity S3DistCp Step' }
6
- its(:jar) { should == '/home/hadoop/lib/emr-s3distcp-1.0.jar' }
7
- its(:arguments) { should == [] }
8
- its(:action_on_failure) { should == 'TERMINATE_JOB_FLOW' }
7
+ it 'should set the appropriate default fields' do
8
+ expect(subject.name).to eql('Elasticity S3DistCp Step')
9
+ expect(subject.jar).to eql('/home/hadoop/lib/emr-s3distcp-1.0.jar')
10
+ end
9
11
 
10
12
  end
@@ -1,12 +1,17 @@
1
1
  describe Elasticity::ScriptStep do
2
2
 
3
- it { should be_a Elasticity::CustomJarStep }
3
+ subject do
4
+ Elasticity::ScriptStep.new('script_location', 'arg1', 'arg2')
5
+ end
4
6
 
5
- subject { Elasticity::ScriptStep.new('script_location', 'arg1', 'arg2') }
7
+ it { should be_a Elasticity::CustomJarStep }
6
8
 
7
- its(:name) { should == 'Elasticity Script Step' }
8
- its(:jar) { should == 's3://elasticmapreduce/libs/script-runner/script-runner.jar' }
9
- its(:arguments) { should == %w(script_location arg1 arg2) }
10
- its(:action_on_failure) { should == 'TERMINATE_JOB_FLOW' }
9
+ describe '.initialize' do
10
+ it 'should set the fields appropriately' do
11
+ expect(subject.name).to eql('Elasticity Script Step')
12
+ expect(subject.jar).to eql('s3://elasticmapreduce/libs/script-runner/script-runner.jar')
13
+ expect(subject.arguments).to eql(%w(script_location arg1 arg2))
14
+ end
15
+ end
11
16
 
12
17
  end
@@ -1,10 +1,14 @@
1
1
  describe Elasticity::SetupHadoopDebuggingStep do
2
2
 
3
- it { should be_a Elasticity::CustomJarStep }
3
+ it 'should be a CustomJarStep' do
4
+ expect(subject).to be_a(Elasticity::CustomJarStep)
5
+ end
4
6
 
5
- its(:name) { should == 'Elasticity Setup Hadoop Debugging' }
6
- its(:jar) { should == 's3://elasticmapreduce/libs/script-runner/script-runner.jar' }
7
- its(:arguments) { should == ['s3://elasticmapreduce/libs/state-pusher/0.1/fetch'] }
8
- its(:action_on_failure) { should == 'TERMINATE_JOB_FLOW' }
7
+ it 'should set the appropriate fields' do
8
+ expect(subject.name).to eql('Elasticity Setup Hadoop Debugging')
9
+ expect(subject.jar).to eql('s3://elasticmapreduce/libs/script-runner/script-runner.jar')
10
+ expect(subject.arguments).to eql(['s3://elasticmapreduce/libs/state-pusher/0.1/fetch'])
11
+ expect(subject.action_on_failure).to eql('TERMINATE_JOB_FLOW')
12
+ end
9
13
 
10
14
  end
@@ -6,18 +6,22 @@ describe Elasticity::StreamingStep do
6
6
 
7
7
  it { should be_a Elasticity::JobFlowStep }
8
8
 
9
- its(:name) { should == 'Elasticity Streaming Step' }
10
- its(:action_on_failure) { should == 'TERMINATE_JOB_FLOW' }
11
- its(:input_bucket) { should == 'INPUT_BUCKET' }
12
- its(:output_bucket) { should == 'OUTPUT_BUCKET' }
13
- its(:mapper) { should == 'MAPPER' }
14
- its(:reducer) { should == 'REDUCER' }
15
- its(:arguments) { should == %w(-ARG1 VALUE1) }
9
+ describe '.initialize' do
10
+ it 'should set the fields appropriately' do
11
+ expect(subject.name).to eql('Elasticity Streaming Step')
12
+ expect(subject.action_on_failure).to eql('TERMINATE_JOB_FLOW')
13
+ expect(subject.input_bucket).to eql('INPUT_BUCKET')
14
+ expect(subject.output_bucket).to eql('OUTPUT_BUCKET')
15
+ expect(subject.mapper).to eql('MAPPER')
16
+ expect(subject.reducer).to eql('REDUCER')
17
+ expect(subject.arguments).to eql(%w(-ARG1 VALUE1))
18
+ end
19
+ end
16
20
 
17
21
  describe '#to_aws_step' do
18
22
 
19
23
  it 'should convert to aws step format' do
20
- subject.to_aws_step(Elasticity::JobFlow.new('_', '_')).should == {
24
+ subject.to_aws_step(Elasticity::JobFlow.new).should == {
21
25
  :name => 'Elasticity Streaming Step',
22
26
  :action_on_failure => 'TERMINATE_JOB_FLOW',
23
27
  :hadoop_jar_step => {
@@ -31,7 +35,7 @@ describe Elasticity::StreamingStep do
31
35
 
32
36
  describe '.requires_installation?' do
33
37
  it 'should not require installation' do
34
- Elasticity::StreamingStep.requires_installation?.should be_false
38
+ expect(Elasticity::StreamingStep.requires_installation?).to be false
35
39
  end
36
40
  end
37
41
 
@@ -10,4 +10,12 @@ RSpec.configure do |config|
10
10
  Elasticity.default_configuration
11
11
  end
12
12
 
13
+ config.expect_with :rspec do |c|
14
+ c.syntax = [:should, :expect]
15
+ end
16
+
17
+ config.mock_with :rspec do |mocks|
18
+ mocks.syntax = :should
19
+ end
20
+
13
21
  end
@@ -0,0 +1,8 @@
1
+ require 'factory_girl'
2
+
3
+ FactoryGirl.find_definitions
4
+
5
+ RSpec.configure do |config|
6
+ config.include FactoryGirl::Syntax::Methods
7
+ end
8
+
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: 5.0.3
4
+ version: '6.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: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: nokogiri
28
+ name: fog
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
@@ -39,33 +39,33 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: fog
42
+ name: unf
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '1.0'
47
+ version: '0.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '1.0'
54
+ version: '0.1'
55
55
  - !ruby/object:Gem::Dependency
56
- name: unf
56
+ name: factory_girl
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0.1'
62
- type: :runtime
61
+ version: '4.0'
62
+ type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '0.1'
68
+ version: '4.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fakefs
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - ~>
102
102
  - !ruby/object:Gem::Version
103
- version: 2.14.0
103
+ version: '3.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ~>
109
109
  - !ruby/object:Gem::Version
110
- version: 2.14.0
110
+ version: '3.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: timecop
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -142,11 +142,12 @@ files:
142
142
  - Rakefile
143
143
  - elasticity.gemspec
144
144
  - lib/elasticity.rb
145
- - lib/elasticity/aws_request_v2.rb
146
145
  - lib/elasticity/aws_request_v4.rb
147
146
  - lib/elasticity/aws_session.rb
148
147
  - lib/elasticity/aws_utils.rb
149
148
  - lib/elasticity/bootstrap_action.rb
149
+ - lib/elasticity/cluster_status.rb
150
+ - lib/elasticity/cluster_step_status.rb
150
151
  - lib/elasticity/custom_jar_step.rb
151
152
  - lib/elasticity/emr.rb
152
153
  - lib/elasticity/ganglia_bootstrap_action.rb
@@ -155,8 +156,6 @@ files:
155
156
  - lib/elasticity/hive_step.rb
156
157
  - lib/elasticity/instance_group.rb
157
158
  - lib/elasticity/job_flow.rb
158
- - lib/elasticity/job_flow_status.rb
159
- - lib/elasticity/job_flow_status_step.rb
160
159
  - lib/elasticity/job_flow_step.rb
161
160
  - lib/elasticity/looper.rb
162
161
  - lib/elasticity/pig_step.rb
@@ -166,11 +165,14 @@ files:
166
165
  - lib/elasticity/streaming_step.rb
167
166
  - lib/elasticity/sync_to_s3.rb
168
167
  - lib/elasticity/version.rb
169
- - spec/lib/elasticity/aws_request_v2_spec.rb
168
+ - spec/factories/cluster_status_factory.rb
169
+ - spec/factories/cluster_step_status_factory.rb
170
170
  - spec/lib/elasticity/aws_request_v4_spec.rb
171
171
  - spec/lib/elasticity/aws_session_spec.rb
172
172
  - spec/lib/elasticity/aws_utils_spec.rb
173
173
  - spec/lib/elasticity/bootstrap_action_spec.rb
174
+ - spec/lib/elasticity/cluster_status_spec.rb
175
+ - spec/lib/elasticity/cluster_step_status_spec.rb
174
176
  - spec/lib/elasticity/custom_jar_step_spec.rb
175
177
  - spec/lib/elasticity/emr_spec.rb
176
178
  - spec/lib/elasticity/ganglia_bootstrap_action_spec.rb
@@ -180,8 +182,6 @@ files:
180
182
  - spec/lib/elasticity/instance_group_spec.rb
181
183
  - spec/lib/elasticity/job_flow_integration_spec.rb
182
184
  - spec/lib/elasticity/job_flow_spec.rb
183
- - spec/lib/elasticity/job_flow_status_spec.rb
184
- - spec/lib/elasticity/job_flow_status_step_spec.rb
185
185
  - spec/lib/elasticity/job_flow_step_spec.rb
186
186
  - spec/lib/elasticity/looper_spec.rb
187
187
  - spec/lib/elasticity/pig_step_spec.rb
@@ -192,6 +192,7 @@ files:
192
192
  - spec/lib/elasticity/sync_to_s3_spec.rb
193
193
  - spec/spec_helper.rb
194
194
  - spec/support/be_a_hash_including_matcher.rb
195
+ - spec/support/factory_girl.rb
195
196
  homepage: http://www.github.com/rslifka/elasticity
196
197
  licenses: []
197
198
  metadata: {}
@@ -216,11 +217,14 @@ signing_key:
216
217
  specification_version: 4
217
218
  summary: Streamlined, programmatic access to Amazon's Elastic Map Reduce service.
218
219
  test_files:
219
- - spec/lib/elasticity/aws_request_v2_spec.rb
220
+ - spec/factories/cluster_status_factory.rb
221
+ - spec/factories/cluster_step_status_factory.rb
220
222
  - spec/lib/elasticity/aws_request_v4_spec.rb
221
223
  - spec/lib/elasticity/aws_session_spec.rb
222
224
  - spec/lib/elasticity/aws_utils_spec.rb
223
225
  - spec/lib/elasticity/bootstrap_action_spec.rb
226
+ - spec/lib/elasticity/cluster_status_spec.rb
227
+ - spec/lib/elasticity/cluster_step_status_spec.rb
224
228
  - spec/lib/elasticity/custom_jar_step_spec.rb
225
229
  - spec/lib/elasticity/emr_spec.rb
226
230
  - spec/lib/elasticity/ganglia_bootstrap_action_spec.rb
@@ -230,8 +234,6 @@ test_files:
230
234
  - spec/lib/elasticity/instance_group_spec.rb
231
235
  - spec/lib/elasticity/job_flow_integration_spec.rb
232
236
  - spec/lib/elasticity/job_flow_spec.rb
233
- - spec/lib/elasticity/job_flow_status_spec.rb
234
- - spec/lib/elasticity/job_flow_status_step_spec.rb
235
237
  - spec/lib/elasticity/job_flow_step_spec.rb
236
238
  - spec/lib/elasticity/looper_spec.rb
237
239
  - spec/lib/elasticity/pig_step_spec.rb
@@ -242,3 +244,4 @@ test_files:
242
244
  - spec/lib/elasticity/sync_to_s3_spec.rb
243
245
  - spec/spec_helper.rb
244
246
  - spec/support/be_a_hash_including_matcher.rb
247
+ - spec/support/factory_girl.rb
@@ -1,42 +0,0 @@
1
- module Elasticity
2
-
3
- class AwsRequestV2
4
-
5
- def initialize(aws_session, ruby_service_hash)
6
- @aws_session = aws_session
7
- @ruby_service_hash = ruby_service_hash
8
- end
9
-
10
- def url
11
- "https://elasticmapreduce.#{@aws_session.region}.amazonaws.com"
12
- end
13
-
14
- def headers
15
- {
16
- :content_type => 'application/x-www-form-urlencoded; charset=utf-8'
17
- }
18
- end
19
-
20
- # (Used from RightScale's right_aws gem.)
21
- # EC2, SQS, SDB and EMR requests must be signed by this guy.
22
- # See: http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/index.html?REST_RESTAuth.html
23
- # http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1928
24
- def payload
25
- service_hash = AwsUtils.convert_ruby_to_aws(@ruby_service_hash)
26
- service_hash.merge!({
27
- 'AWSAccessKeyId' => @aws_session.access_key,
28
- 'Timestamp' => Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S.000Z'),
29
- 'SignatureVersion' => '2',
30
- 'SignatureMethod' => 'HmacSHA256'
31
- })
32
- canonical_string = service_hash.keys.sort.map do |key|
33
- "#{AwsUtils.aws_escape(key)}=#{AwsUtils.aws_escape(service_hash[key])}"
34
- end.join('&')
35
- string_to_sign = "POST\n#{@aws_session.host.downcase}\n/\n#{canonical_string}"
36
- signature = AwsUtils.aws_escape(Base64.encode64(OpenSSL::HMAC.digest('sha256', @aws_session.secret_key, string_to_sign)).strip)
37
- "#{canonical_string}&Signature=#{signature}"
38
- end
39
-
40
- end
41
-
42
- end
@@ -1,91 +0,0 @@
1
- module Elasticity
2
-
3
- class JobFlowStatus
4
-
5
- attr_accessor :name
6
- attr_accessor :jobflow_id
7
- attr_accessor :state
8
- attr_accessor :steps
9
- attr_accessor :created_at
10
- attr_accessor :started_at
11
- attr_accessor :ready_at
12
- attr_accessor :ended_at
13
- attr_accessor :duration
14
- attr_accessor :instance_count
15
- attr_accessor :master_instance_type
16
- attr_accessor :master_instance_id
17
- attr_accessor :slave_instance_type
18
- attr_accessor :last_state_change_reason
19
- attr_accessor :installed_steps
20
- attr_accessor :master_public_dns_name
21
- attr_accessor :normalized_instance_hours
22
-
23
- def initialize
24
- @steps = []
25
- @installed_steps = []
26
- end
27
-
28
- # http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/ProcessingCycle.html
29
- def active?
30
- %w{RUNNING STARTING BOOTSTRAPPING WAITING SHUTTING_DOWN}.include? state
31
- end
32
-
33
- # Create a jobflow from an AWS <member> (Nokogiri::XML::Element):
34
- # /DescribeJobFlowsResponse/DescribeJobFlowsResult/JobFlows/member
35
- def self.from_member_element(xml_element)
36
- jobflow_status = JobFlowStatus.new
37
-
38
- jobflow_status.name = xml_element.xpath('./Name').text.strip
39
- jobflow_status.jobflow_id = xml_element.xpath('./JobFlowId').text.strip
40
- jobflow_status.state = xml_element.xpath('./ExecutionStatusDetail/State').text.strip
41
- jobflow_status.last_state_change_reason = xml_element.xpath('./ExecutionStatusDetail/LastStateChangeReason').text.strip
42
-
43
- jobflow_status.steps = JobFlowStatusStep.from_members_nodeset(xml_element.xpath('./Steps/member'))
44
-
45
- step_names = jobflow_status.steps.map(&:name)
46
- Elasticity::JobFlowStep.steps_requiring_installation.each do |step|
47
- jobflow_status.installed_steps << step if step_names.include?(step.aws_installation_step_name)
48
- end
49
-
50
- jobflow_status.created_at = Time.parse(xml_element.xpath('./ExecutionStatusDetail/CreationDateTime').text.strip)
51
-
52
- ready_at = xml_element.xpath('./ExecutionStatusDetail/ReadyDateTime').text.strip
53
- jobflow_status.ready_at = (ready_at == '') ? (nil) : (Time.parse(ready_at))
54
-
55
- started_at = xml_element.xpath('./ExecutionStatusDetail/StartDateTime').text.strip
56
- jobflow_status.started_at = (started_at == '') ? (nil) : (Time.parse(started_at))
57
-
58
- ended_at = xml_element.xpath('./ExecutionStatusDetail/EndDateTime').text.strip
59
- jobflow_status.ended_at = (ended_at == '') ? (nil) : (Time.parse(ended_at))
60
-
61
- if jobflow_status.ended_at && jobflow_status.started_at
62
- jobflow_status.duration = ((jobflow_status.ended_at - jobflow_status.started_at) / 60).to_i
63
- end
64
-
65
- jobflow_status.instance_count = xml_element.xpath('./Instances/InstanceCount').text.strip
66
- jobflow_status.master_instance_type = xml_element.xpath('./Instances/MasterInstanceType').text.strip
67
- master_instance_id = xml_element.xpath('./Instances/MasterInstanceId').text.strip
68
- jobflow_status.master_instance_id = (master_instance_id == '') ? (nil) : (master_instance_id)
69
- jobflow_status.slave_instance_type = xml_element.xpath('./Instances/SlaveInstanceType').text.strip
70
-
71
- master_public_dns_name = xml_element.xpath('./Instances/MasterPublicDnsName').text.strip
72
- jobflow_status.master_public_dns_name = (master_public_dns_name == '') ? (nil) : (master_public_dns_name)
73
-
74
- jobflow_status.normalized_instance_hours = xml_element.xpath('./Instances/NormalizedInstanceHours').text.strip
75
-
76
- jobflow_status
77
- end
78
-
79
- # Create JobFlows from a collection of AWS <member> nodes (Nokogiri::XML::NodeSet):
80
- # /DescribeJobFlowsResponse/DescribeJobFlowsResult/JobFlows
81
- def self.from_members_nodeset(members_nodeset)
82
- jobflow_statuses = []
83
- members_nodeset.each do |member|
84
- jobflow_statuses << from_member_element(member)
85
- end
86
- jobflow_statuses
87
- end
88
-
89
- end
90
-
91
- end