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

iss1007: support for cancle

parent 8dc4fd41
No related branches found
No related tags found
No related merge requests found
...@@ -247,6 +247,10 @@ public class Job { ...@@ -247,6 +247,10 @@ public class Job {
return haasClientSupplier.get().getChangedFiles(getId()); return haasClientSupplier.get().getChangedFiles(getId());
} }
public void cancelJob() {
haasClientSupplier.get().cancelJob(jobId);
}
......
...@@ -314,6 +314,14 @@ public class HaaSClient { ...@@ -314,6 +314,14 @@ public class HaaSClient {
} }
public void cancelJob(Long jobId) {
try {
getJobManagement().cancelJob(jobId, getSessionID());
} catch (RemoteException | ServiceException e) {
throw new HaaSClientException(e);
}
}
private void doSubmitJob(long jobId) throws RemoteException, ServiceException { private void doSubmitJob(long jobId) throws RemoteException, ServiceException {
getJobManagement().submitJob(jobId, getSessionID()); getJobManagement().submitJob(jobId, getSessionID());
} }
......
...@@ -100,7 +100,7 @@ public class BenchmarkJobManager { ...@@ -100,7 +100,7 @@ public class BenchmarkJobManager {
if (job.getState() == JobState.Finished) { if (job.getState() == JobState.Finished) {
String filePattern = job.getProperty(SPIM_OUTPUT_FILENAME_PATTERN); String filePattern = job.getProperty(SPIM_OUTPUT_FILENAME_PATTERN);
job.download(downloadFinishedData(filePattern), progress); job.download(downloadFinishedData(filePattern), progress);
} else if (job.getState() == JobState.Failed) { } else if (job.getState() == JobState.Failed || job.getState() == JobState.Canceled) {
job.download(downloadFailedData(), progress); job.download(downloadFailedData(), progress);
} }
...@@ -214,6 +214,10 @@ public class BenchmarkJobManager { ...@@ -214,6 +214,10 @@ public class BenchmarkJobManager {
public boolean remove() { public boolean remove() {
return job.remove(); return job.remove();
} }
public void cancelJob() {
job.cancelJob();
}
} }
...@@ -289,9 +293,8 @@ public class BenchmarkJobManager { ...@@ -289,9 +293,8 @@ public class BenchmarkJobManager {
Path path = getPathSafely(name); Path path = getPathSafely(name);
if (path == null) if (path == null)
return false; return false;
return path.getFileName().toString().startsWith("snakejob.") return path.getFileName().toString().startsWith("snakejob.")
|| path.getParent().getFileName().toString().equals("logs"); || path.getParent() != null && path.getParent().getFileName() != null && path.getParent().getFileName().toString().equals("logs");
}; };
} }
......
...@@ -102,6 +102,11 @@ public class BenchmarkSPIMController implements FXFrame.Controller { ...@@ -102,6 +102,11 @@ public class BenchmarkSPIMController implements FXFrame.Controller {
registry.get(job.getValue()).update(); registry.get(job.getValue()).update();
}), job -> notNullValue(job, j -> j.getState() == JobState.Configuring || j.getState() == JobState.Finished)); }), job -> notNullValue(job, j -> j.getState() == JobState.Configuring || j.getState() == JobState.Finished));
menu.addItem("Cancel job", job -> executeWSCallAsync("Canceling job", p -> {
job.getValue().cancelJob();
registry.get(job.getValue()).update();
}), job -> notNullValue(job, j -> j.getState() == JobState.Running));
menu.addItem("Show progress", job -> { menu.addItem("Show progress", job -> {
try { try {
new SPIMPipelineProgressViewWindow(root, job.getValue()).setVisible(true); new SPIMPipelineProgressViewWindow(root, job.getValue()).setVisible(true);
...@@ -115,7 +120,8 @@ public class BenchmarkSPIMController implements FXFrame.Controller { ...@@ -115,7 +120,8 @@ public class BenchmarkSPIMController implements FXFrame.Controller {
menu.addItem("Download result", menu.addItem("Download result",
job -> executeWSCallAsync("Downloading data", p -> job.getValue().downloadData(p)), job -> executeWSCallAsync("Downloading data", p -> job.getValue().downloadData(p)),
job -> notNullValue(job, job -> notNullValue(job,
j -> EnumSet.of(JobState.Failed, JobState.Finished).contains(j.getState()) && !j.downloaded())); j -> EnumSet.of(JobState.Failed, JobState.Finished, JobState.Canceled).contains(j.getState())
&& !j.downloaded()));
menu.addItem("Download statistics", menu.addItem("Download statistics",
job -> executeWSCallAsync("Downloading data", p -> job.getValue().downloadStatistics(p)), job -> executeWSCallAsync("Downloading data", p -> job.getValue().downloadStatistics(p)),
job -> notNullValue(job, j -> j.getState() == JobState.Finished)); job -> notNullValue(job, j -> j.getState() == JobState.Finished));
...@@ -148,8 +154,11 @@ public class BenchmarkSPIMController implements FXFrame.Controller { ...@@ -148,8 +154,11 @@ public class BenchmarkSPIMController implements FXFrame.Controller {
FXFrame.Controller.executeAsync(executorServiceWS, (Callable<Void>) () -> { FXFrame.Controller.executeAsync(executorServiceWS, (Callable<Void>) () -> {
ProgressDialog dialog = ModalDialogs.doModal(new ProgressDialog(root, title), ProgressDialog dialog = ModalDialogs.doModal(new ProgressDialog(root, title),
WindowConstants.DO_NOTHING_ON_CLOSE); WindowConstants.DO_NOTHING_ON_CLOSE);
action.doAction(dialog); try {
dialog.done(); action.doAction(dialog);
} finally {
dialog.done();
}
return null; return null;
}, x -> { }, x -> {
if (update) if (update)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment