Run NextGenLocalRecorder.startRecordingProcess() async
This commit is contained in:
parent
1ed2190a3b
commit
fb77e51e53
|
@ -262,27 +262,31 @@ public class NextGenLocalRecorder implements Recorder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startRecordingProcess(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
|
private CompletableFuture<Void> startRecordingProcess(Model model) throws IOException {
|
||||||
recorderLock.lock();
|
return CompletableFuture.runAsync(() -> {
|
||||||
try {
|
recorderLock.lock();
|
||||||
preconditions.check(model);
|
try {
|
||||||
LOG.info("Starting recording for model {}", model.getName());
|
preconditions.check(model);
|
||||||
Download download = createDownload(model);
|
LOG.info("Starting recording for model {}", model.getName());
|
||||||
Recording rec = createRecording(download);
|
Download download = createDownload(model);
|
||||||
setRecordingStatus(rec, State.RECORDING);
|
Recording rec = createRecording(download);
|
||||||
rec.getModel().setLastRecorded(rec.getStartDate());
|
setRecordingStatus(rec, State.RECORDING);
|
||||||
recordingManager.saveRecording(rec);
|
rec.getModel().setLastRecorded(rec.getStartDate());
|
||||||
ScheduledFuture<Recording> future = downloadPool.schedule(rec, 0, TimeUnit.MILLISECONDS);
|
recordingManager.saveRecording(rec);
|
||||||
downloadFutureQueue.add(future);
|
ScheduledFuture<Recording> future = downloadPool.schedule(rec, 0, TimeUnit.MILLISECONDS);
|
||||||
downloadFutureRecordingMap.put(future, rec);
|
downloadFutureQueue.add(future);
|
||||||
} catch (RecordUntilExpiredException e) {
|
downloadFutureRecordingMap.put(future, rec);
|
||||||
LOG.info("Precondition not met to record {}: {}", model, e.getLocalizedMessage());
|
} catch (RecordUntilExpiredException e) {
|
||||||
executeRecordUntilSubsequentAction(model);
|
LOG.info("Precondition not met to record {}: {}", model, e.getLocalizedMessage());
|
||||||
} catch (PreconditionNotMetException e) {
|
executeRecordUntilSubsequentAction(model);
|
||||||
LOG.info("Precondition not met to record {}: {}", model, e.getLocalizedMessage());
|
} catch (PreconditionNotMetException e) {
|
||||||
} finally {
|
LOG.info("Precondition not met to record {}: {}", model, e.getLocalizedMessage());
|
||||||
recorderLock.unlock();
|
} catch (IOException e) {
|
||||||
}
|
LOG.error("Couldn't start recording process for {}", model, e);
|
||||||
|
} finally {
|
||||||
|
recorderLock.unlock();
|
||||||
|
}
|
||||||
|
}, segmentDownloadPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Download createDownload(Model model) throws IOException {
|
private Download createDownload(Model model) throws IOException {
|
||||||
|
@ -294,14 +298,14 @@ public class NextGenLocalRecorder implements Recorder {
|
||||||
return download;
|
return download;
|
||||||
}
|
}
|
||||||
|
|
||||||
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