Search in sources :

Example 31 with Request

use of org.apache.druid.java.util.http.client.Request 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>() {
    });
}
Also used : CoordinatorCompactionConfig(org.apache.druid.server.coordinator.CoordinatorCompactionConfig) 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 32 with Request

use of org.apache.druid.java.util.http.client.Request 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());
    }
}
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 33 with Request

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

the class CoordinatorResourceTestClient method getLoadStatus.

private Map<String, Integer> getLoadStatus(String dataSorce) {
    String url = getLoadStatusURL(dataSorce);
    Map<String, Integer> status;
    try {
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.GET, new URL(url)), responseHandler).get();
        if (response.getStatus().getCode() == HttpResponseStatus.NO_CONTENT.getCode()) {
            return null;
        }
        if (response.getStatus().getCode() != HttpResponseStatus.OK.getCode()) {
            throw new ISE("Error while making request to url[%s] status[%s] content[%s]", url, response.getStatus(), response.getContent());
        }
        status = jsonMapper.readValue(response.getContent(), new TypeReference<Map<String, Integer>>() {
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return status;
}
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) TypeReference(com.fasterxml.jackson.core.type.TypeReference) URL(java.net.URL)

Example 34 with Request

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

the class CoordinatorResourceTestClient method postDynamicConfig.

public void postDynamicConfig(CoordinatorDynamicConfig coordinatorDynamicConfig) throws Exception {
    String url = StringUtils.format("%sconfig", getCoordinatorURL());
    StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, new URL(url)).setContent("application/json", jsonMapper.writeValueAsBytes(coordinatorDynamicConfig)), responseHandler).get();
    if (!response.getStatus().equals(HttpResponseStatus.OK)) {
        throw new ISE("Error while setting dynamic config[%s] status[%s] content[%s]", url, response.getStatus(), response.getContent());
    }
}
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 35 with Request

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

the class OverlordResourceTestClient method getSupervisorStatus.

public SupervisorStateManager.BasicState getSupervisorStatus(String id) {
    try {
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.GET, new URL(StringUtils.format("%ssupervisor/%s/status", 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());
        }
        Map<String, Object> responseData = jsonMapper.readValue(response.getContent(), JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT);
        Map<String, Object> payload = jsonMapper.convertValue(responseData.get("payload"), JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT);
        String state = (String) payload.get("state");
        LOG.debug("Supervisor id[%s] has state [%s]", id, state);
        return SupervisorStateManager.BasicState.valueOf(state);
    } 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