elasticity 1.4 → 1.4.1

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/HISTORY.md CHANGED
@@ -1,6 +1,14 @@
1
+ ### 1.4.1
2
+
3
+ + Added Elasticity::EMR#describe_jobflow("jobflow_id") for describing a specific job. If you happen to run hundreds of EMR jobs, this makes retrieving jobflow status much faster than using Elasticity::EMR#describe_jobflowS which pulls down and parses XML status for hundreds of jobs.
4
+
5
+ ### 1.4
6
+
7
+ + Added Elasticity::CustomJarJob for launching "Custom Jar" jobs.
8
+
1
9
  ### 1.3.1
2
10
 
3
- + Explicitly requiring 'time'.
11
+ + Explicitly requiring 'time' (only a problem if you aren't running from within a Rails environment).
4
12
  + Elasticity::JobFlow now exposes last_state_change_reason.
5
13
 
6
14
  ### 1.3 (Contributions from Wouter Broekhof)
data/README.md CHANGED
@@ -177,15 +177,28 @@ AddJobFlowSteps adds the specified steps to the specified job flow.
177
177
  })
178
178
  </pre>
179
179
 
180
+ ## describe_jobflow (Elasticity Convenience Method)
181
+
182
+ This is a convenience methods that wraps DescribeJobFlow to return the status of a single job.
183
+
184
+ <pre>
185
+ emr = Elasticity::EMR.new(ENV["AWS_ACCESS_KEY_ID"], ENV["AWS_SECRET_KEY"])
186
+ jobflow = emr.describe_jobflow("j-129V5AQFMKO1C")
187
+ p jobflow.jobflow_id
188
+ > "j-129V5AQFMKO1C"
189
+ p jobflow.name
190
+ > "Elasticity Test Job"
191
+ </pre>
192
+
180
193
  ## DescribeJobFlows
181
194
 
182
- DescribeJobFlows returns detailed information as to the state of all jobs. Currently this is wrapped in an <code>Elasticity::JobFlow</code> that contains the <code>name</code>, <code>jobflow_id</code> and <code>state</code>.
195
+ DescribeJobFlows returns detailed information as to the state of all jobs. Currently this is wrapped in an <code>Elasticity::JobFlow</code> that contains the <code>name</code>, <code>jobflow_id</code> and <code>state</code>.
183
196
 
184
197
  <pre>
185
198
  emr = Elasticity::EMR.new(ENV["AWS_ACCESS_KEY_ID"], ENV["AWS_SECRET_KEY"])
186
199
  jobflows = emr.describe_jobflows
187
200
  p jobflows.map(&:name)
188
-
201
+
189
202
  > ["Hive Test", "Pig Test", "Interactive Hadoop", "Interactive Hive"]
190
203
  </pre>
191
204
 
@@ -333,7 +346,7 @@ If you're chomping at the bit to initiate some EMR functionality that isn't wrap
333
346
  # License
334
347
 
335
348
  <pre>
336
- Copyright 2011 Robert Slifka
349
+ Copyright 2011-2012 Robert Slifka
337
350
 
338
351
  Licensed under the Apache License, Version 2.0 (the "License");
339
352
  you may not use this file except in compliance with the License.
@@ -6,6 +6,26 @@ module Elasticity
6
6
  @aws_request = Elasticity::AwsRequest.new(aws_access_key_id, aws_secret_access_key, options)
7
7
  end
8
8
 
9
+ # Describe a specific jobflow.
10
+ #
11
+ # describe_jobflow("j-3UN6WX5RRO2AG")
12
+ #
13
+ # Raises ArgumentError if the specified jobflow does not exist.
14
+ def describe_jobflow(jobflow_id)
15
+ begin
16
+ aws_result = @aws_request.aws_emr_request(EMR.convert_ruby_to_aws({
17
+ :operation => "DescribeJobFlows",
18
+ :job_flow_ids => [jobflow_id]
19
+ }))
20
+ xml_doc = Nokogiri::XML(aws_result)
21
+ xml_doc.remove_namespaces!
22
+ yield aws_result if block_given?
23
+ JobFlow.from_members_nodeset(xml_doc.xpath("/DescribeJobFlowsResponse/DescribeJobFlowsResult/JobFlows/member")).first
24
+ rescue RestClient::BadRequest => e
25
+ raise ArgumentError, EMR.parse_error_response(e.http_body)
26
+ end
27
+ end
28
+
9
29
  # Lists all jobflows in all states.
10
30
  #
11
31
  # To override this behaviour, pass additional filters as specified in the AWS
@@ -1,3 +1,3 @@
1
1
  module Elasticity
2
- VERSION = "1.4"
2
+ VERSION = "1.4.1"
3
3
  end
@@ -318,6 +318,89 @@ describe Elasticity::EMR do
318
318
 
319
319
  end
320
320
 
