Class: AWS::EMR::InstanceGroupCollection

Inherits:
Object
  • Object
show all
Includes:
Core::Collection::Simple
Defined in:
lib/aws/emr/instance_group_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Core::Collection

#each, #each_batch, #enum, #first, #in_groups_of, #page

Instance Attribute Details

#job_flowJobFlow (readonly)

Returns:



28
29
30
# File 'lib/aws/emr/instance_group_collection.rb', line 28

def job_flow
  @job_flow
end

Instance Method Details

#[](instance_group_id) ⇒ InstanceGroup

Returns an instance group with the given ID.

Parameters:

  • instance_group_id (String)

Returns:

  • (InstanceGroup)

    Returns an instance group with the given ID.



32
33
34
# File 'lib/aws/emr/instance_group_collection.rb', line 32

def [] instance_group_id
  InstanceGroup.new(job_flow, instance_group_id)
end

#create(role, instance_type, instance_count, options = {}) ⇒ InstanceGroup Also known as: add

Adds an instance group to the job flow.

Parameters:

  • role (String)

    The role of the instance group in the cluster.

  • instance_type (String)

    The Amazon EC2 instance type to use.

  • instance_count (Integer)

    Target size of instances for the group.

  • options (Hash) (defaults to: {})
  • opitons (Hash)

    a customizable set of options

Options Hash (options):

  • :name (String)

    Friendly name given to the group.

  • :market (String)

    Market type of the Amazon EC2 instances used to create a cluster node.

Returns:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/aws/emr/instance_group_collection.rb', line 48

def create role, instance_type, instance_count, options = {}

  options[:instance_role] = role
  options[:instance_type] = instance_type
  options[:instance_count] = instance_count
  options[:bid_price] = options[:bid_price].to_s if options[:bid_price]

  client_opts = {}
  client_opts[:job_flow_id] = job_flow.job_flow_id
  client_opts[:instance_groups] = [options]

  resp = client.add_instance_groups(client_opts)

  self[resp.data[:instance_group_ids].first]

end