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 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;
|
||||||
|
|
||||||
|
@ -57,9 +58,10 @@ public class FixedOneKmsManager extends KmsManager {
|
||||||
// TODO: This should be done in KurentoClient connected event
|
// TODO: This should be done in KurentoClient connected event
|
||||||
kms.setKurentoClientConnected(true);
|
kms.setKurentoClientConnected(true);
|
||||||
kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());
|
kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());
|
||||||
|
MediaServer mediaServer = kms.fetchMediaServerType();
|
||||||
|
|
||||||
// Set Media Server in OpenVidu configuration
|
// Set Media Server in OpenVidu configuration
|
||||||
this.openviduConfig.setMediaServer(kms.getMediaServer());
|
this.openviduConfig.setMediaServer(mediaServer);
|
||||||
|
|
||||||
} 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());
|
||||||
|
|
|
@ -37,11 +37,11 @@ import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import io.openvidu.java.client.RecordingProperties;
|
import io.openvidu.java.client.RecordingProperties;
|
||||||
|
import io.openvidu.server.core.MediaServer;
|
||||||
import io.openvidu.server.kurento.core.KurentoSession;
|
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
|
||||||
|
@ -62,6 +62,7 @@ public class Kms {
|
||||||
private String uri;
|
private String uri;
|
||||||
private String ip;
|
private String ip;
|
||||||
private KurentoClient client;
|
private KurentoClient client;
|
||||||
|
private MediaServer mediaServer;
|
||||||
private UpdatableTimerTask clientReconnectTimer;
|
private UpdatableTimerTask clientReconnectTimer;
|
||||||
private LoadManager loadManager;
|
private LoadManager loadManager;
|
||||||
private QuarantineKiller quarantineKiller;
|
private QuarantineKiller quarantineKiller;
|
||||||
|
@ -201,8 +202,7 @@ 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", this.mediaServer.name());
|
||||||
json.addProperty("mediaServer", mediaServer.name());
|
|
||||||
|
|
||||||
if (withSessions) {
|
if (withSessions) {
|
||||||
JsonArray sessions = new JsonArray();
|
JsonArray sessions = new JsonArray();
|
||||||
|
@ -227,7 +227,7 @@ public class Kms {
|
||||||
JsonObject kurentoExtraInfo = new JsonObject();
|
JsonObject kurentoExtraInfo = new JsonObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (MediaServer.kurento.equals(mediaServer)) {
|
if (MediaServer.kurento.equals(this.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();
|
||||||
|
@ -281,13 +281,14 @@ public class Kms {
|
||||||
return this.activeComposedRecordings.intValue();
|
return this.activeComposedRecordings.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MediaServer getMediaServer() {
|
public MediaServer fetchMediaServerType() {
|
||||||
ServerInfo serverInfo = this.client.getServerManager().getInfo();
|
ServerInfo serverInfo = this.client.getServerManager().getInfo();
|
||||||
if (serverInfo.getVersion().startsWith("openvidu/mediasoup-controller")) {
|
if (serverInfo.getVersion().startsWith("openvidu/mediasoup-controller")) {
|
||||||
return MediaServer.mediasoup;
|
this.mediaServer = MediaServer.mediasoup;
|
||||||
} else {
|
} 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.Continuation;
|
||||||
import org.kurento.client.KurentoClient;
|
import org.kurento.client.KurentoClient;
|
||||||
import org.kurento.client.MediaPipeline;
|
import org.kurento.client.MediaPipeline;
|
||||||
|
import org.kurento.client.ServerInfo;
|
||||||
import org.kurento.client.ServerManager;
|
import org.kurento.client.ServerManager;
|
||||||
|
import org.kurento.client.ServerType;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.powermock.reflect.Whitebox;
|
import org.powermock.reflect.Whitebox;
|
||||||
import org.springframework.boot.test.context.TestConfiguration;
|
import org.springframework.boot.test.context.TestConfiguration;
|
||||||
|
@ -50,12 +52,16 @@ public class IntegrationTestConfiguration {
|
||||||
}).when(kClient).createMediaPipeline((Continuation<MediaPipeline>) any());
|
}).when(kClient).createMediaPipeline((Continuation<MediaPipeline>) any());
|
||||||
|
|
||||||
ServerManager serverManagerMock = mock(ServerManager.class);
|
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(serverManagerMock.getCpuCount()).thenReturn(new Random().nextInt(32) + 1);
|
||||||
when(kClient.getServerManager()).thenReturn(serverManagerMock);
|
when(kClient.getServerManager()).thenReturn(serverManagerMock);
|
||||||
|
|
||||||
kms.setKurentoClient(kClient);
|
kms.setKurentoClient(kClient);
|
||||||
kms.setKurentoClientConnected(true);
|
kms.setKurentoClientConnected(true);
|
||||||
kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());
|
kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());
|
||||||
|
kms.fetchMediaServerType();
|
||||||
|
|
||||||
spy.addKms(kms);
|
spy.addKms(kms);
|
||||||
successfullyConnectedKmss.add(kms);
|
successfullyConnectedKmss.add(kms);
|
||||||
|
|
Loading…
Reference in New Issue