View Javadoc
1 /* 2 * Created on Oct 27, 2003 3 * 4 * To change the template for this generated file go to 5 * Window>Preferences>Java>Code Generation>Code and Comments 6 */ 7 package portaview.server; 8 9 import java.util.Iterator; 10 11 import portaview.Log; 12 import portaview.Registry; 13 import portaview.model.PortaViewCollection; 14 import portaview.model.PortaViewModel; 15 16 /*** 17 * Thread that periodically polls the remote PortaViews and check if you need to update them. 18 * @author William Lee 19 */ 20 public class PortaViewUpdateRunner extends Thread 21 { 22 private boolean shutdown = false; 23 private int POLL_TIME = 5000; 24 25 /*** 26 * The main loop in the thread. It currently waits 5 seconds before updating again. 27 */ 28 public void run() 29 { 30 while (shutdown == false) 31 { 32 try 33 { 34 Thread.sleep(POLL_TIME); 35 PortaViewCollection pvs = Registry.getServer().getRegisteredPortaViews(); 36 // compare the pvs with the list we want to get from the master server. 37 for (Iterator i = pvs.iterator(); i.hasNext();) 38 { 39 PortaViewModel element = (PortaViewModel) i.next(); 40 Log.debug( 41 "Updating PV: " 42 + element.getName() 43 + " at " 44 + element.getInetAddress()); 45 element.updateRemote(); 46 } 47 //Log.debug("Updating PV."); 48 if (shutdown) 49 break; 50 } 51 catch (InterruptedException e) 52 { 53 if (shutdown) 54 break; 55 } 56 } 57 } 58 59 /*** 60 * Shutdown this thread. 61 */ 62 public void shutdown() 63 { 64 shutdown = true; 65 this.interrupt(); 66 } 67 68 }

This page was automatically generated by Maven