Masato Taruishi
taru****@users*****
2004年 9月 23日 (木) 04:03:19 JST
=================================================================== RCS file: demo/haviewer/lib/haviewer/haviewer.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- demo/haviewer/lib/haviewer/haviewer.rb 2004/09/16 06:04:43 1.5 +++ demo/haviewer/lib/haviewer/haviewer.rb 2004/09/22 19:03:19 1.6 @@ -20,6 +20,17 @@ $haview.glade["entry_update_error"].hide end +def on_refresh_clicked + $threads.each do |t| + t.kill + end + HAViewer::UltraPossumHost.set_conf( UltraPossum::Config.new ) + $haview.views.each do |key,view| + view.refresh + end + thread_start +end + class HAViewer Hosts = [] @@ -134,6 +145,9 @@ def update(host) end + def refresh + end + end @@ -156,6 +170,24 @@ end +def thread_start + HAViewer::Hosts.each do |host| + $haview.views.each do |name,view| + view.update(host) + end + $threads << Thread.new { + while(1) do + host.update + $haview.views.each do |name,view| + view.update(host) + $haview.update + end + sleep 5 + end + } + end +end + require 'haviewer/ultrapossum' Gtk.init @@ -166,20 +198,9 @@ $haview.add_view( "config", HAViewer::UltraPossum::ConfigView.new($haview) ) $haview.glade["dialog1"].set_title( "UltraPossum HA Viewer (#{HAViewer::UltraPossumHost.conf["ORGANIZATION"]})" ) $haview.update -HAViewer::Hosts.each do |host| - $haview.views.each do |name,view| - view.update(host) - end - Thread.new { - while(1) do - host.update - $haview.views.each do |name,view| - view.update(host) - $haview.update - end - sleep 5 - end - } -end +$threads = [] +thread_start + + Gtk.main =================================================================== RCS file: demo/haviewer/lib/haviewer/ultrapossum.rb,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- demo/haviewer/lib/haviewer/ultrapossum.rb 2004/09/17 06:35:05 1.10 +++ demo/haviewer/lib/haviewer/ultrapossum.rb 2004/09/22 19:03:19 1.11 @@ -45,6 +45,7 @@ def UltraPossumHost.set_conf( conf ) @@conf = conf + UltraPossumHost.update_hosts end def initialize( host, type ) @@ -131,8 +132,8 @@ end - UltraPossumHosts = [] - begin + @@hash = {} + def UltraPossumHost.update_hosts hash = {} ary = [ UltraPossumHost.conf["MASTER"], UltraPossumHost.conf["BACKUP"], UltraPossumHost.conf["SYNCBACKUPS"] ] ary.each do |val| @@ -140,24 +141,34 @@ host = nil val.split(' ').each do |s| host = UltraPossumHost.new(s,"master") - if hash[s].nil? + hash[s] = host + if @@hash[s].nil? UltraPossumHosts << host Hosts << host - hash[s] = host + @@hash[s] = host end end end if ! UltraPossumHost.conf["SLAVES"].nil? UltraPossumHost.conf["SLAVES"].split(' ').each do |s| host = UltraPossumHost.new(s,"slave") - if hash[s].nil? + hash[s] = host + if @@hash[s].nil? UltraPossumHosts << host Hosts << host - hash[s] = host + @@hash[s] = host end end end + ( @@hash.keys - hash.keys ).each do |host| + Hosts.delete(@@hash[host]) + UltraPossumHosts.delete(@@hash[host]) + @@hash.delete(host) + end end + + UltraPossumHosts = [] + UltraPossumHost.update_hosts UltraPossumHost.update_latest_entryCSN class UltraPossum < HAViewer::View @@ -171,16 +182,22 @@ Column.size.times do |i| @columns << Gtk::TreeViewColumn.new(Column[i], Gtk::CellRendererText.new, { :markup => i }) end - @row = {} - UltraPossumHosts.each do |host| - @row[host] =****@list***** + @columns.each do |val| + @glade["treeview1"].append_column(val) end @master_icon = Signal::SignalFactory.create @slave_icon = Signal::SignalFactory.create - columns.each do |val| - @glade["treeview1"].append_column(val) + refresh + end + + def refresh + @list.clear + @row = {} + UltraPossumHosts.each do |host| + @row[host] =****@list***** + update(host) end - @glade["treeview1"].set_model(list) + @glade["treeview1"].set_model(@list) end def update(host) @@ -290,14 +307,19 @@ Column.size.times do |i| @columns << Gtk::TreeViewColumn.new(Column[i], Gtk::CellRendererText.new, { :markup => i }) end - @row = {} - UltraPossumHosts.each do |host| - @row[host] =****@list***** - end @columns.each do |val| @glade["treeview2"].append_column(val) end @glade["treeview2"].set_model(@list) + refresh + end + + def refresh + @list.clear + @row = {} + UltraPossumHosts.each do |host| + @row[host] =****@list***** + end end def update(host) @@ -323,17 +345,23 @@ Column.size.times do |i| @columns << Gtk::TreeViewColumn.new(Column[i], Gtk::CellRendererText.new, { :markup => i }) end + @columns.each do |val| + @glade["treeview3"].append_column(val) + end + @glade["treeview3"].set_model(@list) + refresh + end + + def refresh + @list.clear @row = {} UltraPossumHost.conf.keys.sort.each do |key| @row[key] =****@list***** @list.set_value(@row[key], 0, key ) @list.set_value(@row[key], 1, UltraPossumHost.conf[key] ) end - @columns.each do |val| - @glade["treeview3"].append_column(val) - end - @glade["treeview3"].set_model(@list) end + end end