Search in sources :

Example 11 with StatusResponseHolder

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

the class OverlordResourceTestClient method getTasks.

private List<TaskResponseObject> getTasks(String identifier) {
    try {
        StatusResponseHolder response = makeRequest(HttpMethod.GET, StringUtils.format("%s%s", getIndexerURL(), identifier));
        LOG.debug("Tasks %s response %s", identifier, response.getContent());
        return jsonMapper.readValue(response.getContent(), new TypeReference<List<TaskResponseObject>>() {
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : StatusResponseHolder(org.apache.druid.java.util.http.client.response.StatusResponseHolder) ArrayList(java.util.ArrayList) List(java.util.List)

Example 12 with StatusResponseHolder

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

Example 13 with StatusResponseHolder

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

the class OverlordResourceTestClient method getSupervisorHealth.

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

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

the class OverlordResourceTestClient method getTaskStatus.

public TaskStatusPlus getTaskStatus(String taskID) {
    try {
        StatusResponseHolder response = makeRequest(HttpMethod.GET, StringUtils.format("%stask/%s/status", getIndexerURL(), StringUtils.urlEncode(taskID)));
        LOG.debug("Index status response" + response.getContent());
        TaskStatusResponse taskStatusResponse = jsonMapper.readValue(response.getContent(), new TypeReference<TaskStatusResponse>() {
        });
        return taskStatusResponse.getStatus();
    } catch (ISE e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : TaskStatusResponse(org.apache.druid.client.indexing.TaskStatusResponse) StatusResponseHolder(org.apache.druid.java.util.http.client.response.StatusResponseHolder) ISE(org.apache.druid.java.util.common.ISE)

Example 15 with StatusResponseHolder

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

the class OverlordResourceTestClient method resumeSupervisor.

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