Class: Pwrake::TaskProperty
- Inherits:
-
Object
- Object
- Pwrake::TaskProperty
- Defined in:
- lib/pwrake/task/task_property.rb
Instance Attribute Summary collapse
-
#allow ⇒ Object
readonly
Returns the value of attribute allow.
-
#deny ⇒ Object
readonly
Returns the value of attribute deny.
-
#disable_steal ⇒ Object
readonly
Returns the value of attribute disable_steal.
-
#exclusive ⇒ Object
readonly
Returns the value of attribute exclusive.
-
#ncore ⇒ Object
readonly
Returns the value of attribute ncore.
-
#order_allow_deny ⇒ Object
readonly
Returns the value of attribute order_allow_deny.
-
#retry ⇒ Object
readonly
Returns the value of attribute retry.
Instance Method Summary collapse
- #acceptable_for(host_info) ⇒ Object
- #n_used_cores(host_info = nil) ⇒ Object
- #parse_description(description) ⇒ Object
Instance Attribute Details
#allow ⇒ Object (readonly)
Returns the value of attribute allow.
5 6 7 |
# File 'lib/pwrake/task/task_property.rb', line 5 def allow @allow end |
#deny ⇒ Object (readonly)
Returns the value of attribute deny.
5 6 7 |
# File 'lib/pwrake/task/task_property.rb', line 5 def deny @deny end |
#disable_steal ⇒ Object (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 |
#exclusive ⇒ Object (readonly)
Returns the value of attribute exclusive.
5 6 7 |
# File 'lib/pwrake/task/task_property.rb', line 5 def exclusive @exclusive end |
#ncore ⇒ Object (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_deny ⇒ Object (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 |
#retry ⇒ Object (readonly)
Returns the value of attribute retry.
5 6 7 |
# File 'lib/pwrake/task/task_property.rb', line 5 def retry @retry end |
Instance Method Details
#acceptable_for(host_info) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/pwrake/task/task_property.rb', line 41 def acceptable_for(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 ncore = (@exclusive) ? 0 : (@ncore || 1) if ncore > 0 return false if ncore > host_info.idle_cores else n = host_info.ncore + ncore return false if n < 1 || n > host_info.idle_cores 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 |
#n_used_cores(host_info = nil) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/pwrake/task/task_property.rb', line 73 def n_used_cores(host_info=nil) nc_node = host_info && host_info.ncore if @ncore.nil? return 1 elsif @ncore > 0 if nc_node && @ncore > nc_node m = "ncore=#{@ncore} must be <= nc_node=#{nc_node}" Log.fatal m raise RuntimeError,m end return @ncore else if nc_node.nil? m = "host_info.ncore is not set" Log.fatal m raise RuntimeError,m end n = @ncore + nc_node if n > 0 return n else m = "ncore+nc_node=#{n} must be > 0" Log.fatal m raise RuntimeError,m end end end |
#parse_description(description) ⇒ Object
8 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 |
# File 'lib/pwrake/task/task_property.rb', line 8 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 /\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 end |