Run NextGenLocalRecorder.startRecordingProcess(Model) async
This commit is contained in:
parent
52cdc82044
commit
ebaf4c4c9f
|
@ -22,6 +22,7 @@ import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorCompletionService;
|
import java.util.concurrent.ExecutorCompletionService;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
@ -214,7 +215,8 @@ public class NextGenLocalRecorder implements Recorder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startRecordingProcess(Model model) throws IOException {
|
private CompletableFuture<Void> startRecordingProcess(Model model) throws IOException {
|
||||||
|
return CompletableFuture.runAsync(() -> {
|
||||||
recorderLock.lock();
|
recorderLock.lock();
|
||||||
try {
|
try {
|
||||||
preconditions.check(model);
|
preconditions.check(model);
|
||||||
|
@ -227,10 +229,12 @@ public class NextGenLocalRecorder implements Recorder {
|
||||||
executeRecordUntilSubsequentAction(model);
|
executeRecordUntilSubsequentAction(model);
|
||||||
} catch (PreconditionNotMetException e) {
|
} catch (PreconditionNotMetException e) {
|
||||||
LOG.info("Precondition not met to record {}: {}", model, e.getLocalizedMessage());
|
LOG.info("Precondition not met to record {}: {}", model, e.getLocalizedMessage());
|
||||||
return;
|
} catch (IOException e) {
|
||||||
|
LOG.error("Couldn't start recording process for {}", model, e);
|
||||||
} finally {
|
} finally {
|
||||||
recorderLock.unlock();
|
recorderLock.unlock();
|
||||||
}
|
}
|
||||||
|
}, downloadPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Download createDownload(Model model) {
|
private Download createDownload(Model model) {
|
||||||
|
@ -262,14 +266,14 @@ public class NextGenLocalRecorder implements Recorder {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeRecordUntilSubsequentAction(Model model) throws IOException {
|
private void executeRecordUntilSubsequentAction(Model model) {
|
||||||
if (model.getRecordUntilSubsequentAction() == PAUSE) {
|
if (model.getRecordUntilSubsequentAction() == PAUSE) {
|
||||||
model.setSuspended(true);
|
model.setSuspended(true);
|
||||||
} else if (model.getRecordUntilSubsequentAction() == REMOVE) {
|
} else if (model.getRecordUntilSubsequentAction() == REMOVE) {
|
||||||
try {
|
try {
|
||||||
LOG.info("Removing {} because the recording timeframe ended at {}", model, model.getRecordUntil().atZone(ZoneId.systemDefault()));
|
LOG.info("Removing {} because the recording timeframe ended at {}", model, model.getRecordUntil().atZone(ZoneId.systemDefault()));
|
||||||
stopRecording(model);
|
stopRecording(model);
|
||||||
} catch (InvalidKeyException | NoSuchAlgorithmException e1) {
|
} catch (Exception e1) {
|
||||||
LOG.error("Error while stopping recording", e1);
|
LOG.error("Error while stopping recording", e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue