openvidu-server: more wait time when waiting for files if docker env

pull/574/head
pabloFuente 2020-11-30 17:16:22 +01:00
parent 80867eb7e7
commit 2e5797e348
4 changed files with 15 additions and 13 deletions

View File

@ -246,7 +246,7 @@ public class ComposedQuickStartRecordingService extends ComposedRecordingService
private void waitForComposedQuickStartFiles(Recording recording) throws Exception {
final int SECONDS_MAX_WAIT = 30;
final int SECONDS_MAX_WAIT = fileManager.maxSecondsWaitForFile();
final String PATH = this.openviduConfig.getOpenViduRecordingPath() + recording.getId() + "/";
// Waiting for the files generated at the end of the stopping process: the
@ -264,8 +264,7 @@ public class ComposedQuickStartRecordingService extends ComposedRecordingService
@Override
public void run() {
try {
fileManager.waitForFileToExistAndNotEmpty(recording.getRecordingProperties().mediaNode(), file,
SECONDS_MAX_WAIT);
fileManager.waitForFileToExistAndNotEmpty(recording.getRecordingProperties().mediaNode(), file);
} catch (Exception e) {
log.error(e.getMessage());
recording.setStatus(io.openvidu.java.client.Recording.Status.failed);
@ -282,7 +281,7 @@ public class ComposedQuickStartRecordingService extends ComposedRecordingService
if (!latch.await(SECONDS_MAX_WAIT, TimeUnit.SECONDS)) {
recording.setStatus(io.openvidu.java.client.Recording.Status.failed);
String msg = "The wait for files of COMPOSED_QUICK_START recording " + recording.getId()
+ " didn't complete in " + SECONDS_MAX_WAIT + " seconds";
+ " didn't complete in " + fileManager.maxSecondsWaitForFile() + " seconds";
log.error(msg);
throw new Exception(msg);
} else {

View File

@ -433,9 +433,7 @@ public class ComposedRecordingService extends RecordingService {
protected void waitForVideoFileNotEmpty(Recording recording) throws Exception {
final String VIDEO_FILE = this.openviduConfig.getOpenViduRecordingPath() + recording.getId() + "/"
+ recording.getName() + RecordingService.COMPOSED_RECORDING_EXTENSION;
int SECONDS_MAX_WAIT = 20;
this.fileManager.waitForFileToExistAndNotEmpty(recording.getRecordingProperties().mediaNode(), VIDEO_FILE,
SECONDS_MAX_WAIT);
this.fileManager.waitForFileToExistAndNotEmpty(recording.getRecordingProperties().mediaNode(), VIDEO_FILE);
}
protected void failRecordingCompletion(Recording recording, String containerId, boolean removeContainer,

View File

@ -121,7 +121,8 @@ public abstract class CustomFileManager {
}
}
public abstract void waitForFileToExistAndNotEmpty(String mediaNodeId, String absolutePathToFile,
int maxSecondsWait) throws Exception;
public abstract void waitForFileToExistAndNotEmpty(String mediaNodeId, String absolutePathToFile) throws Exception;
public abstract int maxSecondsWaitForFile();
}

View File

@ -5,12 +5,12 @@ import java.io.File;
public class LocalCustomFileManager extends CustomFileManager {
@Override
public void waitForFileToExistAndNotEmpty(String mediaNodeId, String absolutePathToFile, int maxSeconsWait)
throws Exception {
public void waitForFileToExistAndNotEmpty(String mediaNodeId, String absolutePathToFile) throws Exception {
// Check 10 times per seconds
int MAX_SECONDS_WAIT = this.maxSecondsWaitForFile();
int MILLISECONDS_INTERVAL_WAIT = 100;
int LIMIT = maxSeconsWait * 1000 / MILLISECONDS_INTERVAL_WAIT;
int LIMIT = MAX_SECONDS_WAIT * 1000 / MILLISECONDS_INTERVAL_WAIT;
int i = 0;
boolean arePresent = fileExistsAndHasBytes(absolutePathToFile);
@ -25,7 +25,7 @@ public class LocalCustomFileManager extends CustomFileManager {
}
if (!arePresent) {
throw new Exception("File " + absolutePathToFile + " does not exist and hasn't been created in "
+ maxSeconsWait + " seconds");
+ MAX_SECONDS_WAIT + " seconds");
}
}
@ -34,4 +34,8 @@ public class LocalCustomFileManager extends CustomFileManager {
return (f.exists() && f.isFile() && f.length() > 0);
}
public int maxSecondsWaitForFile() {
return 30;
}
}