use of org.eclipse.che.api.core.rest.HttpJsonResponse in project che by eclipse.
the class ApiEndpointAccessibilityChecker method start.
@PostConstruct
public void start() {
try {
final HttpJsonResponse pingResponse = httpJsonRequestFactory.fromUrl(apiEndpoint).setMethod(HttpMethod.GET).setTimeout(2000).request();
if (pingResponse.getResponseCode() == HttpURLConnection.HTTP_OK) {
return;
}
} catch (ApiException | IOException e) {
LOG.error(e.getLocalizedMessage(), e);
}
LOG.error("The workspace agent has attempted to start, but it is unable to ping the Che server at " + apiEndpoint);
LOG.error("The workspace agent has been forcefully stopped. " + "This error happens when the agent cannot resolve the location of the Che server. " + "This error can usually be fixed with additional configuration settings in /conf/che.properties. " + "The Che server will stop this workspace after a short timeout. " + "You can get help by posting your config, stacktrace and workspace /etc/hosts below as a GitHub issue.");
// content of /etc/hosts file may provide clues on why the connection failed, e.g. how che-host is resolved
try {
LOG.info("Workspace /etc/hosts: " + IoUtil.readAndCloseQuietly(new FileInputStream(new File("/etc/hosts"))));
} catch (Exception e) {
LOG.info(e.getLocalizedMessage(), e);
}
System.exit(0);
}
use of org.eclipse.che.api.core.rest.HttpJsonResponse in project che by eclipse.
the class WsAgentHealthCheckerImpl method check.
@Override
public WsAgentHealthStateDto check(Machine machine) throws ServerException {
Server wsAgent = getWsAgent(machine);
final WsAgentHealthStateDto agentHealthStateDto = newDto(WsAgentHealthStateDto.class);
if (wsAgent == null) {
return agentHealthStateDto.withCode(NOT_FOUND.getStatusCode()).withReason("Workspace Agent not available");
}
try {
final HttpJsonRequest pingRequest = createPingRequest(machine);
final HttpJsonResponse response = pingRequest.request();
return agentHealthStateDto.withCode(response.getResponseCode());
} catch (ApiException | IOException e) {
return agentHealthStateDto.withCode(SERVICE_UNAVAILABLE.getStatusCode()).withReason(e.getMessage());
}
}
Aggregations