public static HttpStatus pingUrl ( final String location ) { try { val url = new URL ( location ) ; val connection = ( HttpURLConnection ) url . openConnection ( ) ; connection . setConnectTimeout ( PING_URL_TIMEOUT ) ; connection . setReadTimeout ( PING_URL_TIMEOUT ) ; connection . setRequestMethod ( HttpMethod . HEAD . name ( ) ) ; return HttpStatus . valueOf ( connection . getResponseCode ( ) ) ; } catch ( final Exception e ) { LOGGER . error ( e . getMessage ( ) , e ) ; } return HttpStatus . SERVICE_UNAVAILABLE ; }
Ping url and return http status .