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.10 by ajm, Thu Mar 22 23:35:11 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 +        _logger.write(toString(), Logger.SYSINIT, "started.");
27 +        this.start();
28 +    }
29 +
30   //---PUBLIC METHODS---
31  
32 <    public abstract void analysePacket(XMLPacket packet);
32 >    public void run() {
33 >        while(_running) {
34 >            try {
35 >                analysePacket((XMLPacket) getQueue().get(getQueueId()));
36 >            } catch (InvalidQueueException e) {
37 >                _logger.write(this.toString(), Logger.ERROR, "Unable to get queue.");
38 >            }
39 >        }
40 >    }
41 >    
42 >    protected abstract void analysePacket(XMLPacket packet);
43  
44 <    public void processAlert(int newThreshold, String attributeName, Register reg, String source, String currentValue) {
44 >    protected void processAlert(int newThreshold, String attributeName, Register reg, String source, String currentValue) {
45          // decide what threshold level we're on, if we've changed, record that
46          if (newThreshold != reg.getLastThresholdLevel()) {
47              reg.setLastThresholdLevel(newThreshold);
# Line 86 | Line 101 | public abstract class MonitorSkeleton implements Plugi
101          int thresholdLevel = reg.getLastThresholdLevel();
102          String thresholdValue = String.valueOf(reg.getThreshold(thresholdLevel));
103          String timeout = String.valueOf(reg.getAlertTimeout(reg.getLastAlertLevel()) / 1000);
104 <        if (thresholdLevel == Alert.thresholdNORMAL) {
104 >        // ensures we display a nice thing if its -1.0
105 >        if (thresholdValue.equals("-1.0")) {
106              thresholdValue = "-";
107          }
108          if (alertLevel == Alert.alertOK) {
# Line 99 | Line 115 | public abstract class MonitorSkeleton implements Plugi
115  
116   //---ACCESSOR/MUTATOR METHODS---
117  
118 +    protected abstract Queue getQueue();
119 +    
120 +    protected int getQueueId() {
121 +        if (_qID == -1) {
122 +            _qID = getQueue().getQueue();
123 +            _logger.write(toString(), Logger.DEBUG, "Assigned Queue - " + _qID);
124 +        }
125 +        return _qID;
126 +    }
127 +
128   //---ATTRIBUTES---
129  
130      protected Logger _logger = ReferenceManager.getInstance().getLogger();
131  
132      protected Queue _alerterQueue = ClientMain._alerterQueue;
133 +    
134 +    protected int _qID = -1;
135 +    
136 +    protected boolean _running = true;
137  
138   //---STATIC ATTRIBUTES---
139  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines