--- projects/cms/source/host/java/Config.java 2000/11/30 04:06:52 1.3 +++ projects/cms/source/host/java/Config.java 2001/01/22 04:08:36 1.6 @@ -8,11 +8,11 @@ import java.io.*; /** * Configurator object for the JavaHost - * Will connect to the configurator manager and collect its specific + * Will connect to the filter manager and collect its specific * configuration * - * @author $Author: ab11 $ - * @version $Id: Config.java,v 1.3 2000/11/30 04:06:52 ab11 Exp $ + * @author $Author: tdb $ + * @version $Id: Config.java,v 1.6 2001/01/22 04:08:36 tdb Exp $ */ class Config { @@ -52,6 +52,8 @@ class Config { myProperties = new HashMap(); configChanged = false; + // time in seconds before first retry + filterManagerRetryTime = 10; // do the funky jibble connect(serverName, serverPort); @@ -60,7 +62,7 @@ class Config { //---PUBLIC METHODS--- public InetAddress getFilterName(){ - // will return the most recient IP address (if it is dynamic for whatever reason + // will return the most recent IP address (if it is dynamic for whatever reason) try { return InetAddress.getByName(filterName); } @@ -74,7 +76,7 @@ class Config { /** * Used to retrieve the port to send UDP packets to on the filter * - * @return an integer corrisponding to the UDP port of the filter + * @return an integer corresponding to the UDP port of the filter */ public int getFilterUDPPort(){ @@ -84,7 +86,7 @@ class Config { /** * Used to retrieve the port to send TCP heartbeats to on the filter * - * @return an integer corrisponding to the TCP of the filter + * @return an integer corresponding to the TCP of the filter */ public int getFilterTCPPort(){ @@ -116,7 +118,7 @@ class Config { Socket mySocket; configChanged = false; - System.out.println("Establishing connection with config manager"); + System.out.println("Establishing connection with filter manager"); // might throw a UnknownHostException try { @@ -146,7 +148,7 @@ class Config { filterName = tok.nextToken(); filterUDPPort = Integer.parseInt(tok.nextToken()); filterTCPPort = Integer.parseInt(tok.nextToken()); - + sendCommand("END"); } @@ -154,7 +156,7 @@ class Config { // close the socket mySocket.close(); - System.out.println("Completed communication with config manager"); + System.out.println("Completed communication with filter manager"); } catch ( UnknownHostException e ){ @@ -164,6 +166,18 @@ class Config { catch ( IOException e ){ // what to do System.out.println("Unable to read from socket, might not be open"); + System.out.println("Retrying in "+filterManagerRetryTime+" seconds"); + configChanged = true; + try { + Thread.sleep(filterManagerRetryTime*1000); + } + catch( InterruptedException f ){ + System.out.println("Sleep interrupted"); + } + filterManagerRetryTime = filterManagerRetryTime * 2; + // warning this WILL cause a stack overflow after a while.. + // need to fix it. + connect(serverName, serverPort); } } // connect @@ -198,6 +212,8 @@ class Config { catch ( IOException e ){ // what to do System.out.println("Unable to read from socket, might not be open"); + System.out.println("Re-establishing contact with filter manager"); + configChanged = true; } } @@ -237,6 +253,7 @@ class Config { private ArrayList aList; private BufferedReader socketIn; private PrintWriter socketOut; + private int filterManagerRetryTime;