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.
-
#subflow ⇒ Object
Returns the value of attribute subflow.
Instance Method Summary collapse
- #accept_host(host_info) ⇒ Object
- #merge(prop) ⇒ Object
- #n_used_cores(host_info = nil) ⇒ Object
- #parse_description(description) ⇒ Object
- #use_cores(host_info) ⇒ 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 |
#subflow ⇒ Object
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
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/pwrake/task/task_property.rb', line 61 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
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pwrake/task/task_property.rb', line 42 def merge(prop) @ncore = prop.ncore if prop.ncore @exclusive = prop.exclusive if prop.exclusive @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 end |
#n_used_cores(host_info = nil) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/pwrake/task/task_property.rb', line 86 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
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 |
# 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 /\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 |
#use_cores(host_info) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/pwrake/task/task_property.rb', line 53 def use_cores(host_info) nc = (@exclusive) ? 0 : (@ncore || 1) if nc < 1 nc += host_info.ncore end return nc end |