Search in sources :

Example 36 with Request

use of org.apache.druid.java.util.http.client.Request in project druid by druid-io.

the class OverlordResourceTestClient method getSupervisorHealth.

public void getSupervisorHealth(String id) {
    try {
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.GET, new URL(StringUtils.format("%ssupervisor/%s/health", getIndexerURL(), StringUtils.urlEncode(id)))), StatusResponseHandler.getInstance()).get();
        if (!response.getStatus().equals(HttpResponseStatus.OK)) {
            throw new ISE("Error while get supervisor health, response [%s %s]", response.getStatus(), response.getContent());
        }
        LOG.debug("get supervisor health with id[%s]", id);
    } catch (ISE e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Request(org.apache.druid.java.util.http.client.Request) StatusResponseHolder(org.apache.druid.java.util.http.client.response.StatusResponseHolder) ISE(org.apache.druid.java.util.common.ISE) URL(java.net.URL)

Example 37 with Request

use of org.apache.druid.java.util.http.client.Request in project druid by druid-io.

the class OverlordResourceTestClient method resumeSupervisor.

public void resumeSupervisor(String id) {
    try {
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, new URL(StringUtils.format("%ssupervisor/%s/resume", getIndexerURL(), StringUtils.urlEncode(id)))), StatusResponseHandler.getInstance()).get();
        if (!response.getStatus().equals(HttpResponseStatus.OK)) {
            throw new ISE("Error while resuming supervisor, response [%s %s]", response.getStatus(), response.getContent());
        }
        LOG.debug("Resumed supervisor with id[%s]", id);
    } catch (ISE e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Request(org.apache.druid.java.util.http.client.Request) StatusResponseHolder(org.apache.druid.java.util.http.client.response.StatusResponseHolder) ISE(org.apache.druid.java.util.common.ISE) URL(java.net.URL)

Example 38 with Request

use of org.apache.druid.java.util.http.client.Request in project druid by druid-io.

the class OverlordResourceTestClient method resetSupervisor.

public void resetSupervisor(String id) {
    try {
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, new URL(StringUtils.format("%ssupervisor/%s/reset", getIndexerURL(), StringUtils.urlEncode(id)))), StatusResponseHandler.getInstance()).get();
        if (!response.getStatus().equals(HttpResponseStatus.OK)) {
            throw new ISE("Error while resetting supervisor, response [%s %s]", response.getStatus(), response.getContent());
        }
        LOG.debug("Reset supervisor with id[%s]", id);
    } catch (ISE e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Request(org.apache.druid.java.util.http.client.Request) StatusResponseHolder(org.apache.druid.java.util.http.client.response.StatusResponseHolder) ISE(org.apache.druid.java.util.common.ISE) URL(java.net.URL)

Example 39 with Request

use of org.apache.druid.java.util.http.client.Request in project druid by druid-io.

the class OverlordResourceTestClient method getSupervisorHistory.

public List<Object> getSupervisorHistory(String id) {
    try {
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.GET, new URL(StringUtils.format("%ssupervisor/%s/history", 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());
        }
        List<Object> responseData = jsonMapper.readValue(response.getContent(), new TypeReference<List<Object>>() {
        });
        return responseData;
    } catch (ISE e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Request(org.apache.druid.java.util.http.client.Request) StatusResponseHolder(org.apache.druid.java.util.http.client.response.StatusResponseHolder) ISE(org.apache.druid.java.util.common.ISE) ArrayList(java.util.ArrayList) List(java.util.List) URL(java.net.URL)

Example 40 with Request

use of org.apache.druid.java.util.http.client.Request in project druid by druid-io.

the class OverlordResourceTestClient method getLockedIntervals.

public Map<String, List<Interval>> getLockedIntervals(Map<String, Integer> minTaskPriority) {
    try {
        String jsonBody = jsonMapper.writeValueAsString(minTaskPriority);
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, new URL(getIndexerURL() + "lockedIntervals")).setContent("application/json", StringUtils.toUtf8(jsonBody)), StatusResponseHandler.getInstance()).get();
        return jsonMapper.readValue(response.getContent(), new TypeReference<Map<String, List<Interval>>>() {
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Request(org.apache.druid.java.util.http.client.Request) StatusResponseHolder(org.apache.druid.java.util.http.client.response.StatusResponseHolder) Map(java.util.Map) URL(java.net.URL) Interval(org.joda.time.Interval)

Aggregations

Request (org.apache.druid.java.util.http.client.Request)148 URL (java.net.URL)129 Test (org.junit.Test)84 StatusResponseHolder (org.apache.druid.java.util.http.client.response.StatusResponseHolder)42 ISE (org.apache.druid.java.util.common.ISE)29 StringFullResponseHolder (org.apache.druid.java.util.http.client.response.StringFullResponseHolder)28 ObjectOrErrorResponseHandler (org.apache.druid.java.util.http.client.response.ObjectOrErrorResponseHandler)24 IOException (java.io.IOException)23 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)22 ArrayList (java.util.ArrayList)22 HashMap (java.util.HashMap)14 Map (java.util.Map)14 ExecutionException (java.util.concurrent.ExecutionException)14 InputStream (java.io.InputStream)12 HttpResponse (org.jboss.netty.handler.codec.http.HttpResponse)11 RE (org.apache.druid.java.util.common.RE)10 InputStreamResponseHandler (org.apache.druid.java.util.http.client.response.InputStreamResponseHandler)10 BigEndianHeapChannelBuffer (org.jboss.netty.buffer.BigEndianHeapChannelBuffer)9 ImmutableMap (com.google.common.collect.ImmutableMap)8 HttpResponseHandler (org.apache.druid.java.util.http.client.response.HttpResponseHandler)8