return null;
Map<String, String> urlsToTry = new HashMap<String, String>();
addDefaultURL(urlsToTry, dir, minVersion);
TeamServerPointerFile pointerFile = new TeamServerPointerFile(dir);
for (String url : pointerFile.getInstanceURLs())
urlsToTry.put(url, minVersion);
URL result = null;
long bestTimeSoFar = Integer.MAX_VALUE;
for (Map.Entry<String, String> e : urlsToTry.entrySet()) {
String serverURL = e.getKey();
String requiredVersion = e.getValue();
long start = System.currentTimeMillis();
URL u = testServerURL(serverURL, requiredVersion);
if (u == null) {
logger.log(Level.FINE,
"IOxception when contacting {0} - skipping", serverURL);
continue;
}
long end = System.currentTimeMillis();
long elapsed = end - start;
logger.log(Level.FINE, "Successfully contacted {0} - took {1} ms",
new Object[] { serverURL, elapsed });
if (elapsed < bestTimeSoFar) {
bestTimeSoFar = elapsed;
result = u;
}
}
if (result == null && offlineOK) {
List<String> instanceURLs = pointerFile.getInstanceURLs();
if (!instanceURLs.isEmpty()) {
try {
// select one of the URLs at random. (Of course, with
// the current PDES deployment scenario, we expect exactly
// one URL to be present anyway.)