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/MonitorSkeleton.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/MonitorSkeleton.java (file contents):
Revision 1.3 by ajm, Fri Mar 9 03:30:54 2001 UTC vs.
Revision 1.8 by ajm, Thu Mar 22 18:28:17 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 < package uk.ac.ukc.iscream.client;
2 > package uk.org.iscream.client;
3  
4   //---IMPORTS---
5   import java.util.HashMap;
6 < import uk.ac.ukc.iscream.client.*;
7 < import uk.ac.ukc.iscream.core.*;
8 < import uk.ac.ukc.iscream.util.*;
9 < import uk.ac.ukc.iscream.componentmanager.*;
6 > import uk.org.iscream.client.*;
7 > import uk.org.iscream.core.*;
8 > import uk.org.iscream.util.*;
9 > import uk.org.iscream.componentmanager.*;
10  
11   /**
12   * Skeleton class for Monitors
# Line 14 | Line 14 | import uk.ac.ukc.iscream.componentmanager.*;
14   * @author  $Author$
15   * @version $Id$
16   */
17 < public abstract class MonitorSkeleton implements PluginMonitor {
17 > public abstract class MonitorSkeleton extends Thread implements PluginMonitor {
18  
19   //---FINAL ATTRIBUTES---
20      
# Line 22 | Line 22 | public abstract class MonitorSkeleton implements Plugi
22  
23   //---CONSTRUCTORS---
24  
25 +    public MonitorSkeleton() {
26 +        this.start();
27 +    }
28 +
29   //---PUBLIC METHODS---
30  
31 <    public abstract void analysePacket(XMLPacket packet);
31 >    public void run() {
32 >        while(_running) {
33 >            try {
34 >                analysePacket((XMLPacket) getQueue().get(getQueueId()));
35 >            } catch (InvalidQueueException e) {
36 >                _logger.write(this.toString(), Logger.ERROR, "Unable to get queue.");
37 >            }
38 >        }
39 >    }
40 >    
41 >    protected abstract void analysePacket(XMLPacket packet);
42  
43 <    public void processAlert(int newThreshold, String attributeName, Register reg, String source, String currentValue) {
43 >    protected void processAlert(int newThreshold, String attributeName, Register reg, String source, String currentValue) {
44          // decide what threshold level we're on, if we've changed, record that
45          if (newThreshold != reg.getLastThresholdLevel()) {
46              reg.setLastThresholdLevel(newThreshold);
# Line 86 | Line 100 | public abstract class MonitorSkeleton implements Plugi
100          int thresholdLevel = reg.getLastThresholdLevel();
101          String thresholdValue = String.valueOf(reg.getThreshold(thresholdLevel));
102          String timeout = String.valueOf(reg.getAlertTimeout(reg.getLastAlertLevel()) / 1000);
103 <        if (thresholdLevel == Alert.thresholdNORMAL) {
103 >        // ensures we display a nice thing if its -1.0
104 >        if (thresholdValue.equals("-1.0")) {
105              thresholdValue = "-";
106          }
107          if (alertLevel == Alert.alertOK) {
# Line 99 | Line 114 | public abstract class MonitorSkeleton implements Plugi
114  
115   //---ACCESSOR/MUTATOR METHODS---
116  
117 +    protected abstract Queue getQueue();
118 +    
119 +    protected int getQueueId() {
120 +        if (_qID == -1) {
121 +            _qID = getQueue().getQueue();
122 +        }
123 +        return _qID;
124 +    }
125 +
126   //---ATTRIBUTES---
127  
128      protected Logger _logger = ReferenceManager.getInstance().getLogger();
129  
130      protected Queue _alerterQueue = ClientMain._alerterQueue;
131 +    
132 +    protected int _qID = -1;
133 +    
134 +    protected boolean _running = true;
135  
136   //---STATIC ATTRIBUTES---
137  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines