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.10 by ajm, Thu Mar 22 23:35:11 2001 UTC vs.
Revision 1.11 by ajm, Fri Mar 23 01:32:38 2001 UTC

# Line 10 | Line 10 | import uk.org.iscream.componentmanager.*;
10  
11   /**
12   * Skeleton class for Monitors
13 + * This skeleton reads packets from a queue designated
14 + * by the extending class, it then feeds the data to the analysePacket
15 + * method, which the extending class should implement.  The class
16 + * should then handle the monitoring for that packet.
17   *
18   * @author  $Author$
19   * @version $Id$
# Line 17 | Line 21 | import uk.org.iscream.componentmanager.*;
21   public abstract class MonitorSkeleton extends Thread implements PluginMonitor {
22  
23   //---FINAL ATTRIBUTES---
24 +
25 +    /**
26 +     * The current CVS revision of this class
27 +     */
28 +    public final String REVISION = "$Revision$";
29      
30   //---STATIC METHODS---
31  
32   //---CONSTRUCTORS---
33  
34 +    /**
35 +     * Constructs and start the monitor reading its data
36 +     */
37      public MonitorSkeleton() {
38          _logger.write(toString(), Logger.SYSINIT, "started.");
39          this.start();
# Line 29 | Line 41 | public abstract class MonitorSkeleton extends Thread i
41  
42   //---PUBLIC METHODS---
43  
44 +    /**
45 +     * Obtains data from the monitors data queue and
46 +     * passes the packet to the analysePacket method.
47 +     */
48      public void run() {
49          while(_running) {
50              try {
# Line 39 | Line 55 | public abstract class MonitorSkeleton extends Thread i
55          }
56      }
57      
58 +    /**
59 +     * Extending classes should override this method to
60 +     * analyse the given packet for the attribute
61 +     * they are responsible for.
62 +     */
63      protected abstract void analysePacket(XMLPacket packet);
64  
65 +    /**
66 +     * Once a Monitor has determined which threshold the given data packet
67 +     * is at, it should then call this method.  This method handles ALL
68 +     * the alerting logic to determine escalation of alerts.
69 +     * If it decides an alert needs to be send, it will send one using fireAlert.
70 +     *
71 +     * @param newThreshold the threshold that has been determined by the monitor
72 +     * @param attributeName the textual name of the attribute the monitor is responsible for
73 +     * @param reg the register that holds the current alert state for the machine/attribute
74 +     * @param source the source of the alert eg, hostname
75 +     * @param currentValue the data value for the attribute
76 +     */
77      protected void processAlert(int newThreshold, String attributeName, Register reg, String source, String currentValue) {
78          // decide what threshold level we're on, if we've changed, record that
79          if (newThreshold != reg.getLastThresholdLevel()) {
# Line 89 | Line 122 | public abstract class MonitorSkeleton extends Thread i
122      }
123  
124      /**
125 <     * return the String representation of what the monitor does
125 >     * Return the String representation of what the alerter does
126 >     *
127 >     * @return the description
128       */
129      public abstract String getDescription();
130  
131  
132   //---PRIVATE METHODS---
133  
134 <    protected void fireAlert(Register reg, int lastAlert, String source, String currentValue, String attributeName) {
134 >    /**
135 >     * Fires an alert.  This creates a new Alert object
136 >     * and populates it with the given alert information.
137 >     * It then adds the alert to the Alerter queue.
138 >     *
139 >     * This method should only be called by the processAlert method.
140 >     *
141 >     * @param reg the register holding the state values for the alert
142 >     * @param source the source of the alert eg, hostname
143 >     * @param currentValue the data value for the attribute
144 >     * @param attributeName the textual name of the attribute the alert is for
145 >     */
146 >    private void fireAlert(Register reg, int lastAlert, String source, String currentValue, String attributeName) {
147          int alertLevel = reg.getLastAlertLevel();
148          int thresholdLevel = reg.getLastThresholdLevel();
149          String thresholdValue = String.valueOf(reg.getThreshold(thresholdLevel));
# Line 115 | Line 162 | public abstract class MonitorSkeleton extends Thread i
162  
163   //---ACCESSOR/MUTATOR METHODS---
164  
165 +    /**
166 +     * Obtain the queue which contains the data
167 +     * the Monitor is reading.
168 +     * eg, MonitorManager.getInstance().getHeartbeatQueue()
169 +     */
170      protected abstract Queue getQueue();
171      
172 +    /**
173 +     * Create a queue ID on the feeding
174 +     * data queue
175 +     */
176      protected int getQueueId() {
177          if (_qID == -1) {
178              _qID = getQueue().getQueue();
# Line 127 | Line 183 | public abstract class MonitorSkeleton extends Thread i
183  
184   //---ATTRIBUTES---
185  
186 +    /**
187 +     * This holds a reference to the
188 +     * system logger that is being used.
189 +     */
190      protected Logger _logger = ReferenceManager.getInstance().getLogger();
191  
192 <    protected Queue _alerterQueue = ClientMain._alerterQueue;
192 >    /**
193 >     * A reference to the Alerter queue, into which
194 >     * all new alerts will be placed.
195 >     */
196 >    protected Queue _alerterQueue = AlerterManager.getInstance().getQueue();
197      
198 +    /**
199 +     * The ID of the queue the monitor will use.
200 +     * Initially -1, but initialised on first use.
201 +     */
202      protected int _qID = -1;
203      
204 +    /**
205 +     * The state of the alerter thread
206 +     */
207      protected boolean _running = true;
208  
209   //---STATIC ATTRIBUTES---

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines