Search in sources :

Example 71 with Request

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

the class OverlordResourceTestClient method shutdownSupervisor.

public void shutdownSupervisor(String id) {
    try {
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, new URL(StringUtils.format("%ssupervisor/%s/shutdown", getIndexerURL(), StringUtils.urlEncode(id)))), StatusResponseHandler.getInstance()).get();
        if (!response.getStatus().equals(HttpResponseStatus.OK)) {
            throw new ISE("Error while shutting down supervisor, response [%s %s]", response.getStatus(), response.getContent());
        }
        LOG.debug("Shutdown 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 72 with Request

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

the class OverlordResourceTestClient method submitSupervisor.

public String submitSupervisor(String spec) {
    try {
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, new URL(getIndexerURL() + "supervisor")).setContent("application/json", StringUtils.toUtf8(spec)), StatusResponseHandler.getInstance()).get();
        if (!response.getStatus().equals(HttpResponseStatus.OK)) {
            throw new ISE("Error while submitting supervisor to overlord, response [%s: %s]", response.getStatus(), response.getContent());
        }
        Map<String, String> responseData = jsonMapper.readValue(response.getContent(), JacksonUtils.TYPE_REFERENCE_MAP_STRING_STRING);
        String id = responseData.get("id");
        LOG.debug("Submitted supervisor with id[%s]", id);
        return id;
    } 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 73 with Request

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

the class OverlordResourceTestClient method suspendSupervisor.

public void suspendSupervisor(String id) {
    try {
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, new URL(StringUtils.format("%ssupervisor/%s/suspend", getIndexerURL(), StringUtils.urlEncode(id)))), StatusResponseHandler.getInstance()).get();
        if (!response.getStatus().equals(HttpResponseStatus.OK)) {
            throw new ISE("Error while suspending supervisor, response [%s %s]", response.getStatus(), response.getContent());
        }
        LOG.debug("Suspended 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 74 with Request

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

the class OverlordResourceTestClient method shutdownTask.

public void shutdownTask(String id) {
    try {
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, new URL(StringUtils.format("%stask/%s/shutdown", getIndexerURL(), StringUtils.urlEncode(id)))), StatusResponseHandler.getInstance()).get();
        if (!response.getStatus().equals(HttpResponseStatus.OK)) {
            throw new ISE("Error while shutdown task, response [%s %s]", response.getStatus(), response.getContent());
        }
        LOG.debug("Shutdown task 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 75 with Request

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

the class OverlordResourceTestClient method terminateSupervisor.

public void terminateSupervisor(String id) {
    try {
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, new URL(StringUtils.format("%ssupervisor/%s/terminate", getIndexerURL(), StringUtils.urlEncode(id)))), StatusResponseHandler.getInstance()).get();
        if (!response.getStatus().equals(HttpResponseStatus.OK)) {
            throw new ISE("Error while terminating supervisor, response [%s %s]", response.getStatus(), response.getContent());
        }
        LOG.debug("Terminate 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)

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