Skip to content
Snippets Groups Projects
Commit bb34acc8 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

Testing HaaS API for benchamrk

parent c6bc5861
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,8 @@ public class Job {
private static final String JOB_HAS_DATA_TO_DOWNLOAD_PROPERTY = "job.needDownload";
private static final String JOB_NAME = "job.name";
public static boolean isJobPath(Path p) {
return isValidPath(p);
}
......@@ -73,12 +75,15 @@ public class Job {
}
};
public Job(Path basePath, Supplier<HaaSClient> haasClientSupplier, Progress progress) throws IOException {
private String name;
public Job(String name, Path basePath, Supplier<HaaSClient> haasClientSupplier, Progress progress) throws IOException {
this(haasClientSupplier);
HaaSClient client = this.haasClientSupplier.get();
long id = client.createJob("TestOutRedirect", Collections.emptyList(),
long id = client.createJob(name, Collections.emptyList(),
notifier = new P_ProgressNotifierAdapter(progress));
jobDir = basePath.resolve("" + id);
this.name = name;
Files.createDirectory(jobDir);
updateState();
}
......@@ -171,6 +176,7 @@ public class Job {
if (needsDownload != null) {
prop.setProperty(JOB_HAS_DATA_TO_DOWNLOAD_PROPERTY, needsDownload.toString());
}
prop.setProperty(JOB_NAME, name);
prop.store(ow, null);
}
}
......@@ -181,6 +187,7 @@ public class Job {
prop.load(is);
if (prop.containsKey(JOB_HAS_DATA_TO_DOWNLOAD_PROPERTY)) {
needsDownload = Boolean.parseBoolean(prop.getProperty(JOB_HAS_DATA_TO_DOWNLOAD_PROPERTY));
name = prop.getProperty(JOB_NAME);
}
}
}
......
......@@ -47,7 +47,7 @@ public class JobManager {
public JobInfo createJob(Progress progress) throws IOException {
Job job;
jobs.add(job = new Job(workDirectory, this::getHaasClient, progress));
jobs.add(job = new Job(settings.getJobName(),workDirectory, this::getHaasClient, progress));
return new JobInfo(job) {
@Override
public JobState getState() {
......
package cz.it4i.fiji.haas;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cz.it4i.fiji.haas.JobManager.JobInfo;
import net.imagej.updater.util.Progress;
public class RunBenchmark {
private static Logger log = LoggerFactory.getLogger(cz.it4i.fiji.haas.RunBenchmark.class);
public static class CreateJob{
public static void main(String[] args) throws IOException {
Path p = Paths.get("/tmp/benchmark");
if(!Files.exists(p)) {
Files.createDirectory(p);
}
BenchmarkJobManager benchmarkJobManager = new BenchmarkJobManager(Paths.get("/tmp"), new P_Progress());
JobInfo ji = benchmarkJobManager.createJob();
log.info("job: " + ji + " created.");
}
}
private static class P_Progress implements Progress {
@Override
public void setTitle(String title) {
}
@Override
public void setCount(int count, int total) {
}
@Override
public void addItem(Object item) {
}
@Override
public void setItemCount(int count, int total) {
}
@Override
public void itemDone(Object item) {
}
@Override
public void done() {
}
}
}
package cz.it4i.fiji.haas;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
/**
*
*/
/**
* @author koz01
*
*/
package cz.it4i.fiji.haas;
\ No newline at end of file
......@@ -9,4 +9,5 @@ public interface Settings {
int getTimeout();
long getClusterNodeType();
String getProjectId();
String getJobName();
}
......@@ -48,6 +48,11 @@ interface TestingConstants {
public String getProjectId() {
return projectId;
}
@Override
public String getJobName() {
return "TestOutRedirect";
}
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment