use of com.metamx.http.client.response.StatusResponseHolder in project druid by druid-io.
the class RemoteTaskRunner method shutdown.
/**
* Finds the worker running the task and forwards the shutdown signal to the worker.
*
* @param taskId - task id to shutdown
*/
@Override
public void shutdown(final String taskId) {
if (!started) {
log.info("This TaskRunner is stopped. Ignoring shutdown command for task: %s", taskId);
} else if (pendingTasks.remove(taskId) != null) {
pendingTaskPayloads.remove(taskId);
log.info("Removed task from pending queue: %s", taskId);
} else if (completeTasks.containsKey(taskId)) {
cleanup(taskId);
} else {
final ZkWorker zkWorker = findWorkerRunningTask(taskId);
if (zkWorker == null) {
log.info("Can't shutdown! No worker running task %s", taskId);
return;
}
URL url = null;
try {
url = makeWorkerURL(zkWorker.getWorker(), String.format("/task/%s/shutdown", taskId));
final StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, url), RESPONSE_HANDLER, shutdownTimeout).get();
log.info("Sent shutdown message to worker: %s, status %s, response: %s", zkWorker.getWorker().getHost(), response.getStatus(), response.getContent());
if (!HttpResponseStatus.OK.equals(response.getStatus())) {
log.error("Shutdown failed for %s! Are you sure the task was running?", taskId);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RE(e, "Interrupted posting shutdown to [%s] for task [%s]", url, taskId);
} catch (Exception e) {
throw new RE(e, "Error in handling post to [%s] for task [%s]", zkWorker.getWorker().getHost(), taskId);
}
}
}
use of com.metamx.http.client.response.StatusResponseHolder in project druid by druid-io.
the class CoordinatorResourceTestClient method getLoadStatus.
private Map<String, Integer> getLoadStatus() {
Map<String, Integer> status = null;
try {
StatusResponseHolder response = makeRequest(HttpMethod.GET, getLoadStatusURL());
status = jsonMapper.readValue(response.getContent(), new TypeReference<Map<String, Integer>>() {
});
} catch (Exception e) {
throw Throwables.propagate(e);
}
return status;
}
use of com.metamx.http.client.response.StatusResponseHolder in project druid by druid-io.
the class CoordinatorResourceTestClient method getSegmentIntervals.
// return a list of the segment dates for the specified datasource
public ArrayList<String> getSegmentIntervals(final String dataSource) throws Exception {
ArrayList<String> segments = null;
try {
StatusResponseHolder response = makeRequest(HttpMethod.GET, getIntervalsURL(dataSource));
segments = jsonMapper.readValue(response.getContent(), new TypeReference<ArrayList<String>>() {
});
} catch (Exception e) {
throw Throwables.propagate(e);
}
return segments;
}
use of com.metamx.http.client.response.StatusResponseHolder in project druid by druid-io.
the class OverlordResourceTestClient method shutDownTask.
public Map<String, String> shutDownTask(String taskID) {
try {
StatusResponseHolder response = makeRequest(HttpMethod.POST, String.format("%stask/%s/shutdown", getIndexerURL(), URLEncoder.encode(taskID, "UTF-8")));
LOG.info("Shutdown Task %s response %s", taskID, response.getContent());
return jsonMapper.readValue(response.getContent(), new TypeReference<Map<String, String>>() {
});
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
use of com.metamx.http.client.response.StatusResponseHolder in project druid by druid-io.
the class OverlordResourceTestClient method getTasks.
private List<TaskResponseObject> getTasks(String identifier) {
try {
StatusResponseHolder response = makeRequest(HttpMethod.GET, String.format("%s%s", getIndexerURL(), identifier));
LOG.info("Tasks %s response %s", identifier, response.getContent());
return jsonMapper.readValue(response.getContent(), new TypeReference<List<TaskResponseObject>>() {
});
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
Aggregations