ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/client/monitors/Heartbeat__Monitor.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/monitors/Heartbeat__Monitor.java (file contents):
Revision 1.2 by tdb, Mon Mar 5 15:47:48 2001 UTC vs.
Revision 1.3 by tdb, Mon Mar 5 23:14:30 2001 UTC

# Line 15 | Line 15 | import uk.ac.ukc.iscream.componentmanager.*;
15   * @author  $Author$
16   * @version $Id$
17   */
18 < public class Heartbeat__Monitor extends Thread implements PluginMonitor {
18 > public class Heartbeat__Monitor implements PluginMonitor, Runnable {
19  
20   //---FINAL ATTRIBUTES---
21  
# Line 26 | Line 26 | public class Heartbeat__Monitor extends Thread impleme
26      
27      public final String DESC = "Monitors Heartbeats.";
28      
29 +    public final int DEFAULT_CHECK_PERIOD = 60;
30 +    
31   //---STATIC METHODS---
32  
33   //---CONSTRUCTORS---
34  
35      public Heartbeat__Monitor() {
36 <        this.start();
36 >        new Thread(this).start();
37      }
38  
39   //---PUBLIC METHODS---
# Line 39 | Line 41 | public class Heartbeat__Monitor extends Thread impleme
41      public void run() {
42          ConfigurationProxy cp = ConfigurationProxy.getInstance();
43          while(true) {
44 <            // this cycle period could be done better, maybe ?
45 <            int checkPeriod = Integer.parseInt(cp.getProperty(_name, "Monitor.Heartbeat.checkPeriod"));
44 >            // this cycle period of this monitor's checks
45 >            int checkPeriod = 0;
46 >            try {
47 >                checkPeriod = Integer.parseInt(cp.getProperty(_name, "Monitor.Heartbeat.checkPeriod"));
48 >            } catch (PropertyNotFoundException e) {
49 >                checkPeriod = DEFAULT_CHECK_PERIOD;
50 >                _logger.write(toString(), Logger.WARNING, "Monitor.Heartbeat.checkPeriod value unavailable using default of " + checkPeriod + " seconds");
51 >            } catch (NumberFormatException e) {
52 >                checkPeriod = DEFAULT_CHECK_PERIOD;
53 >                _logger.write(toString(), Logger.WARNING, "Erronous Monitor.Heartbeat.checkPeriod value in configuration using default of " + checkPeriod + " seconds");
54 >            }
55              
56              // perform the checks (use HB hash, although they *should* be the same)
57              Iterator i = _hostsHB.keySet().iterator();
# Line 62 | Line 73 | public class Heartbeat__Monitor extends Thread impleme
73          Register reg = (Register) _hostsReg.get(source);
74          
75          // get host's HB interval (seconds)
76 <        // this should always exist
66 <        String HBint = cp.getProperty("Host."+source, "TCPUpdateTime");
76 >        // this should always exist, thus we set to 0
77          int hostHBinterval = 0;
78 <        if(HBint != null) {            
78 >        try {
79              hostHBinterval = Integer.parseInt(cp.getProperty("Host."+source, "TCPUpdateTime"));
80 <        }
81 <        else {
82 <            hostHBinterval = 60;
80 >        } catch (PropertyNotFoundException e) {
81 >            hostHBinterval = 0;
82 >            _logger.write(toString(), Logger.WARNING, "TCPUpdateTime value unavailable using default of " + hostHBinterval + " seconds");
83 >        } catch (NumberFormatException e) {
84 >            hostHBinterval = 0;
85 >            _logger.write(toString(), Logger.WARNING, "Erronous TCPUpdateTime value in configuration using default of " + hostHBinterval + " seconds");
86          }
87  
88          // get host's last HB time (seconds)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines