mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: Kms#fetchMediaServerType (no remote operation on GET media-node)
parent
701e35356b
commit
022a692735
|
@ -30,6 +30,7 @@ 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;
|
||||
|
||||
|
@ -57,9 +58,10 @@ public class FixedOneKmsManager extends KmsManager {
|
|||
// TODO: This should be done in KurentoClient connected event
|
||||
kms.setKurentoClientConnected(true);
|
||||
kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());
|
||||
MediaServer mediaServer = kms.fetchMediaServerType();
|
||||
|
||||
// Set Media Server in OpenVidu configuration
|
||||
this.openviduConfig.setMediaServer(kms.getMediaServer());
|
||||
this.openviduConfig.setMediaServer(mediaServer);
|
||||
|
||||
} catch (KurentoException e) {
|
||||
log.error("KMS in {} is not reachable by OpenVidu Server", firstProps.getUri());
|
||||
|
|
|
@ -37,11 +37,11 @@ import com.google.gson.JsonArray;
|
|||
import com.google.gson.JsonObject;
|
||||
|
||||
import io.openvidu.java.client.RecordingProperties;
|
||||
import io.openvidu.server.core.MediaServer;
|
||||
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
|
||||
|
@ -62,6 +62,7 @@ public class Kms {
|
|||
private String uri;
|
||||
private String ip;
|
||||
private KurentoClient client;
|
||||
private MediaServer mediaServer;
|
||||
private UpdatableTimerTask clientReconnectTimer;
|
||||
private LoadManager loadManager;
|
||||
private QuarantineKiller quarantineKiller;
|
||||
|
@ -201,8 +202,7 @@ public class Kms {
|
|||
public JsonObject toJsonExtended(boolean withSessions, boolean withRecordings, boolean withExtraInfo) {
|
||||
|
||||
JsonObject json = this.toJson();
|
||||
MediaServer mediaServer = getMediaServer();
|
||||
json.addProperty("mediaServer", mediaServer.name());
|
||||
json.addProperty("mediaServer", this.mediaServer.name());
|
||||
|
||||
if (withSessions) {
|
||||
JsonArray sessions = new JsonArray();
|
||||
|
@ -227,7 +227,7 @@ public class Kms {
|
|||
JsonObject kurentoExtraInfo = new JsonObject();
|
||||
|
||||
try {
|
||||
if (MediaServer.kurento.equals(mediaServer)) {
|
||||
if (MediaServer.kurento.equals(this.mediaServer)) {
|
||||
kurentoExtraInfo.addProperty("memory", this.client.getServerManager().getUsedMemory() / 1024);
|
||||
|
||||
ServerInfo info = this.client.getServerManager().getInfo();
|
||||
|
@ -281,13 +281,14 @@ public class Kms {
|
|||
return this.activeComposedRecordings.intValue();
|
||||
}
|
||||
|
||||
public MediaServer getMediaServer() {
|
||||
public MediaServer fetchMediaServerType() {
|
||||
ServerInfo serverInfo = this.client.getServerManager().getInfo();
|
||||
if (serverInfo.getVersion().startsWith("openvidu/mediasoup-controller")) {
|
||||
return MediaServer.mediasoup;
|
||||
this.mediaServer = MediaServer.mediasoup;
|
||||
} else {
|
||||
return MediaServer.kurento;
|
||||
this.mediaServer = MediaServer.kurento;
|
||||
}
|
||||
return this.mediaServer;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@ import java.util.Random;
|
|||
import org.kurento.client.Continuation;
|
||||
import org.kurento.client.KurentoClient;
|
||||
import org.kurento.client.MediaPipeline;
|
||||
import org.kurento.client.ServerInfo;
|
||||
import org.kurento.client.ServerManager;
|
||||
import org.kurento.client.ServerType;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
|
@ -50,12 +52,16 @@ public class IntegrationTestConfiguration {
|
|||
}).when(kClient).createMediaPipeline((Continuation<MediaPipeline>) any());
|
||||
|
||||
ServerManager serverManagerMock = mock(ServerManager.class);
|
||||
ServerInfo serverInfoMock = new ServerInfo("6.16.0", new ArrayList<>(), ServerType.KMS,
|
||||
new ArrayList<>());
|
||||
when(serverManagerMock.getInfo()).thenReturn(serverInfoMock);
|
||||
when(serverManagerMock.getCpuCount()).thenReturn(new Random().nextInt(32) + 1);
|
||||
when(kClient.getServerManager()).thenReturn(serverManagerMock);
|
||||
|
||||
kms.setKurentoClient(kClient);
|
||||
kms.setKurentoClientConnected(true);
|
||||
kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());
|
||||
kms.fetchMediaServerType();
|
||||
|
||||
spy.addKms(kms);
|
||||
successfullyConnectedKmss.add(kms);
|
||||
|
|
Loading…
Reference in New Issue