use of com.ning.http.client.PerRequestConfig in project Singularity by HubSpot.
the class SandboxManager method browse.
public Collection<MesosFileObject> browse(String slaveHostname, String fullPath) throws SlaveNotFoundException {
try {
PerRequestConfig timeoutConfig = new PerRequestConfig();
timeoutConfig.setRequestTimeoutInMs((int) configuration.getSandboxHttpTimeoutMillis());
Response response = asyncHttpClient.prepareGet(String.format("http://%s:5051/files/browse", slaveHostname)).setPerRequestConfig(timeoutConfig).addQueryParameter("path", fullPath).execute().get();
if (response.getStatusCode() == 404) {
return Collections.emptyList();
}
if (response.getStatusCode() != 200) {
throw new RuntimeException(String.format("Got HTTP %s from Mesos slave", response.getStatusCode()));
}
return objectMapper.readValue(response.getResponseBodyAsStream(), MESOS_FILE_OBJECTS);
} catch (ConnectException ce) {
throw new SlaveNotFoundException(ce);
} catch (Exception e) {
if (e.getCause().getClass() == ConnectException.class) {
throw new SlaveNotFoundException(e);
} else {
throw Throwables.propagate(e);
}
}
}
Aggregations