use of org.apache.druid.java.util.http.client.Request in project druid by druid-io.
the class CompactionResourceTestClient method getCoordinatorCompactionConfigs.
public CoordinatorCompactionConfig getCoordinatorCompactionConfigs() throws Exception {
String url = StringUtils.format("%sconfig/compaction", getCoordinatorURL());
StatusResponseHolder response = httpClient.go(new Request(HttpMethod.GET, new URL(url)), responseHandler).get();
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
throw new ISE("Error while getting compaction config status[%s] content[%s]", response.getStatus(), response.getContent());
}
return jsonMapper.readValue(response.getContent(), new TypeReference<CoordinatorCompactionConfig>() {
});
}
use of org.apache.druid.java.util.http.client.Request in project druid by druid-io.
the class CompactionResourceTestClient method forceTriggerAutoCompaction.
public void forceTriggerAutoCompaction() throws Exception {
String url = StringUtils.format("%scompaction/compact", getCoordinatorURL());
StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, new URL(url)), responseHandler).get();
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
throw new ISE("Error while force trigger auto compaction status[%s] content[%s]", response.getStatus(), response.getContent());
}
}
use of org.apache.druid.java.util.http.client.Request in project druid by druid-io.
the class CoordinatorResourceTestClient method getLoadStatus.
private Map<String, Integer> getLoadStatus(String dataSorce) {
String url = getLoadStatusURL(dataSorce);
Map<String, Integer> status;
try {
StatusResponseHolder response = httpClient.go(new Request(HttpMethod.GET, new URL(url)), responseHandler).get();
if (response.getStatus().getCode() == HttpResponseStatus.NO_CONTENT.getCode()) {
return null;
}
if (response.getStatus().getCode() != HttpResponseStatus.OK.getCode()) {
throw new ISE("Error while making request to url[%s] status[%s] content[%s]", url, response.getStatus(), response.getContent());
}
status = jsonMapper.readValue(response.getContent(), new TypeReference<Map<String, Integer>>() {
});
} catch (Exception e) {
throw new RuntimeException(e);
}
return status;
}
use of org.apache.druid.java.util.http.client.Request in project druid by druid-io.
the class CoordinatorResourceTestClient method postDynamicConfig.
public void postDynamicConfig(CoordinatorDynamicConfig coordinatorDynamicConfig) throws Exception {
String url = StringUtils.format("%sconfig", getCoordinatorURL());
StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, new URL(url)).setContent("application/json", jsonMapper.writeValueAsBytes(coordinatorDynamicConfig)), responseHandler).get();
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
throw new ISE("Error while setting dynamic config[%s] status[%s] content[%s]", url, response.getStatus(), response.getContent());
}
}
use of org.apache.druid.java.util.http.client.Request in project druid by druid-io.
the class OverlordResourceTestClient method getSupervisorStatus.
public SupervisorStateManager.BasicState getSupervisorStatus(String id) {
try {
StatusResponseHolder response = httpClient.go(new Request(HttpMethod.GET, new URL(StringUtils.format("%ssupervisor/%s/status", getIndexerURL(), StringUtils.urlEncode(id)))), StatusResponseHandler.getInstance()).get();
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
throw new ISE("Error while getting supervisor status, response [%s %s]", response.getStatus(), response.getContent());
}
Map<String, Object> responseData = jsonMapper.readValue(response.getContent(), JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT);
Map<String, Object> payload = jsonMapper.convertValue(responseData.get("payload"), JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT);
String state = (String) payload.get("state");
LOG.debug("Supervisor id[%s] has state [%s]", id, state);
return SupervisorStateManager.BasicState.valueOf(state);
} catch (ISE e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations