ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/java/Config.java
(Generate patch)

Comparing projects/cms/source/host/java/Config.java (file contents):
Revision 1.3 by ab11, Thu Nov 30 04:06:52 2000 UTC vs.
Revision 1.9 by tdb, Sat May 18 18:15:57 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  
22   //---IMPORTS---
# Line 8 | Line 27 | import java.io.*;
27  
28   /**
29   * Configurator object for the JavaHost
30 < * Will connect to the configurator manager and collect its specific
30 > * Will connect to the filter manager and collect its specific
31   * configuration
32   *
33   * @author  $Author$
# Line 52 | Line 71 | class Config {
71          myProperties = new HashMap();
72          configChanged = false;
73          
74 +        // time in seconds before first retry
75 +        filterManagerRetryTime = 10;
76      
77          // do the funky jibble
78          connect(serverName, serverPort);
# Line 60 | Line 81 | class Config {
81   //---PUBLIC METHODS---
82  
83      public InetAddress getFilterName(){
84 <        // will return the most recient IP address (if it is dynamic for whatever reason
84 >        // will return the most recent IP address (if it is dynamic for whatever reason)
85          try {
86              return InetAddress.getByName(filterName);
87          }
# Line 74 | Line 95 | class Config {
95      /**
96       * Used to retrieve the port to send UDP packets to on the filter
97       *
98 <     * @return an integer corrisponding to the UDP port of the filter
98 >     * @return an integer corresponding to the UDP port of the filter
99       */
100      public int getFilterUDPPort(){
101          
# Line 84 | Line 105 | class Config {
105      /**
106       * Used to retrieve the port to send TCP heartbeats to on the filter
107       *
108 <     * @return an integer corrisponding to the TCP of the filter
108 >     * @return an integer corresponding to the TCP of the filter
109       */    
110      public int getFilterTCPPort(){
111          
# Line 116 | Line 137 | class Config {
137          Socket mySocket;
138          configChanged = false;
139          
140 <        System.out.println("Establishing connection with config manager");
140 >        System.out.println("Establishing connection with filter manager");
141          
142          // might throw a UnknownHostException
143          try {
# Line 129 | Line 150 | class Config {
150                  // everything is fine
151                  // sendCommand("LASTMODIFIED");
152                  lastModified = sendCommand("LASTMODIFIED");
153 <                
153 >                    
154                  fileList = sendCommand("FILELIST");
155 +                
156 +                fQDN = sendCommand("FQDN");                
157                  // get all the properties
158                  if ( numProperties > 0 ){
159                          // sendCommand("CONFIG");
# Line 146 | Line 169 | class Config {
169                  filterName = tok.nextToken();
170                  filterUDPPort = Integer.parseInt(tok.nextToken());
171                  filterTCPPort = Integer.parseInt(tok.nextToken());
172 <                    
172 >                                    
173                  sendCommand("END");        
174                  
175              }
# Line 154 | Line 177 | class Config {
177          
178              // close the socket
179              mySocket.close();
180 <            System.out.println("Completed communication with config manager");
180 >            System.out.println("Completed communication with filter manager");
181          
182          }
183          catch ( UnknownHostException e ){
# Line 164 | Line 187 | class Config {
187          catch ( IOException e ){
188              // what to do
189              System.out.println("Unable to read from socket, might not be open");
190 +            System.out.println("Retrying in "+filterManagerRetryTime+" seconds");
191 +            configChanged = true;
192 +            try {
193 +                Thread.sleep(filterManagerRetryTime*1000);
194 +            }
195 +            catch( InterruptedException f ){
196 +                System.out.println("Sleep interrupted");
197 +            }
198 +            filterManagerRetryTime = filterManagerRetryTime * 2;
199 +            // warning this WILL cause a stack overflow after a while..
200 +            // need to fix it.
201 +            connect(serverName, serverPort);
202          }
203              
204      } // connect
# Line 198 | Line 233 | class Config {
233          catch ( IOException e ){
234              // what to do
235              System.out.println("Unable to read from socket, might not be open");
236 +            System.out.println("Re-establishing contact with filter manager");
237 +            configChanged = true;
238          }
239      }
240  
# Line 229 | Line 266 | class Config {
266      private boolean configChanged;
267      private String lastModified;
268      private String fileList;
269 +    private String fQDN;
270      private int numProperties;
271      private HashMap myProperties;
272      private String filterName;
# Line 237 | Line 275 | class Config {
275      private ArrayList aList;
276      private BufferedReader socketIn;
277      private PrintWriter socketOut;
278 +    private int filterManagerRetryTime;
279      
280  
281  
282   //---STATIC ATTRIBUTES---
283  
284 < } // class
284 > } // class

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines