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

Merge branch 'iss1007-provideTaskInfos'

parents ef30a741 1aa785eb
No related branches found
No related tags found
No related merge requests found
Showing
with 74 additions and 48 deletions
......@@ -10,7 +10,6 @@ public class HaaSOutputHolderImpl implements HaaSOutputHolder {
private HaaSOutputSource source;
private SynchronizableFileType type;
public HaaSOutputHolderImpl(HaaSOutputSource source, SynchronizableFileType typeForHold) {
super();
this.source = source;
this.type = typeForHold;
}
......
......@@ -214,7 +214,6 @@ public class Job {
private Progress progress;
public P_ProgressNotifierAdapter(Progress progress) {
super();
this.progress = progress;
}
......
......@@ -102,7 +102,6 @@ public class JobManager {
private long offset;
public JobSynchronizableFile(SynchronizableFileType type, long offset) {
super();
this.type = type;
this.offset = offset;
}
......
......@@ -13,7 +13,6 @@ public class PropertyHolder {
private Properties properties;
public PropertyHolder(Path storage) {
super();
this.storage = storage;
}
......
......@@ -17,7 +17,6 @@ public class ObservableValueAdapter<S, T> implements ObservableValue<T> {
private Map<ChangeListener<? super T>, ChangeListener<? super S>> mapOfListeners = new HashMap<>();
public ObservableValueAdapter(ObservableValue<S> decorated, Function<S, T> map) {
super();
this.adapted = decorated;
this.transformation = map;
}
......
......@@ -18,7 +18,6 @@ public class ObservableValueRegistry<T> {
public ObservableValueRegistry(Function<T, UpdateStatus> updateFunction,Function<T,Object> stateProvider,
Consumer<T> removeConsumer) {
super();
this.updateFunction = updateFunction;
this.stateProvider = stateProvider;
this.removeConsumer = t-> {
......
......@@ -55,7 +55,6 @@ public class TableViewContextMenu<T> {
private Predicate<T> enableHandler;
public P_MenuItem(String text, Consumer<T> eventHandler, Predicate<T> enableHandler) {
super();
this.enableHandler = enableHandler;
item = new MenuItem(text);
item.setOnAction(e -> eventHandler.accept(getSelectedItem()));
......
......@@ -17,7 +17,6 @@ public class UpdatableObservableValue<T> extends ObservableValueBase<T> {
public UpdatableObservableValue(T wrapped, Function<T, UpdateStatus> updateFunction,
Function<T, Object> stateProvider) {
super();
this.wrapped = wrapped;
this.updateFunction = updateFunction;
this.stateProvider = stateProvider;
......
......@@ -207,7 +207,6 @@ public class HaaSClient {
}
public HaaSClient(Settings settings) {
super();
this.settings = settings;
this.templateId = settings.getTemplateId();
this.timeOut = settings.getTimeout();
......@@ -434,7 +433,6 @@ public class HaaSClient {
private ProgressNotifier notifier;
public P_ProgressNotifierDecorator(ProgressNotifier notifier) {
super();
this.notifier = notifier;
}
......
......@@ -32,7 +32,6 @@ class HaaSFileTransferImp implements HaaSFileTransfer {
public HaaSFileTransferImp(FileTransferMethodExt ft, String sessionId, long jobId, FileTransferWsSoap fileTransfer,
ScpClient scpClient, ProgressNotifier notifier) {
super();
this.ft = ft;
this.scpClient = scpClient;
this.fileTransfer = fileTransfer;
......
......@@ -15,7 +15,6 @@ class TransferFileProgressForHaaSClient implements TransferFileProgress {
public TransferFileProgressForHaaSClient(long totalSize, ProgressNotifier notifier) {
super();
this.totalSize = totalSize;
this.notifier = notifier;
}
......
package cz.it4i.fiji.haas_spim_benchmark.core;
import static cz.it4i.fiji.haas_spim_benchmark.core.Constants.BENCHMARK_RESULT_FILE;
import static cz.it4i.fiji.haas_spim_benchmark.core.Constants.HAAS_UPDATE_TIMEOUT;
import static cz.it4i.fiji.haas_spim_benchmark.core.Constants.SPIM_OUTPUT_FILENAME_PATTERN;
import static cz.it4i.fiji.haas_spim_benchmark.core.Constants.STATISTICS_TASK_NAME_MAP;
import static cz.it4i.fiji.haas_spim_benchmark.core.Constants.UI_TO_HAAS_FREQUENCY_UPDATE_RATIO;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileWriter;
......@@ -59,7 +65,6 @@ public class BenchmarkJobManager {
public BenchmarkJob(Job job) {
super();
this.job = job;
computationAccessor = new SPIMComputationAccessor() {
......@@ -76,14 +81,14 @@ public class BenchmarkJobManager {
};
};
computationAccessor = new SPIMComputationAccessorDecoratorWithTimeout(computationAccessor, Constants.HAAS_UPDATE_TIMEOUT);
computationAccessor = new SPIMComputationAccessorDecoratorWithTimeout(computationAccessor, HAAS_UPDATE_TIMEOUT/UI_TO_HAAS_FREQUENCY_UPDATE_RATIO);
}
public void startJob(Progress progress) throws IOException {
job.uploadFilesByName(Arrays.asList(Constants.CONFIG_YAML), progress);
String outputName = getOutputName(job.openLocalFile(Constants.CONFIG_YAML));
job.submit();
job.setProperty(Constants.SPIM_OUTPUT_FILENAME_PATTERN, outputName);
job.setProperty(SPIM_OUTPUT_FILENAME_PATTERN, outputName);
setDownloaded(false);
}
......@@ -93,7 +98,7 @@ public class BenchmarkJobManager {
public void downloadData(Progress progress) throws IOException {
if (job.getState() == JobState.Finished) {
String filePattern = job.getProperty(Constants.SPIM_OUTPUT_FILENAME_PATTERN);
String filePattern = job.getProperty(SPIM_OUTPUT_FILENAME_PATTERN);
job.download(downloadFinishedData(filePattern), progress);
} else if (job.getState() == JobState.Failed) {
job.download(downloadFailedData(), progress);
......@@ -104,7 +109,7 @@ public class BenchmarkJobManager {
public void downloadStatistics(Progress progress) throws IOException {
job.download(BenchmarkJobManager.downloadStatistics(), progress);
Path resultFile = job.getDirectory().resolve(Constants.BENCHMARK_RESULT_FILE);
Path resultFile = job.getDirectory().resolve(BENCHMARK_RESULT_FILE);
if (resultFile != null)
BenchmarkJobManager.formatResultFile(resultFile);
}
......@@ -193,7 +198,7 @@ public class BenchmarkJobManager {
scanner.close();
// Order tasks chronologically
List<String> chronologicList = Constants.STATISTICS_TASK_NAME_MAP.keySet().stream().collect(Collectors.toList());
List<String> chronologicList = STATISTICS_TASK_NAME_MAP.keySet().stream().collect(Collectors.toList());
Collections.sort(tasks, Comparator.comparingInt(task -> chronologicList.indexOf(task.getDescription())));
}
......
......@@ -4,7 +4,8 @@ import java.util.LinkedHashMap;
import java.util.Map;
public interface Constants {
long HAAS_UPDATE_TIMEOUT = 30000;
int HAAS_UPDATE_TIMEOUT = 30000;
short UI_TO_HAAS_FREQUENCY_UPDATE_RATIO = 10;
String HAAS_JOB_NAME = "HaaSSPIMBenchmark";
int HAAS_CLUSTER_NODE_TYPE = 6;
int HAAS_TEMPLATE_ID = 4;
......@@ -39,4 +40,5 @@ public interface Constants {
put("done", "Done");
}};
String STATISTICS_SUMMARY_FILENAME = "summary.csv";
}
......@@ -9,7 +9,6 @@ abstract public class PipelineBase<T extends PipelineBase<?,?>,S> {
public PipelineBase( S id) {
super();
this.id = id;
}
......
......@@ -13,7 +13,6 @@ public class SPIMComputationAccessorDecoratorWithTimeout implements SPIMComputat
private P_ResultCacheHolder<Set<String>> changedFilesCache;
public SPIMComputationAccessorDecoratorWithTimeout(SPIMComputationAccessor decorated, long intervalForQueryInMs) {
super();
this.intervalForQueryInMs = intervalForQueryInMs;
outputCache = new P_ResultCacheHolder<>(x -> decorated.getActualOutput());
changedFilesCache = new P_ResultCacheHolder<>(set -> {
......@@ -44,7 +43,6 @@ public class SPIMComputationAccessorDecoratorWithTimeout implements SPIMComputat
private Function<T, T> producer;
public P_ResultCacheHolder(Function<T, T> producer) {
super();
this.producer = producer;
}
......
......@@ -3,7 +3,10 @@ package cz.it4i.fiji.haas_spim_benchmark.ui;
import java.awt.Window;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.function.Function;
......@@ -20,9 +23,40 @@ import javafx.fxml.FXML;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.paint.Color;
public class SPIMPipelineProgressViewController implements FXFrame.Controller {
protected static final String RUNNING_STATE_COMPUTATION = Color.YELLOW.toString();
protected static final String FINISHED_STATE_COMPUTATION = null;
protected static final String UNKNOWN_STATE_COMPUTATION = Color.GRAY.toString();
private static final Map<JobState, Color> taskExecutionState2Color = new HashMap<>();
static {
taskExecutionState2Color.put(JobState.Running, Color.YELLOW);
taskExecutionState2Color.put(JobState.Finished, Color.GREEN);
taskExecutionState2Color.put(JobState.Failed, Color.RED);
taskExecutionState2Color.put(JobState.Unknown, Color.GRAY);
}
private static String getColorTaskExecState(JobState jobState) {
Color result = null;
if(jobState == null) {
result = Color.GRAY;
} else {
result = taskExecutionState2Color.get(jobState);
}
return toCss(result != null? result : Color.ORANGE);
}
private static String toCss(Color color) {
return "rgb(" + Math.round(color.getRed() * 255.0) + ","
+ Math.round(color.getGreen() * 255.0) + ","
+ Math.round(color.getBlue() * 255.0) + ")";
}
@FXML
private TableView<ObservableValue<Task>> tasks;
......@@ -49,7 +83,6 @@ public class SPIMPipelineProgressViewController implements FXFrame.Controller {
this.job = job;
}
@SuppressWarnings("unchecked")
private void fillTable() {
List<Task> tasks = job.getTasks();
if (tasks == null) {
......@@ -58,7 +91,7 @@ public class SPIMPipelineProgressViewController implements FXFrame.Controller {
public void run() {
fillTable();
}
}, Constants.HAAS_UPDATE_TIMEOUT / 10);
}, Constants.HAAS_UPDATE_TIMEOUT / Constants.UI_TO_HAAS_FREQUENCY_UPDATE_RATIO);
} else {
List<TaskComputation> computations = tasks.stream().map(task -> task.getComputations())
.collect(Collectors.<List<TaskComputation>>maxBy((a, b) -> a.size() - b.size())).get();
......@@ -69,29 +102,7 @@ public class SPIMPipelineProgressViewController implements FXFrame.Controller {
this.tasks.getColumns().add(new TableColumn<>(tc.getTimepoint() + ""));
int index = i++;
FXFrame.Controller.setCellValueFactory(this.tasks, index, (Function<Task, JobState>) v -> {
if (v.getComputations().size() >= index) {
return v.getComputations().get(index - 1).getState();
} else {
return null;
}
});
((TableColumn<ObservableValue<Task>, JobState>)this.tasks.getColumns().get(index)).setCellFactory(column->new TableCell<ObservableValue<Task>,JobState>(){
@Override
protected void updateItem(JobState state, boolean empty) {
if (state == null || empty) {
setText(null);
setStyle("");
} else {
// Format date.
setText(state + "");
if(state == JobState.Unknown) {
setStyle("-fx-background-color: yellow");
}
}
}
});
constructCellFactory(index);
}
......@@ -107,6 +118,30 @@ public class SPIMPipelineProgressViewController implements FXFrame.Controller {
}
}
@SuppressWarnings("unchecked")
private void constructCellFactory(int index) {
FXFrame.Controller.setCellValueFactory(this.tasks, index, (Function<Task, Optional<JobState>>) v -> {
if (v.getComputations().size() >= index) {
return Optional.of(v.getComputations().get(index - 1).getState());
} else {
return null;
}
});
((TableColumn<ObservableValue<Task>, Optional<JobState>>)this.tasks.getColumns().get(index)).setCellFactory(column->new TableCell<ObservableValue<Task>,Optional<JobState>>(){
@Override
protected void updateItem(Optional<JobState> state, boolean empty) {
if (state == null || empty) {
setText(null);
setStyle("");
} else {
// Format date.
setText( "" + (state.isPresent()?state.get():"N/A"));
setStyle("-fx-background-color: " + getColorTaskExecState(state.get()));
}
}
});
}
private void updateTable() {
registry.update();
}
......
......@@ -40,7 +40,6 @@ public class ScpClient implements Closeable {
}
public ScpClient(String hostName, String username, Identity privateKeyFile) throws JSchException {
super();
init(hostName, username, privateKeyFile);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment