| 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 { |
| 131 |
|
// everything is fine |
| 132 |
|
// sendCommand("LASTMODIFIED"); |
| 133 |
|
lastModified = sendCommand("LASTMODIFIED"); |
| 134 |
< |
|
| 134 |
> |
|
| 135 |
|
fileList = sendCommand("FILELIST"); |
| 136 |
+ |
|
| 137 |
+ |
fQDN = sendCommand("FQDN"); |
| 138 |
|
// get all the properties |
| 139 |
|
if ( numProperties > 0 ){ |
| 140 |
|
// sendCommand("CONFIG"); |
| 150 |
|
filterName = tok.nextToken(); |
| 151 |
|
filterUDPPort = Integer.parseInt(tok.nextToken()); |
| 152 |
|
filterTCPPort = Integer.parseInt(tok.nextToken()); |
| 153 |
< |
|
| 153 |
> |
|
| 154 |
|
sendCommand("END"); |
| 155 |
|
|
| 156 |
|
} |
| 158 |
|
|
| 159 |
|
// close the socket |
| 160 |
|
mySocket.close(); |
| 161 |
< |
System.out.println("Completed communication with config manager"); |
| 161 |
> |
System.out.println("Completed communication with filter manager"); |
| 162 |
|
|
| 163 |
|
} |
| 164 |
|
catch ( UnknownHostException e ){ |
| 168 |
|
catch ( IOException e ){ |
| 169 |
|
// what to do |
| 170 |
|
System.out.println("Unable to read from socket, might not be open"); |
| 171 |
+ |
System.out.println("Retrying in "+filterManagerRetryTime+" seconds"); |
| 172 |
+ |
configChanged = true; |
| 173 |
+ |
try { |
| 174 |
+ |
Thread.sleep(filterManagerRetryTime*1000); |
| 175 |
+ |
} |
| 176 |
+ |
catch( InterruptedException f ){ |
| 177 |
+ |
System.out.println("Sleep interrupted"); |
| 178 |
+ |
} |
| 179 |
+ |
filterManagerRetryTime = filterManagerRetryTime * 2; |
| 180 |
+ |
// warning this WILL cause a stack overflow after a while.. |
| 181 |
+ |
// need to fix it. |
| 182 |
+ |
connect(serverName, serverPort); |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
} // connect |
| 214 |
|
catch ( IOException e ){ |
| 215 |
|
// what to do |
| 216 |
|
System.out.println("Unable to read from socket, might not be open"); |
| 217 |
+ |
System.out.println("Re-establishing contact with filter manager"); |
| 218 |
+ |
configChanged = true; |
| 219 |
|
} |
| 220 |
|
} |
| 221 |
|
|
| 247 |
|
private boolean configChanged; |
| 248 |
|
private String lastModified; |
| 249 |
|
private String fileList; |
| 250 |
+ |
private String fQDN; |
| 251 |
|
private int numProperties; |
| 252 |
|
private HashMap myProperties; |
| 253 |
|
private String filterName; |
| 256 |
|
private ArrayList aList; |
| 257 |
|
private BufferedReader socketIn; |
| 258 |
|
private PrintWriter socketOut; |
| 259 |
+ |
private int filterManagerRetryTime; |
| 260 |
|
|
| 261 |
|
|
| 262 |
|
|
| 263 |
|
//---STATIC ATTRIBUTES--- |
| 264 |
|
|
| 265 |
< |
} // class |
| 265 |
> |
} // class |