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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/ClientMain.java (file contents):
Revision 1.16 by tdb, Thu Mar 15 22:12:22 2001 UTC vs.
Revision 1.19 by ajm, Fri Mar 23 02:30:44 2001 UTC

# Line 9 | Line 9 | import uk.org.iscream.util.*;
9  
10   /**
11   * A startup component for the Local Clients.
12 + * This class starts the CORBA client used for alerting
13 + * purposes.  It reads data using the ClientServant from CORBA
14 + * calls by the i-scream client interface.  This data is then
15 + * used by the MonitorManager to pass to Monitors.  Monitors then
16 + * analyse the data and raise alerts if needed, these are passed to
17 + * the Alerters, which send out alerts.  They are looked after by
18 + * the AlerterManager.
19   *
20   * @author  $Author$
21   * @version $Id$
# Line 35 | Line 42 | public class ClientMain implements Component {
42   //---PUBLIC METHODS---
43  
44      /**
45 <     * This starts the Local Client component
45 >     * This starts the Local Client component.
46 >     * This starts the ClientServant, the MonitorManager and
47 >     * the AlerterManager, aswell as initialising any queues
48 >     * and obtaining any initial configuration.
49 >     *
50 >     * @throws ComponentStartException if the component fails to start
51       */
52      public void start() throws ComponentStartException {
53          // get references to key objects
# Line 43 | Line 55 | public class ClientMain implements Component {
55  
56          _logger.write(toString(), Logger.SYSINIT, "coming up");
57          
58 <        // setup the queues, this must be done before both managers are setup
59 <        // setup a Queue for the servant -> monitor manager
48 <        _monitorQueue = new Queue();
49 <        // setup a Queue for the monitors -> alert manager
50 <        _alerterQueue = new Queue();
58 >        // get a reference to the configuration proxy
59 >        ConfigurationProxy cp = ConfigurationProxy.getInstance();
60          
61 +        // see if these Queue's need a size limit
62 +        try {
63 +            int queueSizeLimit = Integer.parseInt(cp.getProperty(NAME, "Queue.SizeLimit"));
64 +            String queueRemoveAlgorithm = cp.getProperty(NAME, "Queue.RemoveAlgorithm");
65 +            int algorithm = StringUtils.getStringPos(queueRemoveAlgorithm, Queue.algorithms);
66 +            if(algorithm != -1) {
67 +                _logger.write(toString(), Logger.DEBUG, "Starting 2 Queues with size limit of "+queueSizeLimit+", using remove algorithm "+queueRemoveAlgorithm);
68 +                // we have valid values, so lets start it.
69 +                _alerterQueue = new Queue(queueSizeLimit, algorithm);
70 +                _monitorQueue = new Queue(queueSizeLimit, algorithm);
71 +            }
72 +            else {
73 +                _logger.write(toString(), Logger.WARNING, "Bad Queue Algorithm configuration, not known: "+queueRemoveAlgorithm);
74 +                // just don't activate a limit
75 +                _alerterQueue = new Queue();
76 +                _monitorQueue = new Queue();
77 +            }
78 +        } catch (PropertyNotFoundException e) {
79 +            _logger.write(toString(), Logger.DEBUG, "Optional config not set: "+e);
80 +            // just don't activate a limit
81 +            _alerterQueue = new Queue();
82 +            _monitorQueue = new Queue();
83 +        } catch (NumberFormatException e) {
84 +            _logger.write(toString(), Logger.WARNING, "Bad Queue SizeLimit configuration: "+e);
85 +            // just don't activate a limit
86 +            _alerterQueue = new Queue();
87 +            _monitorQueue = new Queue();
88 +        }
89 +        
90 +        // startup monitors on these queues
91 +        try {
92 +            // try to get the interval, if this fails, we won't start up the monitor
93 +            int queueMonitorInterval = Integer.parseInt(cp.getProperty(NAME, "Queue.MonitorInterval"));
94 +            _alerterQueue.startMonitor(queueMonitorInterval*1000, _monitorQueue, NAME + " Alerter");
95 +            _monitorQueue.startMonitor(queueMonitorInterval*1000, _monitorQueue, NAME + " Monitor");
96 +        } catch (PropertyNotFoundException e) {
97 +            _logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e);
98 +        }        
99 +        
100          // setup the servant and connect
101          _logger.write(toString(), Logger.SYSINIT, "starting servant and connecting");          
102          try {
# Line 79 | Line 127 | public class ClientMain implements Component {
127          alertMan.start();
128        
129          _logger.write(toString(), Logger.SYSINIT, "started");
82        
130      }
131      
132      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines