Class: Pwrake::TaskProperty

Inherits:
Object
  • Object
show all
Defined in:
lib/pwrake/task/task_property.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#allowObject (readonly)

Returns the value of attribute allow.



5
6
7
# File 'lib/pwrake/task/task_property.rb', line 5

def allow
  @allow
end

#denyObject (readonly)

Returns the value of attribute deny.



5
6
7
# File 'lib/pwrake/task/task_property.rb', line 5

def deny
  @deny
end

#disable_stealObject (readonly)

Returns the value of attribute disable_steal.



5
6
7
# File 'lib/pwrake/task/task_property.rb', line 5

def disable_steal
  @disable_steal
end

#exclusiveObject (readonly)

Returns the value of attribute exclusive.



5
6
7
# File 'lib/pwrake/task/task_property.rb', line 5

def exclusive
  @exclusive
end

#ncoreObject (readonly)

Returns the value of attribute ncore.



5
6
7
# File 'lib/pwrake/task/task_property.rb', line 5

def ncore
  @ncore
end

#order_allow_denyObject (readonly)

Returns the value of attribute order_allow_deny.



5
6
7
# File 'lib/pwrake/task/task_property.rb', line 5

def order_allow_deny
  @order_allow_deny
end

#reserveObject (readonly)

Returns the value of attribute reserve.



5
6
7
# File 'lib/pwrake/task/task_property.rb', line 5

def reserve
  @reserve
end

#retryObject (readonly)

Returns the value of attribute retry.



5
6
7
# File 'lib/pwrake/task/task_property.rb', line 5

def retry
  @retry
end

#subflowObject

Returns the value of attribute subflow.



7
8
9
# File 'lib/pwrake/task/task_property.rb', line 7

def subflow
  @subflow
end

Instance Method Details

#accept_host(host_info) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/pwrake/task/task_property.rb', line 65

def accept_host(host_info)
  return true unless host_info
  if @disable_steal && host_info.steal_flag
    #Log.debug("@disable_steal && host_info.steal_flag")
    return false
  end
  hn = host_info.name
  if @allow
    if @deny
      if @order_allow_deny
        return false if !File.fnmatch(@allow,hn) || File.fnmatch(@deny,hn)
      else
        return false if File.fnmatch(@deny,hn) && !File.fnmatch(@allow,hn)
      end
    else
      return false if !File.fnmatch(@allow,hn)
    end
  else
    if @deny
      return false if File.fnmatch(@deny,hn)
    end
  end
  return true
end

#merge(prop) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/pwrake/task/task_property.rb', line 48

def merge(prop)
  @ncore = prop.ncore if prop.ncore
  @exclusive = prop.exclusive if prop.exclusive
  @reserve = prop.reserve if prop.reserve
  @allow = prop.allow if prop.allow
  @deny = prop.deny if prop.deny
  @order_allow_deny = prop.order_allow_deny if prop.order_allow_deny
  @retry = prop.retry if prop.retry
  @disable_steal = prop.disable_steal if prop.disable_steal
  @subflow = prop.subflow if prop.subflow
  @use_cores = nil
end

#n_used_cores(host_info = nil) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/pwrake/task/task_property.rb', line 90

def n_used_cores(host_info=nil)
  n = use_cores
  if n == 1
    return 1
  elsif host_info
    return host_info.check_cores(n)
  elsif n < 1
    m = "invalid for use_cores=#{n}"
    Log.fatal m
    raise RuntimeError,m
  end
  return n
end

#parse_description(description) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/pwrake/task/task_property.rb', line 9

def parse_description(description)
  if /\bn_?cores?[=:]\s*([+-]?\d+)/i =~ description
    @ncore = $1.to_i
  end
  if /\bretry[=:]\s*(\d+)/i =~ description
    @retry = $1.to_i
  end
  if /\bexclusive[=:]\s*(\S+)/i =~ description
    if /^(y|t)/i =~ $1
      @exclusive = true
    end
  end
  if /\breserve[=:]\s*(\S+)/i =~ description
    if /^(y|t)/i =~ $1
      @reserve = true
    end
  end
  if /\ballow[=:]\s*(\S+)/i =~ description
    @allow = $1
  end
  if /\bdeny[=:]\s*(\S+)/i =~ description
    @deny = $1
  end
  if /\border[=:]\s*(\S+)/i =~ description
    case $1
    when /allow,deny/i
      @order_allow_deny = true
    when /deny,allow/i
      @order_allow_deny = false
    end
  end
  if /\bsteal[=:]\s*(\S+)/i =~ description
    if /^(n|f)/i =~ $1
      @disable_steal = true
    end
  end
  @use_cores = nil
end

#use_coresObject



61
62
63
# File 'lib/pwrake/task/task_property.rb', line 61

def use_cores
  @use_cores ||= (@exclusive) ? 0 : (@ncore || 1)
end