ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/componentmanager/ComponentManager.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/componentmanager/ComponentManager.java (file contents):
Revision 1.32 by ajm, Thu Mar 1 16:49:49 2001 UTC vs.
Revision 1.40 by tdb, Sat May 18 18:16:01 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * Copyright (C) 2000-2002 i-scream
4 + *
5 + * This program is free software; you can redistribute it and/or
6 + * modify it under the terms of the GNU General Public License
7 + * as published by the Free Software Foundation; either version 2
8 + * of the License, or (at your option) any later version.
9 + *
10 + * This program is distributed in the hope that it will be useful,
11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 + * GNU General Public License for more details.
14 + *
15 + * You should have received a copy of the GNU General Public License
16 + * along with this program; if not, write to the Free Software
17 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 + */
19 +
20   //---PACKAGE DECLARATION---
21 < package uk.ac.ukc.iscream.componentmanager;
21 > package uk.org.iscream.cms.server.componentmanager;
22  
23   //---IMPORTS---
24   import java.util.*;
25   import java.io.*;
26 < import uk.ac.ukc.iscream.util.*;
26 > import uk.org.iscream.cms.server.util.*;
27  
28   /**
29   * The component manager is the starting point for all
# Line 12 | Line 31 | import uk.ac.ukc.iscream.util.*;
31   * It loads its initial system configuration from the
32   * default properties file, it then starts all the iscream
33   * components as specified in the default.properties under
34 < * uk.ac.ukc.iscream.ComponentList
34 > * uk.org.iscream.cms.server.ComponentList
35   *
36   * @author  $Author$
37   * @version $Id$
# Line 53 | Line 72 | public class ComponentManager {
72       * @param args the command line arguments
73       */
74      public static void main(String[] args) {
75 +        System.out.println("-----------------------------------------");
76          System.out.println("--- i-scream Server Component Manager ---");
77 +        System.out.println("---   (c) 2001 The i-scream Project   ---");
78 +        System.out.println("---    (http://www.i-scream.org.uk)   ---");
79 +        System.out.println("-----------------------------------------");
80          System.out.println("---          Starting System          ---");        
81          
82          // get the command line args
83          String defaultProperties = DEFAULTPROPERTIES;
84          String filterName = null;
85 +        String filterManagerName = null;
86          for(int i=0; i < args.length; i++) {
87              if(args[i].equals("-h")) {
88                  usage();
89              }
90              else if(args[i].equals("-f")) {
91 <                i++; filterName = args[i];
91 >                if(++i < args.length) {
92 >                    filterName = args[i];
93 >                }
94 >                else {
95 >                    usage();
96 >                }
97              }
98 +            else if(args[i].equals("-fm")) {
99 +                if(++i < args.length) {
100 +                    filterManagerName = args[i];
101 +                }
102 +                else {
103 +                    usage();
104 +                }
105 +            }
106              else if(args[i].equals("-l")) {
107 <                i++; defaultProperties = args[i];
107 >                if(++i < args.length) {
108 >                    defaultProperties = args[i];
109 >                }
110 >                else {
111 >                    usage();
112 >                }
113              }
114              else {
115                  usage();
# Line 96 | Line 138 | public class ComponentManager {
138          refman.activatePOA();
139          
140          // get the list of components
141 <        String componentList = System.getProperty("uk.ac.ukc.iscream.ComponentList");
141 >        String componentList = System.getProperty("uk.org.iscream.cms.server.ComponentList");
142          StringTokenizer st = new StringTokenizer(componentList, ";");
143 <        _componentsToStart = new ArrayList();
143 >        _componentsToStart = new LinkedList();
144          
145          // this could be done using reflection
146          // but..well..we don't ;-p
# Line 109 | Line 151 | public class ComponentManager {
151              
152              // ### This is where the list of supported components is checked! ###
153              if (componentName.equalsIgnoreCase("core")) {
154 <                component = new uk.ac.ukc.iscream.core.Core();
154 >                component = new uk.org.iscream.cms.server.core.Core();
155 >            // note the passing of the FilterManagers's name in its constructor
156              } else if (componentName.equalsIgnoreCase("filtermanager")) {
157 <                component = new uk.ac.ukc.iscream.filtermanager.FilterManager();
157 >                component = new uk.org.iscream.cms.server.filtermanager.FilterManager(filterManagerName);
158              } else if (componentName.equalsIgnoreCase("rootfilter")) {
159 <                component = new uk.ac.ukc.iscream.rootfilter.RootFilter();
159 >                component = new uk.org.iscream.cms.server.rootfilter.RootFilter();
160              } else if (componentName.equalsIgnoreCase("dbinterface")) {
161 <                component = new uk.ac.ukc.iscream.dbinterface.DBInterface();
161 >                component = new uk.org.iscream.cms.server.dbinterface.DBInterface();
162              } else if (componentName.equalsIgnoreCase("clientinterface")) {
163 <                component = new uk.ac.ukc.iscream.clientinterface.ClientInterfaceMain();
163 >                component = new uk.org.iscream.cms.server.clientinterface.ClientInterfaceMain();
164              // note the passing of the Filter's name in its constructor
165              } else if (componentName.equalsIgnoreCase("filter")) {
166 <                component = new uk.ac.ukc.iscream.filter.FilterMain(filterName);
166 >                component = new uk.org.iscream.cms.server.filter.FilterMain(filterName);
167              } else if (componentName.equalsIgnoreCase("client")) {
168 <                component = new uk.ac.ukc.iscream.client.ClientMain();
168 >                component = new uk.org.iscream.cms.server.client.ClientMain();
169              }
170              // ###  Add new component constructors in the above section! ###
171              
# Line 130 | Line 173 | public class ComponentManager {
173              if (component != null) {
174                  _componentsToStart.add(component);    
175              } else {
176 <                System.err.println(toString + ": WARNING unsupported component not started");
176 >                System.err.println(toString + ": WARNING unsupported component not started: "+componentName);
177              }
178          }
179          
# Line 140 | Line 183 | public class ComponentManager {
183          
184          String confTimeout = null;
185          try {
186 <            confTimeout = System.getProperty("uk.ac.ukc.iscream.ComponentTimeout");
186 >            confTimeout = System.getProperty("uk.org.iscream.cms.server.ComponentTimeout");
187              confTimeout.trim();
188              _startTimeout = Integer.parseInt(confTimeout);
189          } catch (NumberFormatException e) {
190              _startTimeout = DEFAULT_COMPONENT_START_TIMEOUT;
191 <            System.err.println(toString + ": unable to read uk.ac.ukc.iscream.ComponentTimeout value (" + confTimeout + "), using default!");
191 >            System.err.println(toString + ": unable to read uk.org.iscream.cms.server.ComponentTimeout value (" + confTimeout + "), using default!");
192          }
193          System.out.println(toString + ": using component start timeout of " + _startTimeout + " seconds");
194          
# Line 154 | Line 197 | public class ComponentManager {
197  
198              // block on the ORB...in time, management functionality can be placed here.
199              // if we detect a CORBA communication error, we'll restart all the components.
200 +            // !! this doesn't appear to work !!
201              while(true) {
202              try {
203                  refman.getORB().run();
# Line 170 | Line 214 | public class ComponentManager {
214       * This method calls the start() methods on all the components.
215       * If a component fails to start due to a CORBA communication
216       * problem, then it catches this and tries to start it again
217 <     * according to uk.ac.ukc.iscream.ComponentTimeout time.
217 >     * according to uk.org.iscream.cms.server.ComponentTimeout time.
218       *
219       * If the server dies and CORBA connections are lost, this method
220       * is called again.
# Line 184 | Line 228 | public class ComponentManager {
228          // maybe add support for a limited number of retries
229          while(tryAgain) {
230              Iterator i = _componentsToStart.iterator();
231 <            ArrayList failedComponents = new ArrayList();
231 >            LinkedList failedComponents = new LinkedList();
232              // go through all the components
233              while(i.hasNext()) {
234 <                try {
235 <                    component = (Component) i.next();
234 >                // get a refence to the component
235 >                component = (Component) i.next();
236 >                System.out.println(toString + ": dependency checking component - " + component.toString());
237 >                
238 >                // check it's dependencies
239 >                boolean depOK = component.depCheck();
240 >                if(depOK) {
241                      System.out.println(toString + ": starting component - " + component.toString());
242 <                    
243 <                    // start the component
244 <                    component.start();
245 <                    
246 <                // if we get this then there was a problem
247 <                // that we can't recover from
248 <                } catch (ComponentStartException e) {
249 <                    System.err.println(toString + ": ERROR starting component - " + component.toString());
250 <                    System.err.println(toString + ": component reports - " + e.getMessage());
251 <                    System.exit(1);
252 <
253 <                // if we get this exception then we've tried
254 <                // to talk to something which may not be up yet
255 <                // so we want to try again in a minute                
256 <                } catch(ComponentCORBAException e2) {
257 <                    System.err.println(toString + ": WARNING Component reported CORBA communications failure");
242 >                    // it should be ok to start the component
243 >                        try {    
244 >                            // start the component
245 >                        component.start();
246 >                    } catch (ComponentStartException e) {
247 >                        // if we get this then there was a problem
248 >                        // that we can't recover from
249 >                        System.err.println(toString + ": ERROR starting component - " + component.toString());
250 >                        System.err.println(toString + ": component reports - " + e.getMessage());
251 >                        System.exit(1);
252 >                    }
253 >                }
254 >                else {
255 >                    // it seems the depedencies failed
256 >                    // so we want to try again after a delay
257 >                    System.err.println(toString + ": WARNING Component reported dependency failure");
258                      System.err.println(toString + ": This could be because it can't communicate with components it needs.");
210                    System.err.println(toString + ": component reports - " + e2.getMessage());
259                      
260                      // make a list of the failed components
261                      failedComponents.add(component);
# Line 245 | Line 293 | public class ComponentManager {
293       * properly.
294       */
295      public static void usage() {
296 <        System.out.println("USAGE: java uk.ac.ukc.iscream.componentmanager.ComponentManager <option>");
296 >        System.out.println("USAGE: java uk.org.iscream.cms.server.componentmanager.ComponentManager <option>");
297          System.out.println("   or: java -jar iscream.jar <option>");
298          System.out.println("WHERE <option>:");
299          System.out.println("      -l <filename> - the location of initial system properties");
300          System.out.println("                      the default is ./etc/default.properties");
301          System.out.println("      -f <name>     - the name of the filter (if there is one configured");
302 +        System.out.println("      -fm <name>    - the name of the filter manager (if there is one configured");
303          System.out.println("      -h            - this help screen");
304          System.exit(1);
305      }
# Line 267 | Line 316 | public class ComponentManager {
316      
317   //---STATIC ATTRIBUTES---
318  
319 <    private static ArrayList _componentsToStart;
319 >    private static LinkedList _componentsToStart;
320      private static int _startTimeout = 0;
321  
322   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines