openvidu-server: parallel stop of RecorderEndpoints

pull/651/head
pabloFuente 2021-09-02 17:09:25 +02:00
parent 8ce647c35b
commit 132653cde7
1 changed files with 10 additions and 3 deletions

View File

@ -30,6 +30,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
@ -159,10 +160,16 @@ public class SingleStreamRecordingService extends RecordingService {
}); });
final CountDownLatch stoppedCountDown = new CountDownLatch(wrappers.size()); final CountDownLatch stoppedCountDown = new CountDownLatch(wrappers.size());
for (RecorderEndpointWrapper wrapper : wrappers) { ForkJoinPool customThreadPool = new ForkJoinPool(4);
this.stopRecorderEndpointOfPublisherEndpoint(recording.getId(), wrapper.getStreamId(), stoppedCountDown, try {
kmsDisconnectionTime); customThreadPool.submit(() -> wrappers.parallelStream().forEach(wrapper -> {
this.stopRecorderEndpointOfPublisherEndpoint(recording.getId(), wrapper.getStreamId(), stoppedCountDown,
kmsDisconnectionTime);
}));
} finally {
customThreadPool.shutdown();
} }
try { try {
if (!stoppedCountDown.await(5, TimeUnit.SECONDS)) { if (!stoppedCountDown.await(5, TimeUnit.SECONDS)) {
recording.setStatus(io.openvidu.java.client.Recording.Status.failed); recording.setStatus(io.openvidu.java.client.Recording.Status.failed);