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.36 by ajm, Mon Mar 19 03:36:18 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 < package uk.ac.ukc.iscream.componentmanager;
2 > package uk.org.iscream.componentmanager;
3  
4   //---IMPORTS---
5   import java.util.*;
6   import java.io.*;
7 < import uk.ac.ukc.iscream.util.*;
7 > import uk.org.iscream.util.*;
8  
9   /**
10   * The component manager is the starting point for all
# Line 12 | Line 12 | import uk.ac.ukc.iscream.util.*;
12   * It loads its initial system configuration from the
13   * default properties file, it then starts all the iscream
14   * components as specified in the default.properties under
15 < * uk.ac.ukc.iscream.ComponentList
15 > * uk.org.iscream.ComponentList
16   *
17   * @author  $Author$
18   * @version $Id$
# Line 53 | Line 53 | public class ComponentManager {
53       * @param args the command line arguments
54       */
55      public static void main(String[] args) {
56 +        System.out.println("-----------------------------------------");
57          System.out.println("--- i-scream Server Component Manager ---");
58 +        System.out.println("---    © 2001 The i-scream Project    ---");
59 +        System.out.println("---    (http://www.i-scream.org.uk)   ---");
60 +        System.out.println("-----------------------------------------");
61          System.out.println("---          Starting System          ---");        
62          
63          // get the command line args
# Line 96 | Line 100 | public class ComponentManager {
100          refman.activatePOA();
101          
102          // get the list of components
103 <        String componentList = System.getProperty("uk.ac.ukc.iscream.ComponentList");
103 >        String componentList = System.getProperty("uk.org.iscream.ComponentList");
104          StringTokenizer st = new StringTokenizer(componentList, ";");
105 <        _componentsToStart = new ArrayList();
105 >        _componentsToStart = new LinkedList();
106          
107          // this could be done using reflection
108          // but..well..we don't ;-p
# Line 109 | Line 113 | public class ComponentManager {
113              
114              // ### This is where the list of supported components is checked! ###
115              if (componentName.equalsIgnoreCase("core")) {
116 <                component = new uk.ac.ukc.iscream.core.Core();
116 >                component = new uk.org.iscream.core.Core();
117              } else if (componentName.equalsIgnoreCase("filtermanager")) {
118 <                component = new uk.ac.ukc.iscream.filtermanager.FilterManager();
118 >                component = new uk.org.iscream.filtermanager.FilterManager();
119              } else if (componentName.equalsIgnoreCase("rootfilter")) {
120 <                component = new uk.ac.ukc.iscream.rootfilter.RootFilter();
120 >                component = new uk.org.iscream.rootfilter.RootFilter();
121              } else if (componentName.equalsIgnoreCase("dbinterface")) {
122 <                component = new uk.ac.ukc.iscream.dbinterface.DBInterface();
122 >                component = new uk.org.iscream.dbinterface.DBInterface();
123              } else if (componentName.equalsIgnoreCase("clientinterface")) {
124 <                component = new uk.ac.ukc.iscream.clientinterface.ClientInterfaceMain();
124 >                component = new uk.org.iscream.clientinterface.ClientInterfaceMain();
125              // note the passing of the Filter's name in its constructor
126              } else if (componentName.equalsIgnoreCase("filter")) {
127 <                component = new uk.ac.ukc.iscream.filter.FilterMain(filterName);
127 >                component = new uk.org.iscream.filter.FilterMain(filterName);
128              } else if (componentName.equalsIgnoreCase("client")) {
129 <                component = new uk.ac.ukc.iscream.client.ClientMain();
129 >                component = new uk.org.iscream.client.ClientMain();
130              }
131              // ###  Add new component constructors in the above section! ###
132              
# Line 130 | Line 134 | public class ComponentManager {
134              if (component != null) {
135                  _componentsToStart.add(component);    
136              } else {
137 <                System.err.println(toString + ": WARNING unsupported component not started");
137 >                System.err.println(toString + ": WARNING unsupported component not started: "+componentName);
138              }
139          }
140          
# Line 140 | Line 144 | public class ComponentManager {
144          
145          String confTimeout = null;
146          try {
147 <            confTimeout = System.getProperty("uk.ac.ukc.iscream.ComponentTimeout");
147 >            confTimeout = System.getProperty("uk.org.iscream.ComponentTimeout");
148              confTimeout.trim();
149              _startTimeout = Integer.parseInt(confTimeout);
150          } catch (NumberFormatException e) {
151              _startTimeout = DEFAULT_COMPONENT_START_TIMEOUT;
152 <            System.err.println(toString + ": unable to read uk.ac.ukc.iscream.ComponentTimeout value (" + confTimeout + "), using default!");
152 >            System.err.println(toString + ": unable to read uk.org.iscream.ComponentTimeout value (" + confTimeout + "), using default!");
153          }
154          System.out.println(toString + ": using component start timeout of " + _startTimeout + " seconds");
155          
# Line 154 | Line 158 | public class ComponentManager {
158  
159              // block on the ORB...in time, management functionality can be placed here.
160              // if we detect a CORBA communication error, we'll restart all the components.
161 +            // !! this doesn't appear to work !!
162              while(true) {
163              try {
164                  refman.getORB().run();
# Line 170 | Line 175 | public class ComponentManager {
175       * This method calls the start() methods on all the components.
176       * If a component fails to start due to a CORBA communication
177       * problem, then it catches this and tries to start it again
178 <     * according to uk.ac.ukc.iscream.ComponentTimeout time.
178 >     * according to uk.org.iscream.ComponentTimeout time.
179       *
180       * If the server dies and CORBA connections are lost, this method
181       * is called again.
# Line 184 | Line 189 | public class ComponentManager {
189          // maybe add support for a limited number of retries
190          while(tryAgain) {
191              Iterator i = _componentsToStart.iterator();
192 <            ArrayList failedComponents = new ArrayList();
192 >            LinkedList failedComponents = new LinkedList();
193              // go through all the components
194              while(i.hasNext()) {
195 <                try {
196 <                    component = (Component) i.next();
195 >                // get a refence to the component
196 >                component = (Component) i.next();
197 >                System.out.println(toString + ": dependency checking component - " + component.toString());
198 >                
199 >                // check it's dependencies
200 >                boolean depOK = component.depCheck();
201 >                if(depOK) {
202                      System.out.println(toString + ": starting component - " + component.toString());
203 <                    
204 <                    // start the component
205 <                    component.start();
206 <                    
207 <                // if we get this then there was a problem
208 <                // that we can't recover from
209 <                } catch (ComponentStartException e) {
210 <                    System.err.println(toString + ": ERROR starting component - " + component.toString());
211 <                    System.err.println(toString + ": component reports - " + e.getMessage());
212 <                    System.exit(1);
213 <
214 <                // if we get this exception then we've tried
215 <                // to talk to something which may not be up yet
216 <                // so we want to try again in a minute                
217 <                } catch(ComponentCORBAException e2) {
218 <                    System.err.println(toString + ": WARNING Component reported CORBA communications failure");
203 >                    // it should be ok to start the component
204 >                        try {    
205 >                            // start the component
206 >                        component.start();
207 >                    } catch (ComponentStartException e) {
208 >                        // if we get this then there was a problem
209 >                        // that we can't recover from
210 >                        System.err.println(toString + ": ERROR starting component - " + component.toString());
211 >                        System.err.println(toString + ": component reports - " + e.getMessage());
212 >                        System.exit(1);
213 >                    }
214 >                }
215 >                else {
216 >                    // it seems the depedencies failed
217 >                    // so we want to try again after a delay
218 >                    System.err.println(toString + ": WARNING Component reported dependency failure");
219                      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());
220                      
221                      // make a list of the failed components
222                      failedComponents.add(component);
# Line 245 | Line 254 | public class ComponentManager {
254       * properly.
255       */
256      public static void usage() {
257 <        System.out.println("USAGE: java uk.ac.ukc.iscream.componentmanager.ComponentManager <option>");
257 >        System.out.println("USAGE: java uk.org.iscream.componentmanager.ComponentManager <option>");
258          System.out.println("   or: java -jar iscream.jar <option>");
259          System.out.println("WHERE <option>:");
260          System.out.println("      -l <filename> - the location of initial system properties");
# Line 267 | Line 276 | public class ComponentManager {
276      
277   //---STATIC ATTRIBUTES---
278  
279 <    private static ArrayList _componentsToStart;
279 >    private static LinkedList _componentsToStart;
280      private static int _startTimeout = 0;
281  
282   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines