openvidu-server: mediaNodeStatusChanged, launching/terminating

pull/370/head
pabloFuente 2019-10-24 10:46:15 +02:00
parent ba2abde8a8
commit 25aad0f533
7 changed files with 32 additions and 20 deletions

View File

@ -19,6 +19,8 @@ package io.openvidu.server.cdr;
public enum CDREventName {
sessionCreated, sessionDestroyed, participantJoined, participantLeft, webrtcConnectionCreated, webrtcConnectionDestroyed, recordingStarted, recordingStopped, recordingStatusChanged, filterEventDispatched, mediaNodeAdded, mediaNodeRemoved
sessionCreated, sessionDestroyed, participantJoined, participantLeft, webrtcConnectionCreated,
webrtcConnectionDestroyed, recordingStarted, recordingStopped, recordingStatusChanged, filterEventDispatched,
mediaNodeStatusChanged
}

View File

@ -20,6 +20,7 @@ package io.openvidu.server.config;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
@ -350,13 +351,13 @@ public class OpenviduConfig {
return externalizedProperties;
}
public void checkWebsocketUri(String uri) throws Exception {
public URI checkWebsocketUri(String uri) throws Exception {
try {
if (!uri.startsWith("ws://") || uri.startsWith("wss://")) {
throw new Exception("WebSocket protocol not found");
}
String parsedUri = uri.replaceAll("^ws://", "http://").replaceAll("^wss://", "https://");
new URL(parsedUri).toURI();
return new URL(parsedUri).toURI();
} catch (Exception e) {
throw new Exception("URI '" + uri + "' has not a valid WebSocket endpoint format: " + e.getMessage());
}

View File

@ -32,7 +32,8 @@ public class FixedOneKmsManager extends KmsManager {
KurentoClient kClient = null;
Kms kms = new Kms(firstProps, loadManager);
try {
kClient = KurentoClient.create(firstProps.getUri(), this.generateKurentoConnectionListener(kms.getId()));
kClient = KurentoClient.create(firstProps.getUri(),
this.generateKurentoConnectionListener(kms.getId(), false));
this.addKms(kms);
kms.setKurentoClient(kClient);
} catch (KurentoException e) {

View File

@ -144,7 +144,8 @@ public abstract class KmsManager {
return kmsLoads;
}
protected KurentoConnectionListener generateKurentoConnectionListener(final String kmsId) {
protected KurentoConnectionListener generateKurentoConnectionListener(final String kmsId,
final boolean sendConnectedEvent) {
return new KurentoConnectionListener() {
@Override
@ -188,7 +189,7 @@ public abstract class KmsManager {
final Kms kms = kmss.get(kmsId);
kms.setKurentoClientConnected(true);
kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());
mediaNodeStatusManager.setStatus(kmsId, "running");
mediaNodeStatusManager.setStatus(kmsId, kms.getUri(), "running", sendConnectedEvent);
log.warn("Kurento Client is now connected to KMS {} with uri {}", kmsId, kms.getUri());
}
};
@ -205,12 +206,19 @@ public abstract class KmsManager {
protected List<Kms> postConstruct() {
try {
List<KmsProperties> kmsProps = new ArrayList<>();
for (String kmsUri : this.openviduConfig.getKmsUris()) {
String kmsId = forceKmsUrisToHaveKmsIds != null ? forceKmsUrisToHaveKmsIds.get(kmsUri)
: "KMS-" + RandomStringUtils.randomAlphanumeric(6).toUpperCase();
kmsProps.add(new KmsProperties(kmsId, kmsUri));
if (forceKmsUrisToHaveKmsIds != null) {
for (String kmsUri : this.openviduConfig.getKmsUris()) {
String kmsId = forceKmsUrisToHaveKmsIds.get(kmsUri);
kmsProps.add(new KmsProperties(kmsId, kmsUri));
}
return this.initializeKurentoClients(kmsProps, true, true);
} else {
for (String kmsUri : this.openviduConfig.getKmsUris()) {
String kmsId = "kms-" + RandomStringUtils.randomAlphanumeric(6).toUpperCase();
kmsProps.add(new KmsProperties(kmsId, kmsUri));
}
return this.initializeKurentoClients(kmsProps, true, false);
}
return this.initializeKurentoClients(kmsProps, true, false);
} catch (Exception e) {
// Some KMS wasn't reachable
log.error("Shutting down OpenVidu Server");

View File

@ -2,14 +2,14 @@ package io.openvidu.server.utils;
public interface MediaNodeStatusManager {
public boolean isPending(String mediaNodeId);
public boolean isLaunching(String mediaNodeId);
public boolean isRunning(String mediaNodeId);
public boolean isShuttingDown(String mediaNodeId);
public boolean isTerminating(String mediaNodeId);
public boolean isWaitingIdleToShuttingDown(String mediaNodeId);
public boolean isWaitingIdleToTerminating(String mediaNodeId);
public void setStatus(String mediaNodeId, String status);
public void setStatus(String mediaNodeId, String uri, String status, boolean sendConnectedEvent);
}

View File

@ -3,7 +3,7 @@ package io.openvidu.server.utils;
public class MediaNodeStatusManagerDummy implements MediaNodeStatusManager {
@Override
public boolean isPending(String mediaNodeId) {
public boolean isLaunching(String mediaNodeId) {
return false;
}
@ -13,17 +13,17 @@ public class MediaNodeStatusManagerDummy implements MediaNodeStatusManager {
}
@Override
public boolean isShuttingDown(String mediaNodeId) {
public boolean isTerminating(String mediaNodeId) {
return false;
}
@Override
public boolean isWaitingIdleToShuttingDown(String mediaNodeId) {
public boolean isWaitingIdleToTerminating(String mediaNodeId) {
return false;
}
@Override
public void setStatus(String mediaNodeId, String status) {
public void setStatus(String mediaNodeId, String uri, String status, boolean sendConnectedEvent) {
}
}

View File

@ -20,7 +20,7 @@ openvidu.cdr.path=log
openvidu.webhook=false
openvidu.webhook.endpoint=
openvidu.webhook.headers=[]
openvidu.webhook.events=["sessionCreated","sessionDestroyed","participantJoined","participantLeft","webrtcConnectionCreated","webrtcConnectionDestroyed","recordingStatusChanged","filterEventDispatched","mediaNodeAdded","mediaNodeRemoved"]
openvidu.webhook.events=["sessionCreated","sessionDestroyed","participantJoined","participantLeft","webrtcConnectionCreated","webrtcConnectionDestroyed","recordingStatusChanged","filterEventDispatched","mediaNodeStatusChanged"]
openvidu.recording=false
openvidu.recording.version=2.9.0