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

remove phone,

fix not updating state of jobs
parent 3e3b4ab4
No related branches found
No related tags found
1 merge request!14Iss1026
...@@ -17,6 +17,7 @@ import org.scijava.widget.TextWidget; ...@@ -17,6 +17,7 @@ import org.scijava.widget.TextWidget;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import cz.it4i.fiji.haas_spim_benchmark.core.Constants;
import cz.it4i.fiji.haas_spim_benchmark.ui.BenchmarkSPIMWindow; import cz.it4i.fiji.haas_spim_benchmark.ui.BenchmarkSPIMWindow;
import net.imagej.ImageJ; import net.imagej.ImageJ;
...@@ -43,8 +44,6 @@ public class ManageSPIMBenchmark implements Command { ...@@ -43,8 +44,6 @@ public class ManageSPIMBenchmark implements Command {
@Parameter(style = TextWidget.PASSWORD_STYLE) @Parameter(style = TextWidget.PASSWORD_STYLE)
private String password; private String password;
@Parameter(style = TextWidget.FIELD_STYLE)
private String phone;
@Parameter(style = TextWidget.FIELD_STYLE) @Parameter(style = TextWidget.FIELD_STYLE)
private String email; private String email;
...@@ -56,7 +55,7 @@ public class ManageSPIMBenchmark implements Command { ...@@ -56,7 +55,7 @@ public class ManageSPIMBenchmark implements Command {
public void run() { public void run() {
try { try {
JDialog dialog = JDialog dialog =
new BenchmarkSPIMWindow(null, new BenchmarkSPIMParametersImpl(userName, password, phone, new BenchmarkSPIMWindow(null, new BenchmarkSPIMParametersImpl(userName, password, Constants.PHONE,
email, Paths.get(workingDirectory.getPath()))); email, Paths.get(workingDirectory.getPath())));
dialog.setTitle("SPIM workflow computation manager"); dialog.setTitle("SPIM workflow computation manager");
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
......
...@@ -65,7 +65,7 @@ public class BenchmarkJobManager { ...@@ -65,7 +65,7 @@ public class BenchmarkJobManager {
private JobState verifiedState; private JobState verifiedState;
private boolean verifiedStateProcessed; private boolean verifiedStateProcessed;
private CompletableFuture<JobState> running; private CompletableFuture<JobState> running;
public BenchmarkJob(Job job) { public BenchmarkJob(Job job) {
this.job = job; this.job = job;
tasks = new LinkedList<Task>(); tasks = new LinkedList<Task>();
...@@ -85,18 +85,21 @@ public class BenchmarkJobManager { ...@@ -85,18 +85,21 @@ public class BenchmarkJobManager {
} }
public JobState getState() { public JobState getState() {
return getStateAsync(r->r.run()).getNow(JobState.Unknown); return getStateAsync(r -> r.run()).getNow(JobState.Unknown);
} }
public synchronized CompletableFuture<JobState> getStateAsync(Executor executor) { public synchronized CompletableFuture<JobState> getStateAsync(Executor executor) {
if(running != null) { if (running != null) {
return running; return running;
} }
return running = doGetStateAsync(executor); CompletableFuture<JobState> result = doGetStateAsync(executor);
if (!result.isCancelled() && !result.isCompletedExceptionally() && !result.isDone()) {
running = result;
}
return result;
} }
private synchronized CompletableFuture<JobState> doGetStateAsync(Executor executor) { private synchronized CompletableFuture<JobState> doGetStateAsync(Executor executor) {
job.updateInfo();
JobState state = job.getState(); JobState state = job.getState();
if (state != JobState.Finished) { if (state != JobState.Finished) {
return CompletableFuture.completedFuture(state); return CompletableFuture.completedFuture(state);
...@@ -104,7 +107,7 @@ public class BenchmarkJobManager { ...@@ -104,7 +107,7 @@ public class BenchmarkJobManager {
return CompletableFuture.completedFuture(verifiedState); return CompletableFuture.completedFuture(verifiedState);
} }
verifiedStateProcessed = true; verifiedStateProcessed = true;
return CompletableFuture.supplyAsync(()->{ return CompletableFuture.supplyAsync(() -> {
try { try {
verifiedState = Stream verifiedState = Stream
.concat(Arrays.asList(state).stream(), getTasks().stream() .concat(Arrays.asList(state).stream(), getTasks().stream()
...@@ -114,18 +117,18 @@ public class BenchmarkJobManager { ...@@ -114,18 +117,18 @@ public class BenchmarkJobManager {
if (verifiedState != JobState.Finished && verifiedState != JobState.Canceled) { if (verifiedState != JobState.Finished && verifiedState != JobState.Canceled) {
verifiedState = JobState.Failed; verifiedState = JobState.Failed;
} }
synchronized(BenchmarkJob.this) { synchronized (BenchmarkJob.this) {
//test whether job was restarted - it sets running to null // test whether job was restarted - it sets running to null
if(!verifiedStateProcessed) { if (!verifiedStateProcessed) {
verifiedState = null; verifiedState = null;
return doGetStateAsync(r->r.run()).getNow(null); return doGetStateAsync(r -> r.run()).getNow(null);
} }
running = null; running = null;
return verifiedState; return verifiedState;
} }
} finally { } finally {
synchronized(BenchmarkJob.this) { synchronized (BenchmarkJob.this) {
if(running != null) { if (running != null) {
running = null; running = null;
} }
} }
...@@ -234,7 +237,7 @@ public class BenchmarkJobManager { ...@@ -234,7 +237,7 @@ public class BenchmarkJobManager {
public List<String> getActualOutput(List<SynchronizableFileType> content) { public List<String> getActualOutput(List<SynchronizableFileType> content) {
return computationAccessor.getActualOutput(content); return computationAccessor.getActualOutput(content);
} }
@Override @Override
public String toString() { public String toString() {
return "" + getId(); return "" + getId();
......
...@@ -4,6 +4,7 @@ import java.util.LinkedHashMap; ...@@ -4,6 +4,7 @@ import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
public interface Constants { public interface Constants {
String PHONE = "123456789";
int HAAS_UPDATE_TIMEOUT = 30000; int HAAS_UPDATE_TIMEOUT = 30000;
short UI_TO_HAAS_FREQUENCY_UPDATE_RATIO = 10; short UI_TO_HAAS_FREQUENCY_UPDATE_RATIO = 10;
String HAAS_JOB_NAME = "HaaSSPIMBenchmark"; String HAAS_JOB_NAME = "HaaSSPIMBenchmark";
...@@ -50,4 +51,5 @@ public interface Constants { ...@@ -50,4 +51,5 @@ public interface Constants {
String STATISTICS_SUMMARY_FILENAME = "summary.csv"; String STATISTICS_SUMMARY_FILENAME = "summary.csv";
String SUMMARY_FILE_HEADER = "Task;AvgMemoryUsage;AvgWallTime;MaxWallTime;TotalTime;JobCount"; String SUMMARY_FILE_HEADER = "Task;AvgMemoryUsage;AvgWallTime;MaxWallTime;TotalTime;JobCount";
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment