mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: refactor with method Kms.getMediaServer to get which media server is running and Add it to Kms.toJsonExtended as attribute
parent
cff5e634f5
commit
594cd24706
|
@ -25,13 +25,11 @@ import java.util.NoSuchElementException;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.kurento.client.KurentoClient;
|
import org.kurento.client.KurentoClient;
|
||||||
import org.kurento.client.ServerInfo;
|
|
||||||
import org.kurento.commons.exception.KurentoException;
|
import org.kurento.commons.exception.KurentoException;
|
||||||
import org.kurento.jsonrpc.client.JsonRpcClientNettyWebSocket;
|
import org.kurento.jsonrpc.client.JsonRpcClientNettyWebSocket;
|
||||||
import org.kurento.jsonrpc.client.JsonRpcWSConnectionListener;
|
import org.kurento.jsonrpc.client.JsonRpcWSConnectionListener;
|
||||||
|
|
||||||
import io.openvidu.java.client.RecordingProperties;
|
import io.openvidu.java.client.RecordingProperties;
|
||||||
import io.openvidu.server.core.MediaServer;
|
|
||||||
import io.openvidu.server.core.Session;
|
import io.openvidu.server.core.Session;
|
||||||
import io.openvidu.server.core.SessionManager;
|
import io.openvidu.server.core.SessionManager;
|
||||||
|
|
||||||
|
@ -61,12 +59,7 @@ public class FixedOneKmsManager extends KmsManager {
|
||||||
kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());
|
kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());
|
||||||
|
|
||||||
// Set Media Server in OpenVidu configuration
|
// Set Media Server in OpenVidu configuration
|
||||||
ServerInfo serverInfo = kms.getKurentoClient().getServerManager().getInfo();
|
this.openviduConfig.setMediaServer(kms.getMediaServer());
|
||||||
if (serverInfo.getVersion().startsWith("openvidu/mediasoup-controller")) {
|
|
||||||
this.openviduConfig.setMediaServer(MediaServer.mediasoup);
|
|
||||||
} else {
|
|
||||||
this.openviduConfig.setMediaServer(MediaServer.kurento);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (KurentoException e) {
|
} catch (KurentoException e) {
|
||||||
log.error("KMS in {} is not reachable by OpenVidu Server", firstProps.getUri());
|
log.error("KMS in {} is not reachable by OpenVidu Server", firstProps.getUri());
|
||||||
|
|
|
@ -41,6 +41,7 @@ import io.openvidu.server.kurento.core.KurentoSession;
|
||||||
import io.openvidu.server.utils.QuarantineKiller;
|
import io.openvidu.server.utils.QuarantineKiller;
|
||||||
import io.openvidu.server.utils.RecordingUtils;
|
import io.openvidu.server.utils.RecordingUtils;
|
||||||
import io.openvidu.server.utils.UpdatableTimerTask;
|
import io.openvidu.server.utils.UpdatableTimerTask;
|
||||||
|
import io.openvidu.server.core.MediaServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstraction of a KMS instance: an object of this class corresponds to a KMS
|
* Abstraction of a KMS instance: an object of this class corresponds to a KMS
|
||||||
|
@ -200,6 +201,8 @@ public class Kms {
|
||||||
public JsonObject toJsonExtended(boolean withSessions, boolean withRecordings, boolean withExtraInfo) {
|
public JsonObject toJsonExtended(boolean withSessions, boolean withRecordings, boolean withExtraInfo) {
|
||||||
|
|
||||||
JsonObject json = this.toJson();
|
JsonObject json = this.toJson();
|
||||||
|
MediaServer mediaServer = getMediaServer();
|
||||||
|
json.addProperty("mediaServer", mediaServer.name());
|
||||||
|
|
||||||
if (withSessions) {
|
if (withSessions) {
|
||||||
JsonArray sessions = new JsonArray();
|
JsonArray sessions = new JsonArray();
|
||||||
|
@ -224,7 +227,7 @@ public class Kms {
|
||||||
JsonObject kurentoExtraInfo = new JsonObject();
|
JsonObject kurentoExtraInfo = new JsonObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (MediaServer.kurento.equals(mediaServer)) {
|
||||||
kurentoExtraInfo.addProperty("memory", this.client.getServerManager().getUsedMemory() / 1024);
|
kurentoExtraInfo.addProperty("memory", this.client.getServerManager().getUsedMemory() / 1024);
|
||||||
|
|
||||||
ServerInfo info = this.client.getServerManager().getInfo();
|
ServerInfo info = this.client.getServerManager().getInfo();
|
||||||
|
@ -245,7 +248,7 @@ public class Kms {
|
||||||
kurentoExtraInfo.add("modules", modules);
|
kurentoExtraInfo.add("modules", modules);
|
||||||
|
|
||||||
json.add("kurentoInfo", kurentoExtraInfo);
|
json.add("kurentoInfo", kurentoExtraInfo);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("KMS {} extra info was requested but there's no connection to it", this.id);
|
log.warn("KMS {} extra info was requested but there's no connection to it", this.id);
|
||||||
}
|
}
|
||||||
|
@ -278,4 +281,13 @@ public class Kms {
|
||||||
return this.activeComposedRecordings.intValue();
|
return this.activeComposedRecordings.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MediaServer getMediaServer() {
|
||||||
|
ServerInfo serverInfo = this.client.getServerManager().getInfo();
|
||||||
|
if (serverInfo.getVersion().startsWith("openvidu/mediasoup-controller")) {
|
||||||
|
return MediaServer.mediasoup;
|
||||||
|
} else {
|
||||||
|
return MediaServer.kurento;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue