Class: TargetNode
- Inherits:
-
Object
- Object
- TargetNode
- Defined in:
- lib/ls4/command/top.rb
Instance Attribute Summary collapse
-
#nid ⇒ Object
readonly
Returns the value of attribute nid.
Instance Method Summary collapse
-
#initialize(nid, address, name, rsids, location, fault) ⇒ TargetNode
constructor
A new instance of TargetNode.
- #refresh_async ⇒ Object
- #refresh_async_get ⇒ Object
- #time_format(t) ⇒ Object
- #update_info(address, name, rsids, location, fault) ⇒ Object
Constructor Details
#initialize(nid, address, name, rsids, location, fault) ⇒ TargetNode
Returns a new instance of TargetNode.
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ls4/command/top.rb', line 89 def initialize(nid, address, name, rsids, location, fault) @nid = nid @address = address @name = name @rsids = rsids @location = location @fault = fault @time = Time.at(0) @before_read = 0 @before_write = 0 @futures = [] end |
Instance Attribute Details
#nid ⇒ Object (readonly)
Returns the value of attribute nid.
102 103 104 |
# File 'lib/ls4/command/top.rb', line 102 def nid @nid end |
Instance Method Details
#refresh_async ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/ls4/command/top.rb', line 112 def refresh_async s = $net.get_session(*@address) s.timeout = 3 @futures = [] @futures[0] = s.call_async(:stat, 'cmd_read') @futures[1] = s.call_async(:stat, 'cmd_write') @futures[2] = s.call_async(:stat, 'time') @futures[3] = s.call_async(:stat, 'db_items') now = Time.now @elapse = now - @time @time = now self end |
#refresh_async_get ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/ls4/command/top.rb', line 128 def refresh_async_get ar = Array.new(12) ar[0] = @nid ar[1] = @name ar[2] = @address.to_s ar[3] = @location ar[4] = @rsids.join(',') if @fault ar[5] = "FAULT node" return ar end begin nread = @futures[0].get nwrite = @futures[1].get time = @futures[2].get db_items = @futures[3].get psread = (nread - @before_read ) / @elapse pswrite = (nwrite - @before_write) / @elapse @before_read = nread @before_write = nwrite ar[5] = nread ar[6] = nwrite ar[7] = psread.to_i ar[8] = pswrite.to_i ar[9] = (psread + pswrite).to_i ar[10] = db_items ar[11] = time_format(time) rescue @before_read = 0 @before_write = 0 ar[5] = "error: #{$!.to_s}" end ar end |
#time_format(t) ⇒ Object
169 170 171 172 173 174 175 |
# File 'lib/ls4/command/top.rb', line 169 def time_format(t) if t Time.at(t).strftime(TIME_FORMAT) else "" end end |
#update_info(address, name, rsids, location, fault) ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/ls4/command/top.rb', line 104 def update_info(address, name, rsids, location, fault) @address = address @name = name @rsids = rsids @location = location @fault = fault end |