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 org.kurento.client.KurentoClient;
|
||||
import org.kurento.client.ServerInfo;
|
||||
import org.kurento.commons.exception.KurentoException;
|
||||
import org.kurento.jsonrpc.client.JsonRpcClientNettyWebSocket;
|
||||
import org.kurento.jsonrpc.client.JsonRpcWSConnectionListener;
|
||||
|
||||
import io.openvidu.java.client.RecordingProperties;
|
||||
import io.openvidu.server.core.MediaServer;
|
||||
import io.openvidu.server.core.Session;
|
||||
import io.openvidu.server.core.SessionManager;
|
||||
|
||||
|
@ -61,12 +59,7 @@ public class FixedOneKmsManager extends KmsManager {
|
|||
kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());
|
||||
|
||||
// Set Media Server in OpenVidu configuration
|
||||
ServerInfo serverInfo = kms.getKurentoClient().getServerManager().getInfo();
|
||||
if (serverInfo.getVersion().startsWith("openvidu/mediasoup-controller")) {
|
||||
this.openviduConfig.setMediaServer(MediaServer.mediasoup);
|
||||
} else {
|
||||
this.openviduConfig.setMediaServer(MediaServer.kurento);
|
||||
}
|
||||
this.openviduConfig.setMediaServer(kms.getMediaServer());
|
||||
|
||||
} catch (KurentoException e) {
|
||||
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.RecordingUtils;
|
||||
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
|
||||
|
@ -200,6 +201,8 @@ public class Kms {
|
|||
public JsonObject toJsonExtended(boolean withSessions, boolean withRecordings, boolean withExtraInfo) {
|
||||
|
||||
JsonObject json = this.toJson();
|
||||
MediaServer mediaServer = getMediaServer();
|
||||
json.addProperty("mediaServer", mediaServer.name());
|
||||
|
||||
if (withSessions) {
|
||||
JsonArray sessions = new JsonArray();
|
||||
|
@ -224,28 +227,28 @@ public class Kms {
|
|||
JsonObject kurentoExtraInfo = new JsonObject();
|
||||
|
||||
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();
|
||||
kurentoExtraInfo.addProperty("version", info.getVersion());
|
||||
kurentoExtraInfo.addProperty("capabilities", info.getCapabilities().toString());
|
||||
|
||||
ServerInfo info = this.client.getServerManager().getInfo();
|
||||
kurentoExtraInfo.addProperty("version", info.getVersion());
|
||||
kurentoExtraInfo.addProperty("capabilities", info.getCapabilities().toString());
|
||||
JsonArray modules = new JsonArray();
|
||||
for (ModuleInfo moduleInfo : info.getModules()) {
|
||||
JsonObject moduleJson = new JsonObject();
|
||||
moduleJson.addProperty("name", moduleInfo.getName());
|
||||
moduleJson.addProperty("version", moduleInfo.getVersion());
|
||||
moduleJson.addProperty("generationTime", moduleInfo.getGenerationTime());
|
||||
JsonArray factories = new JsonArray();
|
||||
moduleInfo.getFactories().forEach(fact -> factories.add(fact));
|
||||
moduleJson.add("factories", factories);
|
||||
modules.add(moduleJson);
|
||||
}
|
||||
kurentoExtraInfo.add("modules", modules);
|
||||
|
||||
JsonArray modules = new JsonArray();
|
||||
for (ModuleInfo moduleInfo : info.getModules()) {
|
||||
JsonObject moduleJson = new JsonObject();
|
||||
moduleJson.addProperty("name", moduleInfo.getName());
|
||||
moduleJson.addProperty("version", moduleInfo.getVersion());
|
||||
moduleJson.addProperty("generationTime", moduleInfo.getGenerationTime());
|
||||
JsonArray factories = new JsonArray();
|
||||
moduleInfo.getFactories().forEach(fact -> factories.add(fact));
|
||||
moduleJson.add("factories", factories);
|
||||
modules.add(moduleJson);
|
||||
json.add("kurentoInfo", kurentoExtraInfo);
|
||||
}
|
||||
kurentoExtraInfo.add("modules", modules);
|
||||
|
||||
json.add("kurentoInfo", kurentoExtraInfo);
|
||||
|
||||
} catch (Exception e) {
|
||||
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();
|
||||
}
|
||||
|
||||
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