mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: mediaNodeStatusChanged, launching/terminating
parent
ba2abde8a8
commit
25aad0f533
|
@ -19,6 +19,8 @@ package io.openvidu.server.cdr;
|
||||||
|
|
||||||
public enum CDREventName {
|
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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package io.openvidu.server.config;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
@ -350,13 +351,13 @@ public class OpenviduConfig {
|
||||||
return externalizedProperties;
|
return externalizedProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkWebsocketUri(String uri) throws Exception {
|
public URI checkWebsocketUri(String uri) throws Exception {
|
||||||
try {
|
try {
|
||||||
if (!uri.startsWith("ws://") || uri.startsWith("wss://")) {
|
if (!uri.startsWith("ws://") || uri.startsWith("wss://")) {
|
||||||
throw new Exception("WebSocket protocol not found");
|
throw new Exception("WebSocket protocol not found");
|
||||||
}
|
}
|
||||||
String parsedUri = uri.replaceAll("^ws://", "http://").replaceAll("^wss://", "https://");
|
String parsedUri = uri.replaceAll("^ws://", "http://").replaceAll("^wss://", "https://");
|
||||||
new URL(parsedUri).toURI();
|
return new URL(parsedUri).toURI();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new Exception("URI '" + uri + "' has not a valid WebSocket endpoint format: " + e.getMessage());
|
throw new Exception("URI '" + uri + "' has not a valid WebSocket endpoint format: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,8 @@ public class FixedOneKmsManager extends KmsManager {
|
||||||
KurentoClient kClient = null;
|
KurentoClient kClient = null;
|
||||||
Kms kms = new Kms(firstProps, loadManager);
|
Kms kms = new Kms(firstProps, loadManager);
|
||||||
try {
|
try {
|
||||||
kClient = KurentoClient.create(firstProps.getUri(), this.generateKurentoConnectionListener(kms.getId()));
|
kClient = KurentoClient.create(firstProps.getUri(),
|
||||||
|
this.generateKurentoConnectionListener(kms.getId(), false));
|
||||||
this.addKms(kms);
|
this.addKms(kms);
|
||||||
kms.setKurentoClient(kClient);
|
kms.setKurentoClient(kClient);
|
||||||
} catch (KurentoException e) {
|
} catch (KurentoException e) {
|
||||||
|
|
|
@ -144,7 +144,8 @@ public abstract class KmsManager {
|
||||||
return kmsLoads;
|
return kmsLoads;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KurentoConnectionListener generateKurentoConnectionListener(final String kmsId) {
|
protected KurentoConnectionListener generateKurentoConnectionListener(final String kmsId,
|
||||||
|
final boolean sendConnectedEvent) {
|
||||||
return new KurentoConnectionListener() {
|
return new KurentoConnectionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -188,7 +189,7 @@ public abstract class KmsManager {
|
||||||
final Kms kms = kmss.get(kmsId);
|
final Kms kms = kmss.get(kmsId);
|
||||||
kms.setKurentoClientConnected(true);
|
kms.setKurentoClientConnected(true);
|
||||||
kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());
|
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());
|
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() {
|
protected List<Kms> postConstruct() {
|
||||||
try {
|
try {
|
||||||
List<KmsProperties> kmsProps = new ArrayList<>();
|
List<KmsProperties> kmsProps = new ArrayList<>();
|
||||||
for (String kmsUri : this.openviduConfig.getKmsUris()) {
|
if (forceKmsUrisToHaveKmsIds != null) {
|
||||||
String kmsId = forceKmsUrisToHaveKmsIds != null ? forceKmsUrisToHaveKmsIds.get(kmsUri)
|
for (String kmsUri : this.openviduConfig.getKmsUris()) {
|
||||||
: "KMS-" + RandomStringUtils.randomAlphanumeric(6).toUpperCase();
|
String kmsId = forceKmsUrisToHaveKmsIds.get(kmsUri);
|
||||||
kmsProps.add(new KmsProperties(kmsId, 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) {
|
} catch (Exception e) {
|
||||||
// Some KMS wasn't reachable
|
// Some KMS wasn't reachable
|
||||||
log.error("Shutting down OpenVidu Server");
|
log.error("Shutting down OpenVidu Server");
|
||||||
|
|
|
@ -2,14 +2,14 @@ package io.openvidu.server.utils;
|
||||||
|
|
||||||
public interface MediaNodeStatusManager {
|
public interface MediaNodeStatusManager {
|
||||||
|
|
||||||
public boolean isPending(String mediaNodeId);
|
public boolean isLaunching(String mediaNodeId);
|
||||||
|
|
||||||
public boolean isRunning(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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package io.openvidu.server.utils;
|
||||||
public class MediaNodeStatusManagerDummy implements MediaNodeStatusManager {
|
public class MediaNodeStatusManagerDummy implements MediaNodeStatusManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPending(String mediaNodeId) {
|
public boolean isLaunching(String mediaNodeId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,17 +13,17 @@ public class MediaNodeStatusManagerDummy implements MediaNodeStatusManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isShuttingDown(String mediaNodeId) {
|
public boolean isTerminating(String mediaNodeId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWaitingIdleToShuttingDown(String mediaNodeId) {
|
public boolean isWaitingIdleToTerminating(String mediaNodeId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStatus(String mediaNodeId, String status) {
|
public void setStatus(String mediaNodeId, String uri, String status, boolean sendConnectedEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ openvidu.cdr.path=log
|
||||||
openvidu.webhook=false
|
openvidu.webhook=false
|
||||||
openvidu.webhook.endpoint=
|
openvidu.webhook.endpoint=
|
||||||
openvidu.webhook.headers=[]
|
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=false
|
||||||
openvidu.recording.version=2.9.0
|
openvidu.recording.version=2.9.0
|
||||||
|
|
Loading…
Reference in New Issue