Class: Pwrake::HostInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/pwrake/option/host_map.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, id, ncore, weight, group = nil) ⇒ HostInfo

Returns a new instance of HostInfo.



5
6
7
8
9
10
11
12
13
14
# File 'lib/pwrake/option/host_map.rb', line 5

def initialize(name,id,ncore,weight,group=nil)
  @name = name
  @ncore = ncore
  @weight = weight || 1.0
  @group = group || 0
  @id = id
  @continuous_fail = 0
  @total_fail = 0
  @count_task = 0
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



16
17
18
# File 'lib/pwrake/option/host_map.rb', line 16

def group
  @group
end

#idObject (readonly)

Returns the value of attribute id.



16
17
18
# File 'lib/pwrake/option/host_map.rb', line 16

def id
  @id
end

#idle_coresObject

Returns the value of attribute idle_cores.



17
18
19
# File 'lib/pwrake/option/host_map.rb', line 17

def idle_cores
  @idle_cores
end

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/pwrake/option/host_map.rb', line 16

def name
  @name
end

#ncoreObject (readonly)

Returns the value of attribute ncore.



16
17
18
# File 'lib/pwrake/option/host_map.rb', line 16

def ncore
  @ncore
end

#steal_flagObject (readonly)

Returns the value of attribute steal_flag.



16
17
18
# File 'lib/pwrake/option/host_map.rb', line 16

def steal_flag
  @steal_flag
end

#weightObject (readonly)

Returns the value of attribute weight.



16
17
18
# File 'lib/pwrake/option/host_map.rb', line 16

def weight
  @weight
end

Instance Method Details

#busy(n) ⇒ Object



33
34
35
36
37
# File 'lib/pwrake/option/host_map.rb', line 33

def busy(n)
  @busy_cores += n
  @idle_cores -= n
  @idle_cores + @busy_cores < 1 # all retired
end

#decrease(n) ⇒ Object



39
40
41
42
# File 'lib/pwrake/option/host_map.rb', line 39

def decrease(n)
  @idle_cores -= n
  @idle_cores + @busy_cores < 1 # all retired
end

#idle(n) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/pwrake/option/host_map.rb', line 25

def idle(n)
  @busy_cores -= n
  @idle_cores += n
  @idle_cores -= @retire
  @retire = 0
  @idle_cores + @busy_cores < 1 # all retired
end

#retire(n) ⇒ Object



51
52
53
54
# File 'lib/pwrake/option/host_map.rb', line 51

def retire(n)
  @retire += n
  Log.debug "retire n=#{n}, host=#{@name}"
end

#set_ncore(n) ⇒ Object



19
20
21
22
23
# File 'lib/pwrake/option/host_map.rb', line 19

def set_ncore(n)
  @retire = 0
  @busy_cores = 0
  @ncore = @idle_cores = n
end

#steal_phaseObject



44
45
46
47
48
49
# File 'lib/pwrake/option/host_map.rb', line 44

def steal_phase
  @steal_flag = true
  t = yield(self)
  @steal_flag = false
  t
end

#task_result(result) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/pwrake/option/host_map.rb', line 56

def task_result(result)
  @count_task += 1
  case result
  when "end"
    @continuous_fail = 0
  when "fail"
    @continuous_fail += 1
    @total_fail += 1
  else
    raise "unknown result: #{result}"
  end
  @continuous_fail
end