use of org.apache.druid.java.util.common.ISE in project druid by druid-io.
the class AbstractQueryResourceTestClient method query.
public List<Map<String, Object>> query(String url, QueryType query) {
try {
String expectedResponseType = this.contentTypeHeader;
Request request = new Request(HttpMethod.POST, new URL(url));
request.setContent(this.contentTypeHeader, encoderDecoderMap.get(this.contentTypeHeader).encode(query));
if (this.acceptHeader != null) {
expectedResponseType = this.acceptHeader;
request.addHeader(HttpHeaders.Names.ACCEPT, this.acceptHeader);
}
BytesFullResponseHolder response = httpClient.go(request, new BytesFullResponseHandler()).get();
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
throw new ISE("Error while querying[%s] status[%s] content[%s]", url, response.getStatus(), new String(response.getContent(), StandardCharsets.UTF_8));
}
String responseType = response.getResponse().headers().get(HttpHeaders.Names.CONTENT_TYPE);
if (!expectedResponseType.equals(responseType)) {
throw new ISE("Content-Type[%s] in HTTP response does not match the expected[%s]", responseType, expectedResponseType);
}
return this.encoderDecoderMap.get(responseType).decode(response.getContent());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.apache.druid.java.util.common.ISE in project druid by druid-io.
the class CompactionResourceTestClient method getDataSourceCompactionConfig.
public DataSourceCompactionConfig getDataSourceCompactionConfig(String dataSource) throws Exception {
String url = StringUtils.format("%sconfig/compaction/%s", getCoordinatorURL(), StringUtils.urlEncode(dataSource));
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<DataSourceCompactionConfig>() {
});
}
use of org.apache.druid.java.util.common.ISE in project druid by druid-io.
the class CompactionResourceTestClient method deleteCompactionConfig.
public void deleteCompactionConfig(final String dataSource) throws Exception {
String url = StringUtils.format("%sconfig/compaction/%s", getCoordinatorURL(), StringUtils.urlEncode(dataSource));
StatusResponseHolder response = httpClient.go(new Request(HttpMethod.DELETE, new URL(url)), responseHandler).get();
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
throw new ISE("Error while deleting compaction config status[%s] content[%s]", response.getStatus(), response.getContent());
}
}
use of org.apache.druid.java.util.common.ISE 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.common.ISE 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());
}
}
Aggregations