Search in sources :

Example 86 with StringFullResponseHolder

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);
    }
}
Also used : StringFullResponseHolder(org.apache.druid.java.util.http.client.response.StringFullResponseHolder) ISE(org.apache.druid.java.util.common.ISE) IOException(java.io.IOException) Interval(org.joda.time.Interval)

Aggregations

StringFullResponseHolder (org.apache.druid.java.util.http.client.response.StringFullResponseHolder)86 Test (org.junit.Test)56 URL (java.net.URL)50 Request (org.apache.druid.java.util.http.client.Request)49 HashMap (java.util.HashMap)32 IOException (java.io.IOException)31 BigEndianHeapChannelBuffer (org.jboss.netty.buffer.BigEndianHeapChannelBuffer)18 HttpResponse (org.jboss.netty.handler.codec.http.HttpResponse)18 ISE (org.apache.druid.java.util.common.ISE)16 HttpClient (org.apache.druid.java.util.http.client.HttpClient)12 DefaultHttpResponse (org.jboss.netty.handler.codec.http.DefaultHttpResponse)12 ArrayList (java.util.ArrayList)8 List (java.util.List)8 ChannelException (org.jboss.netty.channel.ChannelException)8 MalformedURLException (java.net.MalformedURLException)7 ExecutionException (java.util.concurrent.ExecutionException)7 HttpResponseStatus (org.jboss.netty.handler.codec.http.HttpResponseStatus)6 Duration (org.joda.time.Duration)6 Interval (org.joda.time.Interval)6 TypeReference (com.fasterxml.jackson.core.type.TypeReference)4