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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/filtermanager/HostInit.java (file contents):
Revision 1.16 by tdb, Wed Feb 7 13:47:22 2001 UTC vs.
Revision 1.24 by tdb, Mon Mar 5 23:53:39 2001 UTC

# Line 6 | Line 6 | import uk.ac.ukc.iscream.core.*;
6   import uk.ac.ukc.iscream.filter.*;
7   import uk.ac.ukc.iscream.util.*;
8   import uk.ac.ukc.iscream.componentmanager.*;
9 < import java.net.Socket;
9 > import java.net.*;
10   import java.io.*;
11 + import java.util.*;
12  
13   /**
14   * Handles setting up a host.
# Line 87 | Line 88 | class HostInit extends Thread {
88                          // send info
89                          _socketOut.println(myConfig.getFileList());
90                  }
91 <
91 >                
92 >                // send the FQDN to the host
93 >                inBound = _socketIn.readLine();
94 >                if(!inBound.equals("FQDN")) {
95 >                        // protocol error
96 >                    _socketOut.println("ERROR");
97 >                    throw new IOException("protocol error - expected:FQDN got:" + inBound);
98 >                }
99 >                else {
100 >                    // send the fqdn (of the host) to the host
101 >                    _socketOut.println(_socket.getInetAddress().getHostName().toLowerCase());
102 >                }
103 >                
104                  // get properties
105                  inBound = _socketIn.readLine();
106                  while(!inBound.equals("ENDCONFIG")) {
# Line 115 | Line 128 | class HostInit extends Thread {
128                  }
129                  else {
130                          // send info
131 <                        String parentFilter =  myConfig.getProperty("Host.filter");
132 <                        _logger.write(toString(), Logger.DEBUG, " looking for parent - " + parentFilter);
133 <                    Filter filter = FilterHelper.narrow(ReferenceManager.getInstance().getCORBARef("iscream.Filter." + parentFilter));
134 <                        _socketOut.println(filter.getHostName() + ";"
135 <                                         + filter.getUDPPort() + ";"
136 <                                         + filter.getTCPPort());
131 >                        String filterList = myConfig.getProperty("Host.filter");
132 >                        Filter filterRef = null;
133 >                        String filter = null;
134 >                        StringTokenizer st = new StringTokenizer(filterList, ";");
135 >                    while (filterRef==null && st.hasMoreTokens()) {
136 >                        filter = st.nextToken();
137 >                        _logger.write(toString(), Logger.DEBUG, " looking for filter- " + filter);
138 >                        try {
139 >                            filterRef = FilterHelper.narrow(ReferenceManager.getInstance().getCORBARef("iscream.Filter." + filter));
140 >                        } catch (ComponentCORBAException e) {
141 >                            _logger.write(toString(), Logger.DEBUG, " unable to find filter- " + filter);
142 >                        }
143 >                    }
144 >                        
145 >                        // hopefully we found a filter
146 >                    if(filterRef != null) {
147 >                        _logger.write(toString(), Logger.DEBUG, " found filter- " + filter);
148 >                        // tell the host about it...
149 >                            _socketOut.println(filterRef.getHostName() + ";"
150 >                                             + filterRef.getUDPPort() + ";"
151 >                                             + filterRef.getTCPPort());
152 >                        }
153 >                        else {
154 >                            // ...or throw a wobbly (and tell the host!)
155 >                            _socketOut.println("ERROR");
156 >                            throw new IOException("unable to find filter for host");
157 >                        }
158                  }
159                  
160                  // confirm that all is ok
# Line 138 | Line 172 | class HostInit extends Thread {
172              }
173              
174          } catch (Exception e) {
175 <            _logger.write(toString(), Logger.ERROR, "ERROR - " + e.getMessage());
175 >            _logger.write(toString(), Logger.ERROR, "ERROR - " + e);
176          }
177          
178          _socketOut.flush();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines