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.34 by tdb, Wed Mar 14 23:25:29 2001 UTC vs.
Revision 1.44 by tdb, Sun Aug 1 10:40:50 2004 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org
4 + * Copyright (C) 2000-2002 i-scream
5 + *
6 + * This program is free software; you can redistribute it and/or
7 + * modify it under the terms of the GNU General Public License
8 + * as published by the Free Software Foundation; either version 2
9 + * of the License, or (at your option) any later version.
10 + *
11 + * This program is distributed in the hope that it will be useful,
12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 + * GNU General Public License for more details.
15 + *
16 + * You should have received a copy of the GNU General Public License
17 + * along with this program; if not, write to the Free Software
18 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 + */
20 +
21   //---PACKAGE DECLARATION---
22 < package uk.org.iscream.componentmanager;
22 > package uk.org.iscream.cms.server.componentmanager;
23  
24   //---IMPORTS---
25   import java.util.*;
26   import java.io.*;
27 < import uk.org.iscream.util.*;
27 > import uk.org.iscream.cms.util.*;
28  
29   /**
30   * The component manager is the starting point for all
# Line 12 | Line 32 | import uk.org.iscream.util.*;
32   * It loads its initial system configuration from the
33   * default properties file, it then starts all the iscream
34   * components as specified in the default.properties under
35 < * uk.org.iscream.ComponentList
35 > * uk.org.iscream.cms.server.ComponentList
36   *
37   * @author  $Author$
38   * @version $Id$
# Line 39 | Line 59 | public class ComponentManager {
59      public static final String DEFAULTPROPERTIES = "./etc/default.properties";
60      
61      /**
62 <     * The default time to wait before retrying
62 >     * The default time to wait before retrying
63       * component.
64       */
65      public static final int DEFAULT_COMPONENT_START_TIMEOUT = 5;
# Line 53 | Line 73 | public class ComponentManager {
73       * @param args the command line arguments
74       */
75      public static void main(String[] args) {
76 +        System.out.println("-----------------------------------------");
77          System.out.println("--- i-scream Server Component Manager ---");
78 <        System.out.println("---          Starting System          ---");        
78 >        System.out.println("---   (c) 2001 The i-scream Project   ---");
79 >        System.out.println("---    (http://www.i-scream.org)   ---");
80 >        System.out.println("-----------------------------------------");
81 >        System.out.println("---          Starting System          ---");
82          
83          // get the command line args
84          String defaultProperties = DEFAULTPROPERTIES;
85          String filterName = null;
86 +        String filterManagerName = null;
87 +        String clientInterfaceName = null;
88          for(int i=0; i < args.length; i++) {
89              if(args[i].equals("-h")) {
90                  usage();
91              }
92              else if(args[i].equals("-f")) {
93 <                i++; filterName = args[i];
93 >                if(++i < args.length) {
94 >                    filterName = args[i];
95 >                }
96 >                else {
97 >                    usage();
98 >                }
99              }
100 +            else if(args[i].equals("-fm")) {
101 +                if(++i < args.length) {
102 +                    filterManagerName = args[i];
103 +                }
104 +                else {
105 +                    usage();
106 +                }
107 +            }
108 +            else if(args[i].equals("-ci")) {
109 +                if(++i < args.length) {
110 +                    clientInterfaceName = args[i];
111 +                }
112 +                else {
113 +                    usage();
114 +                }
115 +            }
116              else if(args[i].equals("-l")) {
117 <                i++; defaultProperties = args[i];
117 >                if(++i < args.length) {
118 >                    defaultProperties = args[i];
119 >                }
120 >                else {
121 >                    usage();
122 >                }
123              }
124              else {
125                  usage();
# Line 96 | Line 148 | public class ComponentManager {
148          refman.activatePOA();
149          
150          // get the list of components
151 <        String componentList = System.getProperty("uk.org.iscream.ComponentList");
151 >        String componentList = System.getProperty("uk.org.iscream.cms.server.ComponentList");
152          StringTokenizer st = new StringTokenizer(componentList, ";");
153          _componentsToStart = new LinkedList();
154          
# Line 109 | Line 161 | public class ComponentManager {
161              
162              // ### This is where the list of supported components is checked! ###
163              if (componentName.equalsIgnoreCase("core")) {
164 <                component = new uk.org.iscream.core.Core();
164 >                component = new uk.org.iscream.cms.server.core.Core();
165 >            // note the passing of the FilterManagers's name in its constructor
166              } else if (componentName.equalsIgnoreCase("filtermanager")) {
167 <                component = new uk.org.iscream.filtermanager.FilterManager();
167 >                component = new uk.org.iscream.cms.server.filtermanager.FilterManager(filterManagerName);
168              } else if (componentName.equalsIgnoreCase("rootfilter")) {
169 <                component = new uk.org.iscream.rootfilter.RootFilter();
117 <            } else if (componentName.equalsIgnoreCase("dbinterface")) {
118 <                component = new uk.org.iscream.dbinterface.DBInterface();
169 >                component = new uk.org.iscream.cms.server.rootfilter.RootFilter();
170              } else if (componentName.equalsIgnoreCase("clientinterface")) {
171 <                component = new uk.org.iscream.clientinterface.ClientInterfaceMain();
171 >                component = new uk.org.iscream.cms.server.clientinterface.ClientInterfaceMain(clientInterfaceName);
172              // note the passing of the Filter's name in its constructor
173              } else if (componentName.equalsIgnoreCase("filter")) {
174 <                component = new uk.org.iscream.filter.FilterMain(filterName);
174 >                component = new uk.org.iscream.cms.server.filter.FilterMain(filterName);
175              } else if (componentName.equalsIgnoreCase("client")) {
176 <                component = new uk.org.iscream.client.ClientMain();
176 >                component = new uk.org.iscream.cms.server.client.ClientMain();
177              }
178              // ###  Add new component constructors in the above section! ###
179              
180              // build the list of components to start
181              if (component != null) {
182 <                _componentsToStart.add(component);    
182 >                _componentsToStart.add(component);
183              } else {
184                  System.err.println(toString + ": WARNING unsupported component not started: "+componentName);
185              }
# Line 140 | Line 191 | public class ComponentManager {
191          
192          String confTimeout = null;
193          try {
194 <            confTimeout = System.getProperty("uk.org.iscream.ComponentTimeout");
194 >            confTimeout = System.getProperty("uk.org.iscream.cms.server.ComponentTimeout");
195              confTimeout.trim();
196              _startTimeout = Integer.parseInt(confTimeout);
197          } catch (NumberFormatException e) {
198              _startTimeout = DEFAULT_COMPONENT_START_TIMEOUT;
199 <            System.err.println(toString + ": unable to read uk.org.iscream.ComponentTimeout value (" + confTimeout + "), using default!");
199 >            System.err.println(toString + ": unable to read uk.org.iscream.cms.server.ComponentTimeout value (" + confTimeout + "), using default!");
200          }
201          System.out.println(toString + ": using component start timeout of " + _startTimeout + " seconds");
202          
203          // startup the system components
204          startUp();
205  
206 <            // block on the ORB...in time, management functionality can be placed here.
207 <            // if we detect a CORBA communication error, we'll restart all the components.
208 <            // !! this doesn't appear to work !!
209 <            while(true) {
210 <            try {
206 >        // block on the ORB...in time, management functionality can be placed here.
207 >        // if we detect a CORBA communication error, we'll restart all the components.
208 >        // !! this doesn't appear to work !!
209 >        while(true) {
210 >            try {
211                  refman.getORB().run();
212              } catch (org.omg.CORBA.COMM_FAILURE e) {
213                  System.out.println(toString + ": WARNING CORBA communications failure - " + e.getMessage());
# Line 171 | Line 222 | public class ComponentManager {
222       * This method calls the start() methods on all the components.
223       * If a component fails to start due to a CORBA communication
224       * problem, then it catches this and tries to start it again
225 <     * according to uk.org.iscream.ComponentTimeout time.
225 >     * according to uk.org.iscream.cms.server.ComponentTimeout time.
226       *
227       * If the server dies and CORBA connections are lost, this method
228       * is called again.
229       */
230      private static void startUp() {
231 <        // now we try and start the beast up        
231 >        // now we try and start the beast up
232          boolean tryAgain = true;
233          Component component = null;
234          
# Line 188 | Line 239 | public class ComponentManager {
239              LinkedList failedComponents = new LinkedList();
240              // go through all the components
241              while(i.hasNext()) {
242 <                // get a refence to the component
243 <                component = (Component) i.next();
244 <                System.out.println(toString + ": starting component - " + component.toString());
245 <                
246 <                // check it's dependencies
247 <                boolean depOK = component.depCheck();
248 <                if(depOK) {
249 <                    // it should be ok to start the component
250 <                        try {    
251 <                            // start the component
242 >                // get a refence to the component
243 >                component = (Component) i.next();
244 >                System.out.println(toString + ": dependency checking component - " + component.toString());
245 >                
246 >                // check it's dependencies
247 >                boolean depOK = component.depCheck();
248 >                if(depOK) {
249 >                    System.out.println(toString + ": starting component - " + component.toString());
250 >                    // it should be ok to start the component
251 >                    try {    
252 >                        // start the component
253                          component.start();
254                      } catch (ComponentStartException e) {
255                          // if we get this then there was a problem
# Line 227 | Line 279 | public class ComponentManager {
279                  _componentsToStart = failedComponents;
280                  
281                  // sleep for a given timeout
282 <                try {    
282 >                try {
283                      Thread.sleep(_startTimeout * 1000);
284                  } catch (InterruptedException e) {
285                      // we're not bothered
# Line 238 | Line 290 | public class ComponentManager {
290                  tryAgain = false;
291              }
292          }
293 <                
294 <            System.out.println(toString + ": running");
295 <        }
293 >        
294 >        System.out.println(toString + ": running");
295 >    }
296  
297      /**
298       * A simple method to print the usage of this class.
# Line 249 | Line 301 | public class ComponentManager {
301       * properly.
302       */
303      public static void usage() {
304 <        System.out.println("USAGE: java uk.org.iscream.componentmanager.ComponentManager <option>");
304 >        System.out.println("USAGE: java uk.org.iscream.cms.server.componentmanager.ComponentManager <option>");
305          System.out.println("   or: java -jar iscream.jar <option>");
306          System.out.println("WHERE <option>:");
307          System.out.println("      -l <filename> - the location of initial system properties");
308          System.out.println("                      the default is ./etc/default.properties");
309          System.out.println("      -f <name>     - the name of the filter (if there is one configured");
310 +        System.out.println("      -fm <name>    - the name of the filter manager (if there is one configured");
311 +        System.out.println("      -ci <name>    - the name of the client interface (if there is one configured");
312          System.out.println("      -h            - this help screen");
313          System.exit(1);
314      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines