mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: protect get KMS if there's no running and connected one
parent
a3406d3dfe
commit
7085bb899b
|
@ -114,8 +114,12 @@ public abstract class KmsManager {
|
|||
public synchronized Kms getLessLoadedConnectedAndRunningKms() throws NoSuchElementException {
|
||||
List<KmsLoad> kmsLoads = getKmsLoads().stream().filter(kmsLoad -> kmsLoad.kms.isKurentoClientConnected()
|
||||
&& mediaNodeStatusManager.isRunning(kmsLoad.kms.getId())).collect(Collectors.toList());
|
||||
if (kmsLoads.isEmpty()) {
|
||||
throw new NoSuchElementException();
|
||||
} else {
|
||||
return Collections.min(kmsLoads).kms;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized List<KmsLoad> getKmssSortedByLoad() {
|
||||
List<KmsLoad> kmsLoads = getKmsLoads();
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Collection;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
@ -67,6 +68,7 @@ import io.openvidu.server.core.Session;
|
|||
import io.openvidu.server.core.SessionEventsHandler;
|
||||
import io.openvidu.server.core.SessionManager;
|
||||
import io.openvidu.server.kurento.core.KurentoSession;
|
||||
import io.openvidu.server.kurento.kms.Kms;
|
||||
import io.openvidu.server.kurento.kms.KmsManager;
|
||||
import io.openvidu.server.recording.Recording;
|
||||
import io.openvidu.server.recording.RecordingDownloader;
|
||||
|
@ -678,7 +680,14 @@ public class RecordingManager {
|
|||
if (this.kmsManager.getKmss().isEmpty()) {
|
||||
log.warn("No KMSs were defined in KMS_URIS array. Recording path check aborted");
|
||||
} else {
|
||||
|
||||
Kms kms = null;
|
||||
try {
|
||||
kms = this.kmsManager.getLessLoadedConnectedAndRunningKms();
|
||||
} catch (NoSuchElementException e) {
|
||||
}
|
||||
if (kms == null) {
|
||||
log.warn("There are not running and connected KMSs. Recording path check aborted");
|
||||
} else {
|
||||
MediaPipeline pipeline = this.kmsManager.getLessLoadedConnectedAndRunningKms().getKurentoClient()
|
||||
.createMediaPipeline();
|
||||
RecorderEndpoint recorder = new RecorderEndpoint.Builder(pipeline, "file://" + testFilePath).build();
|
||||
|
@ -733,6 +742,7 @@ public class RecordingManager {
|
|||
throw new OpenViduException(Code.RECORDING_PATH_NOT_VALID, errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (openviduConfig.openviduRecordingCustomLayoutChanged(openviduRecordingCustomLayout)) {
|
||||
// Property OPENVIDU_RECORDING_CUSTOM_LAYOUT changed
|
||||
|
|
Loading…
Reference in New Issue