Search in sources :

Example 51 with ISE

use of org.apache.druid.java.util.common.ISE in project druid by druid-io.

the class AbstractQueryResourceTestClient method query.

public List<Map<String, Object>> query(String url, QueryType query) {
    try {
        String expectedResponseType = this.contentTypeHeader;
        Request request = new Request(HttpMethod.POST, new URL(url));
        request.setContent(this.contentTypeHeader, encoderDecoderMap.get(this.contentTypeHeader).encode(query));
        if (this.acceptHeader != null) {
            expectedResponseType = this.acceptHeader;
            request.addHeader(HttpHeaders.Names.ACCEPT, this.acceptHeader);
        }
        BytesFullResponseHolder response = httpClient.go(request, new BytesFullResponseHandler()).get();
        if (!response.getStatus().equals(HttpResponseStatus.OK)) {
            throw new ISE("Error while querying[%s] status[%s] content[%s]", url, response.getStatus(), new String(response.getContent(), StandardCharsets.UTF_8));
        }
        String responseType = response.getResponse().headers().get(HttpHeaders.Names.CONTENT_TYPE);
        if (!expectedResponseType.equals(responseType)) {
            throw new ISE("Content-Type[%s] in HTTP response does not match the expected[%s]", responseType, expectedResponseType);
        }
        return this.encoderDecoderMap.get(responseType).decode(response.getContent());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : BytesFullResponseHolder(org.apache.druid.java.util.http.client.response.BytesFullResponseHolder) Request(org.apache.druid.java.util.http.client.Request) ISE(org.apache.druid.java.util.common.ISE) URL(java.net.URL) IOException(java.io.IOException) BytesFullResponseHandler(org.apache.druid.java.util.http.client.response.BytesFullResponseHandler)

Example 52 with ISE

use of org.apache.druid.java.util.common.ISE in project druid by druid-io.

the class CompactionResourceTestClient method getDataSourceCompactionConfig.

public DataSourceCompactionConfig getDataSourceCompactionConfig(String dataSource) throws Exception {
    String url = StringUtils.format("%sconfig/compaction/%s", getCoordinatorURL(), StringUtils.urlEncode(dataSource));
    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<DataSourceCompactionConfig>() {
    });
}
Also used : DataSourceCompactionConfig(org.apache.druid.server.coordinator.DataSourceCompactionConfig) 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 53 with ISE

use of org.apache.druid.java.util.common.ISE in project druid by druid-io.

the class CompactionResourceTestClient method deleteCompactionConfig.

public void deleteCompactionConfig(final String dataSource) throws Exception {
    String url = StringUtils.format("%sconfig/compaction/%s", getCoordinatorURL(), StringUtils.urlEncode(dataSource));
    StatusResponseHolder response = httpClient.go(new Request(HttpMethod.DELETE, new URL(url)), responseHandler).get();
    if (!response.getStatus().equals(HttpResponseStatus.OK)) {
        throw new ISE("Error while deleting compaction config 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 54 with ISE

use of org.apache.druid.java.util.common.ISE 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 55 with ISE

use of org.apache.druid.java.util.common.ISE 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)

Aggregations

ISE (org.apache.druid.java.util.common.ISE)354 IOException (java.io.IOException)95 ArrayList (java.util.ArrayList)90 Map (java.util.Map)68 List (java.util.List)60 File (java.io.File)48 Interval (org.joda.time.Interval)48 DataSegment (org.apache.druid.timeline.DataSegment)44 HashMap (java.util.HashMap)43 Nullable (javax.annotation.Nullable)43 URL (java.net.URL)36 StatusResponseHolder (org.apache.druid.java.util.http.client.response.StatusResponseHolder)33 Request (org.apache.druid.java.util.http.client.Request)30 ExecutionException (java.util.concurrent.ExecutionException)29 ImmutableMap (com.google.common.collect.ImmutableMap)28 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)28 VisibleForTesting (com.google.common.annotations.VisibleForTesting)27 Collectors (java.util.stream.Collectors)27 IAE (org.apache.druid.java.util.common.IAE)27 ImmutableList (com.google.common.collect.ImmutableList)26