Search in sources :

Example 1 with HttpClientConnectTimeoutException

use of jp.ossc.nimbus.service.http.httpclient.HttpClientConnectTimeoutException in project nimbus by nimbus-org.

the class HttpKeepAliveCheckerService method checkAlive.

public boolean checkAlive() throws Exception {
    HttpClient client = httpClientFactory.createHttpClient();
    HttpRequest request = httpClientFactory.createRequest(checkTargetRequestName);
    try {
        HttpResponse response = client.executeRequest(request);
        if (response.getStatusCode() == 200) {
            if (assertString != null) {
                String responseBody = (String) response.getObject();
                if (assertString.equals(responseBody)) {
                    return true;
                }
            } else {
                return true;
            }
        }
    } catch (HttpClientConnectTimeoutException e) {
    } catch (HttpClientSocketTimeoutException e) {
    }
    return false;
}
Also used : HttpRequest(jp.ossc.nimbus.service.http.HttpRequest) HttpClient(jp.ossc.nimbus.service.http.HttpClient) HttpClientConnectTimeoutException(jp.ossc.nimbus.service.http.httpclient.HttpClientConnectTimeoutException) HttpResponse(jp.ossc.nimbus.service.http.HttpResponse) HttpClientSocketTimeoutException(jp.ossc.nimbus.service.http.httpclient.HttpClientSocketTimeoutException)

Aggregations

HttpClient (jp.ossc.nimbus.service.http.HttpClient)1 HttpRequest (jp.ossc.nimbus.service.http.HttpRequest)1 HttpResponse (jp.ossc.nimbus.service.http.HttpResponse)1 HttpClientConnectTimeoutException (jp.ossc.nimbus.service.http.httpclient.HttpClientConnectTimeoutException)1 HttpClientSocketTimeoutException (jp.ossc.nimbus.service.http.httpclient.HttpClientSocketTimeoutException)1