use of water.deploy.LaunchJar in project h2o-2 by h2oai.
the class CloudConnect method launch.
/**
* Upload jars to an existing cloud and launches a custom job. Uses the Web API.
*/
public static void launch(String job, String host, File... jars) throws Exception {
HttpClient client = new HttpClient();
String args = "job_class=" + job + "&jars=";
for (File f : jars) {
PostMethod post = new PostMethod("http://" + host + "/Upload.json?key=" + f.getName());
Part[] parts = { new FilePart(f.getName(), f) };
post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
if (200 != client.executeMethod(post))
throw new RuntimeException("Request failed: " + post.getStatusLine());
args += f.getName() + ",";
post.releaseConnection();
}
String href = new LaunchJar().href();
GetMethod get = new GetMethod("http://" + host + href + ".json?" + args);
if (200 != client.executeMethod(get))
throw new RuntimeException("Request failed: " + get.getStatusLine());
get.releaseConnection();
}
Aggregations