aws-sdk 1.5.7 → 1.5.8
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/lib/aws.rb +2 -0
- data/lib/aws/api_config/EMR-2009-03-31.yml +349 -0
- data/lib/aws/auto_scaling.rb +8 -8
- data/lib/aws/auto_scaling/group.rb +2 -2
- data/lib/aws/auto_scaling/instance.rb +1 -1
- data/lib/aws/auto_scaling/launch_configuration.rb +4 -4
- data/lib/aws/auto_scaling/launch_configuration_collection.rb +11 -11
- data/lib/aws/auto_scaling/scaling_policy.rb +1 -1
- data/lib/aws/auto_scaling/scheduled_action.rb +1 -1
- data/lib/aws/auto_scaling/tag.rb +3 -3
- data/lib/aws/cloud_formation/stack.rb +7 -7
- data/lib/aws/cloud_formation/stack_collection.rb +13 -13
- data/lib/aws/cloud_formation/stack_event_collection.rb +2 -2
- data/lib/aws/cloud_formation/stack_resource.rb +1 -1
- data/lib/aws/cloud_formation/stack_resource_summary_collection.rb +10 -18
- data/lib/aws/cloud_formation/stack_summary_collection.rb +12 -16
- data/lib/aws/core.rb +7 -1
- data/lib/aws/core/collection.rb +12 -12
- data/lib/aws/core/configuration.rb +4 -0
- data/lib/aws/core/credential_providers.rb +23 -23
- data/lib/aws/core/inflection.rb +2 -0
- data/lib/aws/core/model.rb +6 -6
- data/lib/aws/core/policy.rb +102 -102
- data/lib/aws/core/resource.rb +81 -80
- data/lib/aws/core/response.rb +23 -23
- data/lib/aws/core/xml/frame.rb +4 -2
- data/lib/aws/dynamo_db/resource.rb +2 -2
- data/lib/aws/dynamo_db/table.rb +5 -5
- data/lib/aws/ec2/availability_zone.rb +2 -3
- data/lib/aws/ec2/export_task.rb +7 -7
- data/lib/aws/ec2/image.rb +5 -5
- data/lib/aws/ec2/instance.rb +40 -40
- data/lib/aws/ec2/instance_collection.rb +5 -2
- data/lib/aws/ec2/key_pair.rb +1 -1
- data/lib/aws/ec2/network_acl.rb +1 -1
- data/lib/aws/ec2/network_interface.rb +2 -2
- data/lib/aws/ec2/region.rb +1 -1
- data/lib/aws/ec2/resource.rb +1 -1
- data/lib/aws/ec2/route_table.rb +1 -1
- data/lib/aws/ec2/security_group.rb +4 -4
- data/lib/aws/ec2/subnet.rb +1 -1
- data/lib/aws/ec2/volume.rb +1 -1
- data/lib/aws/ec2/vpn_connection.rb +1 -1
- data/lib/aws/ec2/vpn_gateway.rb +2 -2
- data/lib/aws/elb/listener_opts.rb +1 -1
- data/lib/aws/elb/load_balancer.rb +5 -5
- data/lib/aws/elb/load_balancer_collection.rb +17 -9
- data/lib/aws/elb/load_balancer_policy.rb +2 -2
- data/lib/aws/emr.rb +84 -0
- data/lib/aws/emr/client.rb +309 -0
- data/lib/aws/emr/config.rb +18 -0
- data/lib/aws/emr/errors.rb +22 -0
- data/lib/aws/emr/instance_group.rb +138 -0
- data/lib/aws/emr/instance_group_collection.rb +82 -0
- data/lib/aws/emr/job_flow.rb +296 -0
- data/lib/aws/emr/job_flow_collection.rb +185 -0
- data/lib/aws/emr/request.rb +23 -0
- data/lib/aws/iam/access_key.rb +1 -1
- data/lib/aws/iam/account_alias_collection.rb +2 -2
- data/lib/aws/iam/client.rb +1 -1
- data/lib/aws/iam/group.rb +2 -2
- data/lib/aws/iam/policy_collection.rb +1 -1
- data/lib/aws/iam/server_certificate.rb +2 -2
- data/lib/aws/iam/signing_certificate.rb +1 -1
- data/lib/aws/iam/user.rb +2 -2
- data/lib/aws/iam/virtual_mfa_device.rb +1 -1
- data/lib/aws/s3/client.rb +57 -55
- data/lib/aws/s3/config.rb +2 -0
- data/lib/aws/s3/request.rb +14 -6
- data/lib/aws/simple_email_service/identity.rb +9 -7
- data/lib/aws/simple_workflow/domain.rb +1 -1
- data/lib/aws/simple_workflow/resource.rb +2 -2
- data/lib/aws/simple_workflow/workflow_execution.rb +5 -5
- data/lib/aws/sns/subscription_collection.rb +33 -35
- data/lib/aws/sns/topic_collection.rb +13 -18
- data/lib/aws/sns/topic_subscription_collection.rb +8 -9
- data/lib/aws/sqs/queue.rb +4 -4
- data/lib/aws/sqs/queue_collection.rb +17 -13
- metadata +13 -4
- data/lib/aws/cloud_formation/stack_summary.rb +0 -71
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
AWS::Core::Configuration.module_eval do
|
15
|
+
|
16
|
+
add_service 'EMR', 'emr', 'us-east-1.elasticmapreduce.amazonaws.com'
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
class EMR
|
16
|
+
module Errors
|
17
|
+
|
18
|
+
extend Core::LazyErrorClasses
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
class EMR
|
16
|
+
|
17
|
+
# @attr_reader [String] market
|
18
|
+
#
|
19
|
+
# @attr_reader [String] instance_role
|
20
|
+
#
|
21
|
+
# @attr_reader [String,nil] bid_price
|
22
|
+
#
|
23
|
+
# @attr_reader [String] instance_type
|
24
|
+
#
|
25
|
+
# @attr_reader [String] instance_request_count
|
26
|
+
#
|
27
|
+
# @attr_reader [String] instance_running_count
|
28
|
+
#
|
29
|
+
# @attr_reader [String] state
|
30
|
+
#
|
31
|
+
# @attr_reader [String] last_state_change_reason
|
32
|
+
#
|
33
|
+
# @attr_reader [Time] created_at
|
34
|
+
#
|
35
|
+
# @attr_reader [Time] started_at
|
36
|
+
#
|
37
|
+
# @attr_reader [Time] ready_at
|
38
|
+
#
|
39
|
+
# @attr_reader [Time] ended_at
|
40
|
+
#
|
41
|
+
class InstanceGroup < Core::Resource
|
42
|
+
|
43
|
+
# @private
|
44
|
+
def initialize job_flow, instance_group_id, options = {}
|
45
|
+
@job_flow = job_flow
|
46
|
+
@instance_group_id = instance_group_id
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [JobFlow]
|
51
|
+
attr_reader :job_flow
|
52
|
+
|
53
|
+
# @return [String]
|
54
|
+
attr_reader :instance_group_id
|
55
|
+
|
56
|
+
alias_method :id, :instance_group_id
|
57
|
+
|
58
|
+
# @attr_reader [String] name
|
59
|
+
attribute :name, :static => true
|
60
|
+
|
61
|
+
attribute :market, :static => true
|
62
|
+
|
63
|
+
attribute :instance_role, :static => true
|
64
|
+
|
65
|
+
attribute :bid_price, :static => true
|
66
|
+
|
67
|
+
attribute :instance_type, :static => true
|
68
|
+
|
69
|
+
attribute :instance_request_count
|
70
|
+
|
71
|
+
attribute :instance_running_count
|
72
|
+
|
73
|
+
attribute :state
|
74
|
+
|
75
|
+
attribute :last_state_change_reason
|
76
|
+
|
77
|
+
attribute :creation_date_time, :static => true, :alias => :created_at
|
78
|
+
|
79
|
+
attribute :start_date_time, :alias => :started_at
|
80
|
+
|
81
|
+
attribute :ready_date_time, :alias => :ready_at
|
82
|
+
|
83
|
+
attribute :end_date_time, :alias => :ended_at
|
84
|
+
|
85
|
+
populates_from(:describe_job_flows) do |resp|
|
86
|
+
find_in_response(resp)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Modifies the target size of this instance group.
|
90
|
+
# @param [Integer] count
|
91
|
+
# @return (see #modify)
|
92
|
+
def set_instance_count count
|
93
|
+
modify(:instance_count => count)
|
94
|
+
end
|
95
|
+
|
96
|
+
# @param [Hash] options
|
97
|
+
# @option options [Integer] :count The new target size for the
|
98
|
+
# instance group.
|
99
|
+
# @return [nil]
|
100
|
+
def modify options = {}
|
101
|
+
options[:instance_group_id] = instance_group_id
|
102
|
+
options[:instance_count] = options.delete(:count) if options[:count]
|
103
|
+
client.modify_instance_groups(:instance_groups => [options])
|
104
|
+
nil
|
105
|
+
end
|
106
|
+
|
107
|
+
# @return [Boolean] Returns +true+ if the instance group exists.
|
108
|
+
def exists?
|
109
|
+
!!find_in_response(get_resource)
|
110
|
+
end
|
111
|
+
|
112
|
+
protected
|
113
|
+
|
114
|
+
def resource_identifiers
|
115
|
+
[[:job_flow_id, job_flow.id], [:instance_group_id, id]]
|
116
|
+
end
|
117
|
+
|
118
|
+
def get_resource attr = nil
|
119
|
+
client.describe_job_flows(:job_flow_ids => [job_flow.id])
|
120
|
+
end
|
121
|
+
|
122
|
+
def find_in_response resp
|
123
|
+
data = nil
|
124
|
+
resp.data[:job_flows].each do |job|
|
125
|
+
if job[:job_flow_id] == job_flow.job_flow_id
|
126
|
+
job[:instances][:instance_groups].each do |ig|
|
127
|
+
if ig[:instance_group_id] == instance_group_id
|
128
|
+
data = ig
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
data
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
class EMR
|
16
|
+
class InstanceGroupCollection
|
17
|
+
|
18
|
+
include Core::Collection::Simple
|
19
|
+
|
20
|
+
# @param [JobFlow] job_flow
|
21
|
+
# @private
|
22
|
+
def initialize job_flow, options = {}
|
23
|
+
@job_flow = job_flow
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [JobFlow]
|
28
|
+
attr_reader :job_flow
|
29
|
+
|
30
|
+
# @param [String] instance_group_id
|
31
|
+
# @return [InstanceGroup] Returns an instance group with the given ID.
|
32
|
+
def [] instance_group_id
|
33
|
+
InstanceGroup.new(job_flow, instance_group_id)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Adds an instance group to the job flow.
|
37
|
+
# @param [String] role The role of the instance group in the cluster.
|
38
|
+
# @param [String] instance_type The Amazon EC2 instance type to use.
|
39
|
+
# @param [Integer] instance_count Target size of instances for the group.
|
40
|
+
# @param [Hash] options
|
41
|
+
# @option options [String] :name Friendly name given to the group.
|
42
|
+
# @option options [String] :market Market type of the Amazon EC2
|
43
|
+
# instances used to create a cluster node.
|
44
|
+
# @option opitons [Float,String] :bid_price Bid price for each Amazon
|
45
|
+
# EC2 instance in the instance group when launching nodes as
|
46
|
+
# spot instances, expressed in USD.
|
47
|
+
# @return [InstanceGroup]
|
48
|
+
def create role, instance_type, instance_count, options = {}
|
49
|
+
|
50
|
+
options[:instance_role] = role
|
51
|
+
options[:instance_type] = instance_type
|
52
|
+
options[:instance_count] = instance_count
|
53
|
+
options[:bid_price] = options[:bid_price].to_s if options[:bid_price]
|
54
|
+
|
55
|
+
client_opts = {}
|
56
|
+
client_opts[:job_flow_id] = job_flow.job_flow_id
|
57
|
+
client_opts[:instance_groups] = [options]
|
58
|
+
|
59
|
+
resp = client.add_instance_groups(client_opts)
|
60
|
+
|
61
|
+
self[resp.data[:instance_group_ids].first]
|
62
|
+
|
63
|
+
end
|
64
|
+
alias_method :add, :create
|
65
|
+
|
66
|
+
protected
|
67
|
+
|
68
|
+
def _each_item options = {}
|
69
|
+
job_flow.instance_group_details.each do |details|
|
70
|
+
|
71
|
+
group = InstanceGroup.new_from(
|
72
|
+
:describe_job_flows, details, job_flow,
|
73
|
+
details[:instance_group_id])
|
74
|
+
|
75
|
+
yield(group)
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,296 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
class EMR
|
16
|
+
|
17
|
+
#
|
18
|
+
# @attr_reader [String] name
|
19
|
+
# The name of the job flow.
|
20
|
+
#
|
21
|
+
# @attr_reader [String] ami_version
|
22
|
+
# The version of the AMI used to initialize Amazon EC2 instances in
|
23
|
+
# the job flow.
|
24
|
+
#
|
25
|
+
# @attr_reader [String,nil] log_uri
|
26
|
+
# The location in Amazon S3 where log files for the job are stored.
|
27
|
+
#
|
28
|
+
# @attr_reader [Array<String>] supported_products
|
29
|
+
# A list of strings set by third party software when the job flow is
|
30
|
+
# launched. If you are not using third party software to manage the
|
31
|
+
# job flow this value is empty.
|
32
|
+
#
|
33
|
+
# @attr_reader [Array<Hash>] bootstrap_actions
|
34
|
+
#
|
35
|
+
# @attr_reader [String] state
|
36
|
+
#
|
37
|
+
# @attr_reader [Time] created_at
|
38
|
+
#
|
39
|
+
# @attr_reader [Time] started_at
|
40
|
+
#
|
41
|
+
# @attr_reader [Time] ready_at
|
42
|
+
#
|
43
|
+
# @attr_reader [Time] ended_at
|
44
|
+
#
|
45
|
+
# @attr_reader [String] last_state_change_reason
|
46
|
+
#
|
47
|
+
# @attr_reader [String] master_instance_type
|
48
|
+
#
|
49
|
+
# @attr_reader [String] master_public_dns_name
|
50
|
+
#
|
51
|
+
# @attr_reader [String] master_instance_id
|
52
|
+
#
|
53
|
+
# @attr_reader [String] slave_instance_id
|
54
|
+
#
|
55
|
+
# @attr_reader [Integer] instance_count
|
56
|
+
#
|
57
|
+
# @attr_reader [Integer] normalized_instance_hours
|
58
|
+
#
|
59
|
+
# @attr_reader [String] ec2_key_name
|
60
|
+
#
|
61
|
+
# @attr_reader [String] ec2_subnet_id
|
62
|
+
#
|
63
|
+
# @attr_reader [String] availability_zone_name
|
64
|
+
#
|
65
|
+
# @attr_reader [Boolean] keep_job_flow_alive_when_no_steps
|
66
|
+
#
|
67
|
+
# @attr_reader [Boolean] termination_protected
|
68
|
+
#
|
69
|
+
# @attr_reader [String] hadoop_version
|
70
|
+
#
|
71
|
+
# @attr_reader [Array<Hash>] instance_group_details
|
72
|
+
#
|
73
|
+
# @attr_reader [Array<Hash>] step_details
|
74
|
+
#
|
75
|
+
class JobFlow < Core::Resource
|
76
|
+
|
77
|
+
# @param [String] job_flow_id
|
78
|
+
# @param [Hash] options
|
79
|
+
# @private
|
80
|
+
def initialize job_flow_id, options = {}
|
81
|
+
@job_flow_id = job_flow_id
|
82
|
+
super
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [String]
|
86
|
+
attr_reader :job_flow_id
|
87
|
+
|
88
|
+
alias_method :id, :job_flow_id
|
89
|
+
|
90
|
+
attribute :name, :static => true
|
91
|
+
|
92
|
+
attribute :ami_version, :static => true
|
93
|
+
|
94
|
+
attribute :log_uri, :static => true
|
95
|
+
|
96
|
+
attribute :supported_products, :static => true
|
97
|
+
|
98
|
+
## attributes from :execution_status_detail
|
99
|
+
|
100
|
+
attribute :state,
|
101
|
+
:from => [:execution_status_detail, :state]
|
102
|
+
|
103
|
+
attribute :creation_date_time,
|
104
|
+
:from => [:execution_status_detail, :creation_date_time],
|
105
|
+
:static => true,
|
106
|
+
:alias => :created_at
|
107
|
+
|
108
|
+
attribute :start_date_time,
|
109
|
+
:from => [:execution_status_detail, :start_date_time],
|
110
|
+
:alias => :started_at
|
111
|
+
|
112
|
+
attribute :ready_date_time,
|
113
|
+
:from => [:execution_status_detail, :ready_date_time],
|
114
|
+
:alias => :ready_at
|
115
|
+
|
116
|
+
attribute :end_date_time,
|
117
|
+
:from => [:execution_status_detail, :end_date_time],
|
118
|
+
:alias => :ended_at
|
119
|
+
|
120
|
+
attribute :last_state_change_reason,
|
121
|
+
:from => [:execution_status_detail, :last_state_change_reason]
|
122
|
+
|
123
|
+
## attributes from :instances
|
124
|
+
|
125
|
+
attribute :master_instance_type,
|
126
|
+
:from => [:instances, :master_instance_type]
|
127
|
+
|
128
|
+
attribute :master_public_dns_name,
|
129
|
+
:from => [:instances, :master_public_dns_name]
|
130
|
+
|
131
|
+
attribute :master_instance_id,
|
132
|
+
:from => [:instances, :master_instance_id]
|
133
|
+
|
134
|
+
attribute :slave_instance_type,
|
135
|
+
:from => [:instances, :slave_instance_type]
|
136
|
+
|
137
|
+
attribute :instance_count,
|
138
|
+
:from => [:instances, :instance_count]
|
139
|
+
|
140
|
+
attribute :normalized_instance_hours,
|
141
|
+
:from => [:instances, :normalized_instance_hours]
|
142
|
+
|
143
|
+
attribute :ec2_key_name,
|
144
|
+
:from => [:instances, :ec2_key_name]
|
145
|
+
|
146
|
+
attribute :ec2_subnet_id,
|
147
|
+
:from => [:instances, :ec2_subnet_id]
|
148
|
+
|
149
|
+
attribute :availability_zone_name,
|
150
|
+
:from => [:instances, :placement, :availability_zone]
|
151
|
+
|
152
|
+
attribute :keep_job_flow_alive_when_no_steps,
|
153
|
+
:from => [:instances, :keep_job_flow_alive_when_no_steps],
|
154
|
+
:alias => :keep_job_flow_alive_when_no_steps?
|
155
|
+
|
156
|
+
attribute :termination_protected,
|
157
|
+
:from => [:instances, :termination_protected],
|
158
|
+
:alias => :termination_protected?
|
159
|
+
|
160
|
+
attribute :hadoop_version,
|
161
|
+
:from => [:instances, :hadoop_version]
|
162
|
+
|
163
|
+
attribute :instance_group_details,
|
164
|
+
:from => [:instances, :instance_groups]
|
165
|
+
|
166
|
+
attribute :step_details, :from => :steps
|
167
|
+
|
168
|
+
attribute :bootstrap_actions
|
169
|
+
|
170
|
+
populates_from(:describe_job_flows) do |resp|
|
171
|
+
resp.data[:job_flows].find{|j| j[:job_flow_id] == job_flow_id }
|
172
|
+
end
|
173
|
+
|
174
|
+
# @return [EC2::Instance,nil]
|
175
|
+
def master_instance
|
176
|
+
if instance_id = master_instance_id
|
177
|
+
AWS::EC2.new(:config => config).instances[instance_id]
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# @return [EC2::Instance,nil]
|
182
|
+
def slave_instance
|
183
|
+
if instance_id = slave_instance_id
|
184
|
+
AWS::EC2.new(:config => config).instances[instance_id]
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# @return [EC2::AvailabilityZone,nil]
|
189
|
+
def availability_zone
|
190
|
+
if name = availability_zone_name
|
191
|
+
AWS::EC2.new(:config => config).availability_zones[name]
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# Adds one (or more) steps to the current job flow.
|
196
|
+
#
|
197
|
+
# emr.job_flows['job-flow-id'].add_steps([{
|
198
|
+
# :name => 'step-name',
|
199
|
+
# :action_on_failure => 'TERMINATE_JOB_FLOW',
|
200
|
+
# :hadoop_jar_step => {
|
201
|
+
# :jar => 'path/to/a/jar/file',
|
202
|
+
# :main_class => 'MainClassName',
|
203
|
+
# :args => %w(arg1 arg2 arg3)],
|
204
|
+
# :properties => [
|
205
|
+
# { :key => 'property-1-name', :value => 'property-1-value' }
|
206
|
+
# { :key => 'property-2-name', :value => 'property-2-value' }
|
207
|
+
# ],
|
208
|
+
# }
|
209
|
+
# }])
|
210
|
+
#
|
211
|
+
# @param [Array<Hash>] steps A list of one or more steps to add.
|
212
|
+
# Each step should be a hash with the following structure:
|
213
|
+
# * +:name+ - *required* - (String) The name of the job flow step.
|
214
|
+
# * +:action_on_failure+ - (String) Specifies the action to take if the
|
215
|
+
# job flow step fails.
|
216
|
+
# * +:hadoop_jar_step+ - *required* - (Hash) Specifies the JAR file
|
217
|
+
# used for the job flow step.
|
218
|
+
# * +:properties+ - (Array<Hash>) A list of Java properties that are
|
219
|
+
# set when the step runs. You can use these properties to pass key
|
220
|
+
# value pairs to your main function.
|
221
|
+
# * +:key+ - (String) The unique identifier of a key value pair.
|
222
|
+
# * +:value+ - (String) The value part of the identified key.
|
223
|
+
# * +:jar+ - *required* - (String) A path to a JAR file run during
|
224
|
+
# the step.
|
225
|
+
# * +:main_class+ - (String) The name of the main class in the
|
226
|
+
# specified Java file. If not specified, the JAR file should
|
227
|
+
# specify a Main-Class in its manifest file.
|
228
|
+
# * +:args+ - (Array<String>) A list of command line arguments passed
|
229
|
+
# to the JAR file's main function when executed.
|
230
|
+
#
|
231
|
+
# @return [nil]
|
232
|
+
#
|
233
|
+
def add_steps *steps
|
234
|
+
options = {}
|
235
|
+
options[:job_flow_id] = job_flow_id
|
236
|
+
options[:steps] = steps.flatten
|
237
|
+
client.add_job_flow_steps(options)
|
238
|
+
nil
|
239
|
+
end
|
240
|
+
|
241
|
+
# @return [InstanceGroupCollection]
|
242
|
+
def instance_groups
|
243
|
+
InstanceGroupCollection.new(self)
|
244
|
+
end
|
245
|
+
|
246
|
+
# Locks this job flow so the Amazon EC2 instances in the cluster
|
247
|
+
# cannot be terminated by user intervention, an API call, or in the
|
248
|
+
# event of a job-flow error.
|
249
|
+
# @return [nil]
|
250
|
+
def enable_termination_protection
|
251
|
+
set_termination_protection(true)
|
252
|
+
end
|
253
|
+
|
254
|
+
# Removes a lock on this job flow so the Amazon EC2 instances in the
|
255
|
+
# cluster may be terminated.
|
256
|
+
# @return [nil]
|
257
|
+
def disable_termination_protection
|
258
|
+
set_termination_protection(false)
|
259
|
+
end
|
260
|
+
|
261
|
+
# @param [Boolean] state
|
262
|
+
# @return [nil]
|
263
|
+
def set_termination_protection state
|
264
|
+
options = {}
|
265
|
+
options[:termination_protected] = state
|
266
|
+
options[:job_flow_ids] = [job_flow_id]
|
267
|
+
client.set_termination_protection(options)
|
268
|
+
nil
|
269
|
+
end
|
270
|
+
|
271
|
+
# Terminates the current job flow.
|
272
|
+
# @return [nil]
|
273
|
+
def terminate
|
274
|
+
client.terminate_job_flows(:job_flow_ids => [job_flow_id])
|
275
|
+
nil
|
276
|
+
end
|
277
|
+
alias_method :delete, :terminate
|
278
|
+
|
279
|
+
# @return [Boolean] Returns +true+ if the job flow exists.
|
280
|
+
def exists?
|
281
|
+
!get_resource.data[:job_flows].empty?
|
282
|
+
end
|
283
|
+
|
284
|
+
protected
|
285
|
+
|
286
|
+
def resource_identifiers
|
287
|
+
[[:job_flow_id, job_flow_id]]
|
288
|
+
end
|
289
|
+
|
290
|
+
def get_resource attr = nil
|
291
|
+
client.describe_job_flows(:job_flow_ids => [job_flow_id])
|
292
|
+
end
|
293
|
+
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|