use of jp.ossc.nimbus.service.http.HttpRequest in project nimbus by nimbus-org.
the class HttpKeepAliveCheckerService method startService.
public void startService() throws Exception {
if (httpClientFactoryServiceName != null) {
httpClientFactory = (HttpClientFactory) ServiceManagerFactory.getServiceObject(httpClientFactoryServiceName);
}
if (httpClientFactory == null) {
throw new IllegalArgumentException("HttpClientFactory is null.");
}
if (checkTargetRequestName == null || "".equals(checkTargetRequestName)) {
throw new IllegalArgumentException("CheckTargetRequestName is null.");
}
if (hostResolverServiceName != null) {
hostResolver = (HostResolver) ServiceManagerFactory.getServiceObject(hostResolverServiceName);
}
HttpRequest request = httpClientFactory.createRequest(checkTargetRequestName);
checkTargetUrl = new URL(request.getURL());
if (protocol == null) {
protocol = checkTargetUrl.getProtocol();
}
if (port == -1) {
port = checkTargetUrl.getPort();
}
if (path == null) {
path = checkTargetUrl.getPath();
}
}
use of jp.ossc.nimbus.service.http.HttpRequest 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;
}
Aggregations