321
+ describe "#describe_jobflow" do
322
+ before do
323
+ @describe_jobflows_xml = <<-JOBFLOWS
324
+ <DescribeJobFlowsResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
325
+ <DescribeJobFlowsResult>
326
+ <JobFlows>
327
+ <member>
328
+ <ExecutionStatusDetail>
329
+ <State>TERMINATED</State>
330
+ </ExecutionStatusDetail>
331
+ <JobFlowId>j-3UN6WX5RRO2AG</JobFlowId>
332
+ <Name>The One Job Flow</Name>
333
+ </member>
334
+ </JobFlows>
335
+ </DescribeJobFlowsResult>
336
+ </DescribeJobFlowsResponse>
337
+ JOBFLOWS
338
+ end
339
+
340
+ it "should ask AWS about the specified job flow" do
341
+ aws_request = Elasticity::AwsRequest.new("","")
342
+ aws_request.should_receive(:aws_emr_request).with({
343
+ "Operation" => "DescribeJobFlows",
344
+ "JobFlowIds.member.1" => "j-3UN6WX5RRO2AG"
345
+ })
346
+ Elasticity::AwsRequest.stub(:new).and_return(aws_request)
347
+ emr = Elasticity::EMR.new("", "")
348
+ emr.describe_jobflow("j-3UN6WX5RRO2AG")
349
+ end
350
+
351
+ context "when the job flow ID exists" do
352
+ it "should return a JobFlow" do
353
+ aws_request = Elasticity::AwsRequest.new("","")
354
+ aws_request.stub(:aws_emr_request).with({
355
+ "Operation" => "DescribeJobFlows",
356
+ "JobFlowIds.member.1" => "j-3UN6WX5RRO2AG"
357
+ }).and_return(@describe_jobflows_xml)
358
+ Elasticity::AwsRequest.stub(:new).and_return(aws_request)
359
+ emr = Elasticity::EMR.new("", "")
360
+ jobflow = emr.describe_jobflow("j-3UN6WX5RRO2AG")
361
+ jobflow.jobflow_id.should == "j-3UN6WX5RRO2AG"
362
+ end
363
+ end
364
+
365
+ context "when there is an error" do
366
+ before do
367
+ @error_xml = <<-ERROR
368
+ <ErrorResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
369
+ <Error>
370
+ <Message>Specified job flow ID not valid</Message>
371
+ </Error>
372
+ </ErrorResponse>
373
+ ERROR
374
+ end
375
+
376
+ it "should raise an ArgumentError with the error message" do
377
+ aws_request = Elasticity::AwsRequest.new("aws_access_key_id", "aws_secret_key")
378
+ @exception = RestClient::BadRequest.new
379
+ @exception.should_receive(:http_body).and_return(@error_xml)
380
+ aws_request.should_receive(:aws_emr_request).and_raise(@exception)
381
+ Elasticity::AwsRequest.should_receive(:new).and_return(aws_request)
382
+ emr = Elasticity::EMR.new("aws_access_key_id", "aws_secret_key")
383
+ lambda {
384
+ emr.describe_jobflow("bad_jobflow_id")
385
+ }.should raise_error(ArgumentError, "Specified job flow ID not valid")
386
+ end
387
+ end
388
+
389
+ context "when a block is provided" do
390
+ it "should yield to the block" do
391
+ aws_request = Elasticity::AwsRequest.new("aws_access_key_id", "aws_secret_key")
392
+ aws_request.should_receive(:aws_emr_request).and_return("describe!")
393
+ Elasticity::AwsRequest.should_receive(:new).and_return(aws_request)
394
+ emr = Elasticity::EMR.new("aws_access_key_id", "aws_secret_key")
395
+ xml_result = nil
396
+ emr.describe_jobflow("_") do |xml|
397
+ xml_result = xml
398
+ end
399
+ xml_result.should == "describe!"
400
+ end
401
+ end
402
+ end
403
+
321
404
  describe "#modify_instance_groups" do
322
405
 
323
406
  describe "integration happy path" do
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticity
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- version: "1.4"
9
+ - 1
10
+ version: 1.4.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Robert Slifka
@@ -14,7 +15,8 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-12-09 00:00:00 Z
18
+ date: 2011-12-17 00:00:00 -08:00
19
+ default_executable:
18
20
  dependencies:
19
21
  - !ruby/object:Gem::Dependency
20
22
  name: rest-client
@@ -199,6 +201,7 @@ files:
199
201
  - spec/lib/elasticity/job_flow_step_spec.rb
200
202
  - spec/lib/elasticity/pig_job_spec.rb
201
203
  - spec/spec_helper.rb
204
+ has_rdoc: true
202
205
  homepage: http://www.github.com/rslifka/elasticity
203
206
  licenses: []
204
207
 
@@ -228,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
231
  requirements: []
229
232
 
230
233
  rubyforge_project:
231
- rubygems_version: 1.8.6
234
+ rubygems_version: 1.4.1
232
235
  signing_key:
233
236
  specification_version: 3
234
237
  summary: Programmatic access to Amazon's Elastic Map Reduce service.