use of org.apache.druid.java.util.http.client.response.StringFullResponseHolder in project druid by apache.
the class HttpIndexingServiceClient method killPendingSegments.
@Override
public int killPendingSegments(String dataSource, DateTime end) {
final String endPoint = StringUtils.format("/druid/indexer/v1/pendingSegments/%s?interval=%s", StringUtils.urlEncode(dataSource), new Interval(DateTimes.MIN, end));
try {
final StringFullResponseHolder responseHolder = druidLeaderClient.go(druidLeaderClient.makeRequest(HttpMethod.DELETE, endPoint));
if (!responseHolder.getStatus().equals(HttpResponseStatus.OK)) {
throw new ISE("Error while killing pendingSegments of dataSource[%s] created until [%s]", dataSource, end);
}
final Map<String, Object> resultMap = jsonMapper.readValue(responseHolder.getContent(), JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT);
final Object numDeletedObject = resultMap.get("numDeleted");
return (Integer) Preconditions.checkNotNull(numDeletedObject, "numDeletedObject");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations