openvidu-server: filter non connected KMSs when getting less loaded

pull/419/head
pabloFuente 2020-04-02 01:49:51 +02:00
parent aecb0095b3
commit 96440b9f26
3 changed files with 7 additions and 6 deletions

View File

@ -111,7 +111,7 @@ public class KurentoSessionManager extends SessionManager {
lockAcquired = true;
Kms lessLoadedKms = null;
try {
lessLoadedKms = this.kmsManager.getLessLoadedAndRunningKms();
lessLoadedKms = this.kmsManager.getLessLoadedConnectedAndRunningKms();
} catch (NoSuchElementException e) {
// Restore session not active
this.cleanCollections(sessionId);

View File

@ -102,9 +102,9 @@ public abstract class KmsManager {
return this.kmss.remove(kmsId);
}
public synchronized Kms getLessLoadedAndRunningKms() throws NoSuchElementException {
List<KmsLoad> kmsLoads = getKmsLoads().stream()
.filter(kmsLoad -> mediaNodeStatusManager.isRunning(kmsLoad.kms.getId())).collect(Collectors.toList());
public synchronized Kms getLessLoadedConnectedAndRunningKms() throws NoSuchElementException {
List<KmsLoad> kmsLoads = getKmsLoads().stream().filter(kmsLoad -> kmsLoad.kms.isKurentoClientConnected()
&& mediaNodeStatusManager.isRunning(kmsLoad.kms.getId())).collect(Collectors.toList());
return Collections.min(kmsLoads).kms;
}
@ -183,7 +183,8 @@ public abstract class KmsManager {
@Override
public void connected() {
final Kms kms = kmss.get(kmsId);
// TODO: This should be done here instead of after KurentoClient.create method returns
// TODO: This should be done here instead of after KurentoClient.create method
// returns
// kms.setKurentoClientConnected(true);
// kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());
log.info("Kurento Client is now connected to KMS {} with uri {}", kmsId, kms.getUri());

View File

@ -629,7 +629,7 @@ public class RecordingManager {
log.warn("No KMSs were defined in kms.uris array. Recording path check aborted");
} else {
MediaPipeline pipeline = this.kmsManager.getLessLoadedAndRunningKms().getKurentoClient()
MediaPipeline pipeline = this.kmsManager.getLessLoadedConnectedAndRunningKms().getKurentoClient()
.createMediaPipeline();
RecorderEndpoint recorder = new RecorderEndpoint.Builder(pipeline, "file://" + testFilePath).build();