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.7 by tdb, Tue Mar 6 22:35:01 2001 UTC vs.
Revision 1.9 by tdb, Wed Mar 7 17:18:48 2001 UTC

# Line 53 | Line 53 | public class Heartbeat__Monitor extends MonitorSkeleto
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 = _hosts.keySet().iterator();
58 <            while(i.hasNext()) {
59 <                // get host
60 <                String source = (String) i.next();
61 <                // check it
62 <                boolean remove = analyseHB(source);
63 <                if(remove) {
64 <                    i.remove();
56 >            synchronized(this) {
57 >                // perform the checks (use HB hash, although they *should* be the same)
58 >                Iterator i = _hosts.keySet().iterator();
59 >                while(i.hasNext()) {
60 >                    // get host
61 >                    String source = (String) i.next();
62 >                    // check it
63 >                    boolean remove = analyseHB(source);
64 >                    if(remove) {
65 >                        i.remove();
66 >                    }
67                  }
68              }
69              
# Line 70 | Line 72 | public class Heartbeat__Monitor extends MonitorSkeleto
72          }
73      }
74      
75 <    public void analysePacket(XMLPacket packet) {
75 >    public synchronized void analysePacket(XMLPacket packet) {
76          if (packet.getParam("packet.attributes.type").equals("heartbeat")) {
77              String source = packet.getParam("packet.attributes.machine_name");
78              if (!_hosts.containsKey(source)) {
# Line 130 | Line 132 | public class Heartbeat__Monitor extends MonitorSkeleto
132          long lastHeartbeat = hbHolder.getLastHeartbeat();
133          // time since last heartbeat (seconds)
134          long timeSinceLastHB = (System.currentTimeMillis()/1000) - lastHeartbeat;
135 +        // time since (or until if negative) the expected heartbeat
136 +        long timeSinceExpectedHB = timeSinceLastHB + (long) hostHBinterval;
137          
138 +        // best do a check in case the expected heartbeat is in the future
139 +        if(timeSinceExpectedHB < 0) {
140 +            timeSinceExpectedHB = 0;
141 +        }
142 +        
143          // find out the threshold level we're at
144 <        int newThreshold = checkAttributeThreshold(timeSinceLastHB, reg);
144 >        int newThreshold = checkAttributeThreshold(timeSinceExpectedHB, reg);
145          
146          // process the alert
147 <        processAlert(newThreshold, 0, "Heartbeat", reg, source, String.valueOf(timeSinceLastHB));
147 >        processAlert(newThreshold, 0, "Heartbeat", reg, source, String.valueOf(timeSinceExpectedHB));
148          
149          if(reg.getLastAlertLevel(0) == Alert.alertFINAL) {
150              return true;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines