Search in sources :

Example 41 with StatusResponseHolder

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

the class CoordinatorResourceTestClient method getSegments.

/**
 * return a list of the segment dates for the specified data source
 */
public List<String> getSegments(final String dataSource) {
    List<String> segments;
    try {
        StatusResponseHolder response = makeRequest(HttpMethod.GET, getSegmentsMetadataURL(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 42 with StatusResponseHolder

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

the class CoordinatorResourceTestClient method postLoadRules.

public void postLoadRules(String datasourceName, List<Rule> rules) throws Exception {
    String url = StringUtils.format("%srules/%s", getCoordinatorURL(), datasourceName);
    StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, new URL(url)).setContent("application/json", jsonMapper.writeValueAsBytes(rules)), 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 43 with StatusResponseHolder

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

the class CoordinatorResourceTestClient method getFullSegmentsMetadata.

public List<DataSegment> getFullSegmentsMetadata(final String dataSource) {
    List<DataSegment> segments;
    try {
        StatusResponseHolder response = makeRequest(HttpMethod.GET, getFullSegmentsMetadataURL(dataSource));
        segments = jsonMapper.readValue(response.getContent(), new TypeReference<List<DataSegment>>() {
        });
    } 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) DataSegment(org.apache.druid.timeline.DataSegment)

Example 44 with StatusResponseHolder

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

the class CoordinatorResourceTestClient method getLookupLoadStatus.

@Nullable
private Map<String, Map<HostAndPort, LookupsState<LookupExtractorFactoryMapContainer>>> getLookupLoadStatus() {
    String url = StringUtils.format("%slookups/nodeStatus", getCoordinatorURL());
    Map<String, Map<HostAndPort, LookupsState<LookupExtractorFactoryMapContainer>>> status;
    try {
        StatusResponseHolder response = httpClient.go(new Request(HttpMethod.GET, new URL(url)), responseHandler).get();
        if (response.getStatus().getCode() == HttpResponseStatus.NOT_FOUND.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, Map<HostAndPort, LookupsState<LookupExtractorFactoryMapContainer>>>>() {
        });
    } 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) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) URL(java.net.URL) LookupExtractorFactoryMapContainer(org.apache.druid.server.lookup.cache.LookupExtractorFactoryMapContainer) Nullable(javax.annotation.Nullable)

Example 45 with StatusResponseHolder

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

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