@Override public void cancelled() { httpPost.reset(); } }
@Override public void cancelled() { httpPost.reset(); } }
@Override public void completed(HttpResponse httpResponse) { httpPost.reset(); }
@Override public void completed(HttpResponse httpResponse) { httpPost.reset(); }
@Override public void failed(Exception e) { httpPost.reset(); LOG.error("Monitor web service invoke failed, url={}", httpPost.getURI(), e); }
@Override public void failed(Exception e) { httpPost.reset(); LOG.error("Monitor web service invoke failed, url={}", httpPost.getURI(), e); }
return null; } finally { takeRequest.reset();
private void finishTask(String taskId, ProvisionerAction action) throws IOException { LOG.debug("finishing task {}, which is a {} action.", taskId, action); try { JsonObject body; // generate random num from 0-99 int num = RANDOM.nextInt(100); if (failureRate > num) { body = failureBody(taskId); } else { body = successBody(taskId, action); } finishRequest.setEntity(new StringEntity(GSON.toJson(body))); CloseableHttpResponse response = httpClient.execute(finishRequest, httpContext); try { int statusCode = response.getStatusLine().getStatusCode(); if (statusCode / 100 != 2) { LOG.error("Error finishing task {}. Got status code {} with message:\n{}", taskId, statusCode, getResponseString(response)); } } finally { response.close(); } } catch (Exception e) { LOG.error("Exception making finish request.", e); } finally { finishRequest.reset(); } }
private void heartbeat() throws Exception { JsonObject heartbeat = new JsonObject(); heartbeat.add("usage", GSON.toJsonTree(provisionerTenantStore.getUsage())); heartbeatRequest.setEntity(new StringEntity(GSON.toJson(heartbeat))); try { LOG.debug("sending heartbeat {}...", heartbeat.toString()); CloseableHttpResponse response = httpClient.execute(heartbeatRequest); try { int statusCode = response.getStatusLine().getStatusCode(); if (statusCode / 100 == 2) { LOG.debug("heartbeat successfull."); } else if (response.getStatusLine().getStatusCode() == 404) { // if we try and heartbeat and get back a 404, register again. LOG.debug("heartbeat returned a 404, will try to register."); register(); } else { LOG.info("heartbeat for provisioner {} failed. Got a {} status with message:\n {}.", id, getResponseString(response), statusCode); } } finally { response.close(); } } catch (Exception e) { LOG.error("Exception while sending heartbeat.", e); } finally { heartbeatRequest.reset(); } }
LOG.error("Can't get AEM authentication cookie", e); } finally { loginPost.reset();
} finally { if (httpPost != null) { httpPost.reset();
LOG.error("Can't get AEM authentication cookie", e); } finally { loginPost.reset();
method.reset();
method.reset();
} finally { if (post != null) { post.reset();