You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2020/08/26 16:02:30 UTC
[openmeetings] branch master updated: [OPENMEETINGS-2422] multiple
OM instances can use same KMS
This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push:
new 52cb4eb [OPENMEETINGS-2422] multiple OM instances can use same KMS
52cb4eb is described below
commit 52cb4ebf5e7363efc85ed86691abf98872d8dddd
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Wed Aug 26 23:01:55 2020 +0700
[OPENMEETINGS-2422] multiple OM instances can use same KMS
---
.../openmeetings/core/remote/KurentoHandler.java | 39 ++++++++++++++++------
.../webapp/WEB-INF/classes/applicationContext.xml | 4 +++
2 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java
index 22000b8..37e5730 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java
@@ -19,7 +19,6 @@
*/
package org.apache.openmeetings.core.remote;
-import static java.util.UUID.randomUUID;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.security.InvalidKeyException;
@@ -27,8 +26,11 @@ import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -39,7 +41,6 @@ import javax.annotation.PreDestroy;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
-import org.apache.directory.api.util.Strings;
import org.apache.openmeetings.core.util.WebSocketHelper;
import org.apache.openmeetings.db.dao.record.RecordingChunkDao;
import org.apache.openmeetings.db.dao.room.RoomDao;
@@ -53,6 +54,7 @@ import org.apache.openmeetings.db.entity.user.User;
import org.apache.openmeetings.db.manager.IClientManager;
import org.apache.openmeetings.db.util.ws.RoomMessage;
import org.apache.openmeetings.db.util.ws.TextRoomMessage;
+import org.apache.wicket.util.string.Strings;
import org.kurento.client.Endpoint;
import org.kurento.client.EventListener;
import org.kurento.client.KurentoClient;
@@ -97,6 +99,7 @@ public class KurentoHandler {
private KurentoClient client;
private final AtomicBoolean connected = new AtomicBoolean(false);
private String kuid;
+ private final Set<String> ignoredKuids = new HashSet<>();
private final Map<Long, KRoom> rooms = new ConcurrentHashMap<>();
private Runnable check;
@@ -127,7 +130,6 @@ public class KurentoHandler {
return;
}
log.debug("Reconnecting KMS");
- kuid = randomUUID().toString();
client = KurentoClient.createFromJsonRpcClient(new JsonRpcClientNettyWebSocket(kurentoWsUrl) {
{
setTryReconnectingMaxTime(0);
@@ -377,6 +379,16 @@ public class KurentoHandler {
return kuid;
}
+ public void setKuid(String kuid) {
+ this.kuid = kuid;
+ }
+
+ public void setIgnoredKuids(String ignoredKuids) {
+ if (!Strings.isEmpty(ignoredKuids)) {
+ this.ignoredKuids.addAll(List.of(ignoredKuids.split("[, ]")));
+ }
+ }
+
public void setCheckTimeout(long checkTimeout) {
this.checkTimeout = checkTimeout;
}
@@ -441,10 +453,14 @@ public class KurentoHandler {
// still alive
MediaPipeline pipe = client.getById(roid, MediaPipeline.class);
Map<String, String> tags = tagsAsMap(pipe);
+ final String inKuid = tags.get(TAG_KUID);
+ if (ignoredKuids.contains(inKuid)) {
+ return;
+ }
if (validTestPipeline(tags)) {
return;
}
- if (kuid.equals(tags.get(TAG_KUID))) {
+ if (kuid.equals(inKuid)) {
KRoom r = rooms.get(Long.valueOf(tags.get(TAG_ROOM)));
if (r.getPipeline().getId().equals(pipe.getId())) {
return;
@@ -475,7 +491,12 @@ public class KurentoHandler {
}
// still alive
Endpoint point = client.getById(eoid, fClazz);
- if (validTestPipeline(point.getMediaPipeline())) {
+ Map<String, String> pipeTags = tagsAsMap(point.getMediaPipeline());
+ final String inKuid = pipeTags.get(TAG_KUID);
+ if (ignoredKuids.contains(inKuid)) {
+ return;
+ }
+ if (validTestPipeline(pipeTags)) {
return;
}
Map<String, String> tags = tagsAsMap(point);
@@ -490,12 +511,10 @@ public class KurentoHandler {
}
}
- private boolean validTestPipeline(MediaPipeline pipeline) {
- return validTestPipeline(tagsAsMap(pipeline));
- }
-
private boolean validTestPipeline(Map<String, String> tags) {
- return kuid.equals(tags.get(TAG_KUID)) && MODE_TEST.equals(tags.get(TAG_MODE)) && MODE_TEST.equals(tags.get(TAG_ROOM));
+ return kuid.equals(tags.get(TAG_KUID))
+ && MODE_TEST.equals(tags.get(TAG_MODE))
+ && MODE_TEST.equals(tags.get(TAG_ROOM));
}
}
}
diff --git a/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml b/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml
index e24aee8..567814b 100644
--- a/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml
+++ b/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml
@@ -144,6 +144,8 @@
</bean>
<!-- Kurento -->
+ <!-- please ensure `p:kuid` below is unique, better to regenerate it from time to time -->
+ <!-- `p:ignoredKuids` can be space and/or comma separated -->
<bean id="kurentoHandler" class="org.apache.openmeetings.core.remote.KurentoHandler"
p:kurentoWsUrl="ws://127.0.0.1:8888/kurento"
p:checkTimeout="10000"
@@ -155,5 +157,7 @@
p:turnTtl="60"
p:objCheckTimeout="200"
p:flowoutTimeout="5"
+ p:kuid="df992960-e7b0-11ea-9acd-337fb30dd93d"
+ p:ignoredKuids=""
/>
</beans>