use of org.eclipse.che.plugin.docker.client.json.ExecStart in project che by eclipse.
the class DockerConnector method startExec.
/**
* Starts a previously set up exec instance.
*
* @param execOutputProcessor
* processor for exec output
* @throws IOException
* when a problem occurs with docker api calls
*/
public void startExec(final StartExecParams params, @Nullable MessageProcessor<LogMessage> execOutputProcessor) throws IOException {
final ExecStart execStart = new ExecStart().withDetach(params.isDetach() == Boolean.TRUE).withTty(params.isTty() == Boolean.TRUE);
byte[] entityBytesArray = toJson(execStart).getBytes(StandardCharsets.UTF_8);
try (DockerConnection connection = connectionFactory.openConnection(dockerDaemonUri).method("POST").path(apiVersionPathPrefix + "/exec/" + params.getExecId() + "/start").header("Content-Type", MediaType.APPLICATION_JSON).header("Content-Length", entityBytesArray.length).entity(entityBytesArray)) {
final DockerResponse response = connection.request();
final int status = response.getStatus();
// in fact docker API returns 200 or 204 status.
if (status / 100 != 2) {
throw getDockerException(response);
}
if (status != NO_CONTENT.getStatusCode() && execOutputProcessor != null) {
try (InputStream responseStream = response.getInputStream()) {
new LogMessagePumper(responseStream, execOutputProcessor).start();
}
}
}
}
Aggregations