This is an automated email from the ASF dual-hosted git repository. solomax pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push: new 03f67fa [OPENMEETINGS-2600] some issues are addressed 03f67fa is described below commit 03f67fa349035d9714c4fc00fd607e554018cfec Author: Maxim Solodovnik <solomax...@gmail.com> AuthorDate: Wed Mar 24 20:52:14 2021 +0700 [OPENMEETINGS-2600] some issues are addressed --- .../openmeetings/core/converter/BaseConverter.java | 60 ++++++++++++---------- .../openmeetings/util/process/ProcessHelper.java | 16 ++++-- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/BaseConverter.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/BaseConverter.java index e19df90..44ec49c 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/BaseConverter.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/BaseConverter.java @@ -194,39 +194,43 @@ public abstract class BaseConverter { } } - protected RecordingChunk waitForTheStream(long chunkId) throws InterruptedException { + protected RecordingChunk waitForTheStream(long chunkId) { RecordingChunk chunk = chunkDao.get(chunkId); - if (chunk.getStreamStatus() != Status.STOPPED) { - log.debug("### Chunk Stream not yet written to disk {}", chunkId); - long counter = 0; - long maxTimestamp = 0; - while(true) { - log.trace("### Stream not yet written Thread Sleep - {}", chunkId); - - chunk = chunkDao.get(chunkId); - - if (chunk.getStreamStatus() == Status.STOPPED) { - printChunkInfo(chunk, "Stream now written"); - log.debug("### Thread continue ... " ); - break; - } else { - File chunkFlv = getRecordingChunk(chunk.getRecording().getRoomId(), chunk.getStreamName()); - if (chunkFlv.exists() && maxTimestamp < chunkFlv.lastModified()) { - maxTimestamp = chunkFlv.lastModified(); - } - if (maxTimestamp + TIME_TO_WAIT_FOR_FRAME < System.currentTimeMillis()) { - log.debug("### long time without any update, closing ... "); - chunk.setStreamStatus(Status.STOPPED); - chunkDao.update(chunk); + try { + if (chunk.getStreamStatus() != Status.STOPPED) { + log.debug("### Chunk Stream not yet written to disk {}", chunkId); + long counter = 0; + long maxTimestamp = 0; + while (true) { + log.trace("### Stream not yet written Thread Sleep - {}", chunkId); + + chunk = chunkDao.get(chunkId); + + if (chunk.getStreamStatus() == Status.STOPPED) { + printChunkInfo(chunk, "Stream now written"); + log.debug("### Thread continue ... " ); break; + } else { + File chunkFlv = getRecordingChunk(chunk.getRecording().getRoomId(), chunk.getStreamName()); + if (chunkFlv.exists() && maxTimestamp < chunkFlv.lastModified()) { + maxTimestamp = chunkFlv.lastModified(); + } + if (maxTimestamp + TIME_TO_WAIT_FOR_FRAME < System.currentTimeMillis()) { + log.debug("### long time without any update, closing ... "); + chunk.setStreamStatus(Status.STOPPED); + chunkDao.update(chunk); + break; + } + } + if (++counter % 1000 == 0) { + printChunkInfo(chunk, "Still waiting"); } - } - if (++counter % 1000 == 0) { - printChunkInfo(chunk, "Still waiting"); - } - Thread.sleep(100L); + Thread.sleep(100L); + } } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); } return chunk; } diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/process/ProcessHelper.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/process/ProcessHelper.java index 4c0f596..f9d8f50 100644 --- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/process/ProcessHelper.java +++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/process/ProcessHelper.java @@ -130,11 +130,11 @@ public class ProcessHelper { res.setExitCode(proc.exitValue()) .setOut(inputWatcher.toString()) .setError(errorWatcher.toString()); + } catch (InterruptedException e) { + onException(e, start, res); + Thread.currentThread().interrupt(); } catch (Throwable t) { - log.error("executeScript", t); - res.setExitCode(-1) - .setError(String.format("Exception after %s of work; %s", formatMillis(System.currentTimeMillis() - start), t.getMessage())) - .setException(t.toString()); + onException(t, start, res); } finally { if (proc != null) { errorWatcher.finish(); @@ -146,4 +146,12 @@ public class ProcessHelper { debugCommandEnd(process); return res; } + + private static void onException(Throwable t, long start, ProcessResult res) { + log.error("executeScript", t); + res.setExitCode(-1) + .setError("Exception after " + formatMillis(System.currentTimeMillis() - start) + + " of work; " + t.getMessage()) + .setException(t.toString()); + } }