@Override public boolean isServiceAvailable() { String url = null; try { Iterable<Discoverable> discoverables = this.discoveryServiceClient.discover(getDiscoverableName()); for (Discoverable discoverable : discoverables) { String scheme = Arrays.equals(Constants.Security.SSL_URI_SCHEME.getBytes(), discoverable.getPayload()) ? Constants.Security.SSL_URI_SCHEME : Constants.Security.URI_SCHEME; url = String.format("%s%s:%d/ping", scheme, discoverable.getSocketAddress().getHostName(), discoverable.getSocketAddress().getPort()); //Ping the discovered service to check its status. if (checkGetStatus(url).equals(HttpResponseStatus.OK)) { return true; } } return false; } catch (IllegalArgumentException e) { return false; } catch (Exception e) { LOG.warn("Unable to ping {} at {} : Reason : {}", serviceName, url, e.getMessage()); return false; } }
@Override public boolean isServiceAvailable() { String url = null; try { Iterable<Discoverable> discoverables = this.discoveryServiceClient.discover(getDiscoverableName()); for (Discoverable discoverable : discoverables) { String scheme = Arrays.equals(Constants.Security.SSL_URI_SCHEME.getBytes(), discoverable.getPayload()) ? Constants.Security.SSL_URI_SCHEME : Constants.Security.URI_SCHEME; url = String.format("%s%s:%d/ping", scheme, discoverable.getSocketAddress().getHostName(), discoverable.getSocketAddress().getPort()); //Ping the discovered service to check its status. if (checkGetStatus(url).equals(HttpResponseStatus.OK)) { return true; } } return false; } catch (IllegalArgumentException e) { return false; } catch (Exception e) { LOG.warn("Unable to ping {} at {} : Reason : {}", serviceName, url, e.getMessage()); return false; } }