private void healthCheck() { for (int i = 0; i < 3; i++) { if (instances[i].getUrl() != null) { String url = instances[i].getUrl() + "/lookup/random"; int responseCode = 0; try { responseCode = getResponseCode(url); } catch (IOException e) { // error when connection to server, dc is dead System.out.println("error when connection to server, dc is dead"); instances[i].changeUrl(null); isHealthy[i] = false; continue; } if (responseCode != 200) { System.out.println("dead dc response code is not 200"); instances[i].changeUrl(null); isHealthy[i] = false; } } } updataHealthCount(); }