Class: UnitHosting::Hadoop::ClusterManger

Inherits:
Object
  • Object
show all
Defined in:
lib/unit_hosting/hadoop/cluster_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_group) ⇒ ClusterManger

Returns a new instance of ClusterManger.



16
17
18
19
# File 'lib/unit_hosting/hadoop/cluster_manager.rb', line 16

def initialize server_group
  @group = UnitHosting::VmGroup.load(server_group)
  update
end

Instance Attribute Details

#clustersObject (readonly)

Returns the value of attribute clusters.



8
9
10
# File 'lib/unit_hosting/hadoop/cluster_manager.rb', line 8

def clusters
  @clusters
end

#groupObject (readonly)

Returns the value of attribute group.



8
9
10
# File 'lib/unit_hosting/hadoop/cluster_manager.rb', line 8

def group
  @group
end

#masterObject (readonly)

Returns the value of attribute master.



8
9
10
# File 'lib/unit_hosting/hadoop/cluster_manager.rb', line 8

def master
  @master
end

#nodesObject (readonly)

Returns the value of attribute nodes.



8
9
10
# File 'lib/unit_hosting/hadoop/cluster_manager.rb', line 8

def nodes
  @nodes
end

#slaveObject (readonly)

Returns the value of attribute slave.



8
9
10
# File 'lib/unit_hosting/hadoop/cluster_manager.rb', line 8

def slave
  @slave
end

#slavesObject (readonly)

Returns the value of attribute slaves.



8
9
10
# File 'lib/unit_hosting/hadoop/cluster_manager.rb', line 8

def slaves
  @slaves
end

Instance Method Details

#clear_varsObject



9
10
11
12
13
14
15
# File 'lib/unit_hosting/hadoop/cluster_manager.rb', line 9

def clear_vars
  @nodes = nil
  @master = nil
  @slave = nil
  @clusters = Array.new
  @slaves = Array.new
end

#updateObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/unit_hosting/hadoop/cluster_manager.rb', line 20

def update
  @vms = @group.vms
  clear_vars
  @vms.each do |instance_id,vm|
    @master = vm if vm.display_name == "master"
    @slave = vm if vm.display_name == "slave"
    @clusters << vm if vm.display_name == "slave-cluster"
  end
  @slaves = @clusters.clone
  @slaves << slave
  @nodes = @slaves.clone
  @nodes << @master
end