8 |
|
|
9 |
|
/** |
10 |
|
* Configurator object for the JavaHost |
11 |
< |
* Will connect to the configurator manager and collect its specific |
11 |
> |
* Will connect to the filter manager and collect its specific |
12 |
|
* configuration |
13 |
|
* |
14 |
|
* @author $Author$ |
52 |
|
myProperties = new HashMap(); |
53 |
|
configChanged = false; |
54 |
|
|
55 |
+ |
// time in seconds before first retry |
56 |
+ |
filterManagerRetryTime = 10; |
57 |
|
|
58 |
|
// do the funky jibble |
59 |
|
connect(serverName, serverPort); |
62 |
|
//---PUBLIC METHODS--- |
63 |
|
|
64 |
|
public InetAddress getFilterName(){ |
65 |
< |
// will return the most recient IP address (if it is dynamic for whatever reason |
65 |
> |
// will return the most recent IP address (if it is dynamic for whatever reason) |
66 |
|
try { |
67 |
|
return InetAddress.getByName(filterName); |
68 |
|
} |
76 |
|
/** |
77 |
|
* Used to retrieve the port to send UDP packets to on the filter |
78 |
|
* |
79 |
< |
* @return an integer corrisponding to the UDP port of the filter |
79 |
> |
* @return an integer corresponding to the UDP port of the filter |
80 |
|
*/ |
81 |
|
public int getFilterUDPPort(){ |
82 |
|
|
86 |
|
/** |
87 |
|
* Used to retrieve the port to send TCP heartbeats to on the filter |
88 |
|
* |
89 |
< |
* @return an integer corrisponding to the TCP of the filter |
89 |
> |
* @return an integer corresponding to the TCP of the filter |
90 |
|
*/ |
91 |
|
public int getFilterTCPPort(){ |
92 |
|
|
118 |
|
Socket mySocket; |
119 |
|
configChanged = false; |
120 |
|
|
121 |
< |
System.out.println("Establishing connection with config manager"); |
121 |
> |
System.out.println("Establishing connection with filter manager"); |
122 |
|
|
123 |
|
// might throw a UnknownHostException |
124 |
|
try { |
148 |
|
filterName = tok.nextToken(); |
149 |
|
filterUDPPort = Integer.parseInt(tok.nextToken()); |
150 |
|
filterTCPPort = Integer.parseInt(tok.nextToken()); |
151 |
< |
|
151 |
> |
|
152 |
|
sendCommand("END"); |
153 |
|
|
154 |
|
} |
156 |
|
|
157 |
|
// close the socket |
158 |
|
mySocket.close(); |
159 |
< |
System.out.println("Completed communication with config manager"); |
159 |
> |
System.out.println("Completed communication with filter manager"); |
160 |
|
|
161 |
|
} |
162 |
|
catch ( UnknownHostException e ){ |
166 |
|
catch ( IOException e ){ |
167 |
|
// what to do |
168 |
|
System.out.println("Unable to read from socket, might not be open"); |
169 |
+ |
System.out.println("Retrying in "+filterManagerRetryTime+" seconds"); |
170 |
+ |
configChanged = true; |
171 |
+ |
try { |
172 |
+ |
Thread.sleep(filterManagerRetryTime*1000); |
173 |
+ |
} |
174 |
+ |
catch( InterruptedException f ){ |
175 |
+ |
System.out.println("Sleep interrupted"); |
176 |
+ |
} |
177 |
+ |
filterManagerRetryTime = filterManagerRetryTime * 2; |
178 |
+ |
// warning this WILL cause a stack overflow after a while.. |
179 |
+ |
// need to fix it. |
180 |
+ |
connect(serverName, serverPort); |
181 |
|
} |
182 |
|
|
183 |
|
} // connect |
212 |
|
catch ( IOException e ){ |
213 |
|
// what to do |
214 |
|
System.out.println("Unable to read from socket, might not be open"); |
215 |
+ |
System.out.println("Re-establishing contact with filter manager"); |
216 |
+ |
configChanged = true; |
217 |
|
} |
218 |
|
} |
219 |
|
|
253 |
|
private ArrayList aList; |
254 |
|
private BufferedReader socketIn; |
255 |
|
private PrintWriter socketOut; |
256 |
+ |
private int filterManagerRetryTime; |
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
//---STATIC ATTRIBUTES--- |
261 |
|
|
262 |
< |
} // class |
262 |
> |
} // class |