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

iss1026: fix scp auth error

parent 56d2820d
No related branches found
No related tags found
1 merge request!14Iss1026
......@@ -78,11 +78,13 @@ public class SPIMPipelineProgressViewController extends BorderPane implements Cl
private Timer timer;
private ObservableTaskRegistry registry;
private ExecutorService executorServiceWS;
private ExecutorService executorServiceScp;
private Executor executorFx = new FXFrameExecutorService();
private Window root;
public SPIMPipelineProgressViewController() {
executorServiceWS = Executors.newSingleThreadExecutor();
executorServiceScp = Executors.newSingleThreadExecutor();
init();
}
......@@ -106,6 +108,7 @@ public class SPIMPipelineProgressViewController extends BorderPane implements Cl
public void close() {
timer.cancel();
executorServiceWS.shutdown();
executorServiceScp.shutdown();
}
@Override
......@@ -129,7 +132,7 @@ public class SPIMPipelineProgressViewController extends BorderPane implements Cl
}
private void proof(ObservableValue<Task> task, int columnIndex) {
ModalDialogs.doModal(new TaskComputationWindow(root, task.getValue().getComputations().get(columnIndex - 1)),
ModalDialogs.doModal(new TaskComputationWindow(root, task.getValue().getComputations().get(columnIndex - 1), executorServiceScp),
WindowConstants.DISPOSE_ON_CLOSE);
}
......
......@@ -6,6 +6,9 @@ import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
import org.slf4j.Logger;
......@@ -29,20 +32,39 @@ public class TaskComputationAdapter implements Closeable {
private final List<ObservableLog> logs = new LinkedList<>();
private final Timer timer;
private Timer timer;
public TaskComputationAdapter(TaskComputation computation) {
private ExecutorService scpExecutor;
public TaskComputationAdapter(TaskComputation computation, ExecutorService scpExecutor) {
this.computation = computation;
this.scpExecutor = scpExecutor;
timer = new Timer();
Map<String, Long> sizes = computation.getOutFileSizes();
computation.getOutputs().forEach(outputFile -> addOutputFile(outputFile, sizes.get(outputFile)));
computation.getLogs().forEach(log->logs.add(new ObservableLog(log)));
timer.scheduleAtFixedRate(new P_TimerTask(), Constants.HAAS_TIMEOUT, Constants.HAAS_TIMEOUT);
}
public void init() {
Future<?> future = scpExecutor.submit(() -> {
Map<String, Long> sizes = computation.getOutFileSizes();
computation.getOutputs().forEach(outputFile -> addOutputFile(outputFile, sizes.get(outputFile)));
computation.getLogs().forEach(log -> logs.add(new ObservableLog(log)));
});
try {
future.get();
} catch (InterruptedException | ExecutionException e) {
log.error(e.getMessage(), e);
}
synchronized (this) {
if(timer != null) {
timer.schedule(new P_TimerTask(), Constants.HAAS_TIMEOUT, Constants.HAAS_TIMEOUT);
}
}
}
@Override
public void close() {
public synchronized void close() {
timer.cancel();
timer = null;
}
public List<ObservableValue<RemoteFileInfo>> getOutputs() {
......@@ -150,11 +172,18 @@ public class TaskComputationAdapter implements Closeable {
@Override
public void run() {
Map<String, Long> sizes = computation.getOutFileSizes();
Map<String, Log> logs = computation.getLogs().stream()
.collect(Collectors.<Log, String, Log>toMap((Log log) -> log.getName(), (Log log) -> log));
TaskComputationAdapter.this.logs.forEach(log->((ObservableLog) log).setContentValue(logs.get(log.getName())));
outputs.forEach(value -> ((ObservableOutputFile) value).setSize(sizes.get(value.getValue().getName())));
try {
scpExecutor.submit(() -> {
Map<String, Long> sizes = computation.getOutFileSizes();
Map<String, Log> logs = computation.getLogs().stream()
.collect(Collectors.<Log, String, Log>toMap((Log log) -> log.getName(), (Log log) -> log));
TaskComputationAdapter.this.logs
.forEach(log -> ((ObservableLog) log).setContentValue(logs.get(log.getName())));
outputs.forEach(value -> ((ObservableOutputFile) value).setSize(sizes.get(value.getValue().getName())));
}).get();
} catch (InterruptedException | ExecutionException e) {
log.error(e.getMessage(), e);
}
}
}
......
......@@ -26,11 +26,8 @@ import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
//TASK: context menu udělat pro TaskComputation (buňku) nikoliv řádek - dodělat
//TASK: vyřešit problém při konkurentním scp
public class TaskComputationControl extends TabPane implements CloseableControl, InitiableControl {
@SuppressWarnings("unused")
private static Logger log = LoggerFactory.getLogger(cz.it4i.fiji.haas_spim_benchmark.ui.TaskComputationControl.class);
public final static Logger log = LoggerFactory.getLogger(cz.it4i.fiji.haas_spim_benchmark.ui.TaskComputationControl.class);
private TaskComputationAdapter adapter;
......@@ -42,9 +39,12 @@ public class TaskComputationControl extends TabPane implements CloseableControl,
private TaskComputation computation;
public TaskComputationControl(TaskComputation computation) {
private ExecutorService scpExecutor;
public TaskComputationControl(TaskComputation computation, ExecutorService scpExecutor) {
JavaFXRoutines.initRootAndController("TaskComputationView.fxml", this);
this.computation = computation;
this.scpExecutor = scpExecutor;
}
@Override
......@@ -53,7 +53,8 @@ public class TaskComputationControl extends TabPane implements CloseableControl,
ProgressDialog dialog = ModalDialogs.doModal(new ProgressDialog(parameter, "Updating infos..."),
WindowConstants.DO_NOTHING_ON_CLOSE);
try {
adapter = new TaskComputationAdapter(computation);
adapter = new TaskComputationAdapter(computation, scpExecutor);
adapter.init();
} finally {
dialog.done();
}
......@@ -80,9 +81,7 @@ public class TaskComputationControl extends TabPane implements CloseableControl,
}
@Override
public void close() {
if(adapter != null) {
adapter.close();
}
adapter.close();
wsExecutorService.shutdown();
}
......
package cz.it4i.fiji.haas_spim_benchmark.ui;
import java.awt.Window;
import java.util.concurrent.ExecutorService;
import cz.it4i.fiji.haas.ui.FXFrame;
import cz.it4i.fiji.haas_spim_benchmark.core.TaskComputation;
......@@ -9,8 +10,8 @@ public class TaskComputationWindow extends FXFrame<TaskComputationControl> {
private static final long serialVersionUID = 1L;
public TaskComputationWindow(Window applicationFrame,TaskComputation computation) {
super(applicationFrame,()->new TaskComputationControl(computation));
public TaskComputationWindow(Window applicationFrame,TaskComputation computation, ExecutorService scpExecutor) {
super(applicationFrame,()->new TaskComputationControl(computation, scpExecutor));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment