Search in sources :

Example 6 with StatusResponseHolder

use of org.apache.druid.java.util.http.client.response.StatusResponseHolder 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 7 with StatusResponseHolder

use of org.apache.druid.java.util.http.client.response.StatusResponseHolder 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 8 with StatusResponseHolder

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

the class CoordinatorResourceTestClient method getSegmentIntervals.

// return a list of the segment dates for the specified datasource
public List<String> getSegmentIntervals(final String dataSource) {
    List<String> segments;
    try {
        StatusResponseHolder response = makeRequest(HttpMethod.GET, getIntervalsURL(dataSource));
        segments = jsonMapper.readValue(response.getContent(), new TypeReference<List<String>>() {
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return segments;
}
Also used : StatusResponseHolder(org.apache.druid.java.util.http.client.response.StatusResponseHolder) TypeReference(com.fasterxml.jackson.core.type.TypeReference)

Example 9 with StatusResponseHolder

use of org.apache.druid.java.util.http.client.response.StatusResponseHolder 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 10 with StatusResponseHolder

use of org.apache.druid.java.util.http.client.response.StatusResponseHolder 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)

Aggregations

StatusResponseHolder (org.apache.druid.java.util.http.client.response.StatusResponseHolder)69 URL (java.net.URL)50 Request (org.apache.druid.java.util.http.client.Request)42 ISE (org.apache.druid.java.util.common.ISE)33 ExecutionException (java.util.concurrent.ExecutionException)13 Test (org.junit.Test)12 Lifecycle (org.apache.druid.java.util.common.lifecycle.Lifecycle)10 Map (java.util.Map)8 ArrayList (java.util.ArrayList)6 TypeReference (com.fasterxml.jackson.core.type.TypeReference)5 IOException (java.io.IOException)5 RE (org.apache.druid.java.util.common.RE)5 ChannelException (org.jboss.netty.channel.ChannelException)5 List (java.util.List)4 ExecutorService (java.util.concurrent.ExecutorService)4 Future (java.util.concurrent.Future)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 BufferedReader (java.io.BufferedReader)3 InputStreamReader (java.io.InputStreamReader)3