From e5dec08ab969755252c8a1eada47ce8f97b9dbc7 Mon Sep 17 00:00:00 2001 From: Daniel Petri Rocha Date: Tue, 1 Feb 2022 17:24:57 +0100 Subject: [PATCH] List/Hash data structure in Redis for messages; add jobId in annotations format --- ...rePresentationAnnotationsRecordEvent.scala | 5 ++++ .../core/running/MeetingActor.scala | 9 +++--- .../bigbluebutton/core2/AnalyticsActor.scala | 4 +-- .../endpoint/redis/RedisRecorderActor.scala | 1 + .../common2/redis/RedisStorageService.java | 28 ++++++++++++++++--- .../common2/msgs/WhiteboardMsgs.scala | 1 + 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/record/events/StorePresentationAnnotationsRecordEvent.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/record/events/StorePresentationAnnotationsRecordEvent.scala index 5fd09e5dee..4120fbc8b5 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/record/events/StorePresentationAnnotationsRecordEvent.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/record/events/StorePresentationAnnotationsRecordEvent.scala @@ -27,6 +27,10 @@ class StorePresentationAnnotationsRecordEvent extends AbstractPresentationWithAn setEvent("StorePresentationAnnotationsRecordEvent") + def setJobId(jobId: String) { + eventMap.put(JOB_ID, jobId) + } + def setPresId(presId: String) { eventMap.put(PRES_ID, presId) } @@ -37,6 +41,7 @@ class StorePresentationAnnotationsRecordEvent extends AbstractPresentationWithAn } object StorePresentationAnnotationsRecordEvent { + protected final val JOB_ID = "jobId" protected final val PRES_ID = "presId" protected final val PAGES = "pages" } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala index faab7364b1..e8f34b9a03 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala @@ -778,12 +778,13 @@ class MeetingActor( resultingPage += 1 } + val jobId = RandomStringGenerator.randomAlphanumericString(16) + // 1) Send Annotations to Redis - var annotations = new StoredAnnotations(presId, storeAnnotationPages) + var annotations = new StoredAnnotations(jobId, presId, storeAnnotationPages) outGW.send(buildStoreAnnotationsInRedisSysMsg(annotations)) // 2) Insert Export Job in Redis - val jobId = RandomStringGenerator.randomAlphanumericString(16) val jobType = "PresentationWithAnnotationDownloadJob" val presLocation = s"/var/bigbluebutton/${presId}" val exportJob = new ExportJob(jobId, jobType, presId, presLocation, allPages, storeAnnotationPages, "", "") @@ -823,16 +824,16 @@ class MeetingActor( } val presentationUploadToken: String = PresentationPodsApp.generateToken("DEFAULT_PRESENTATION_POD", userId) + val jobId = RandomStringGenerator.randomAlphanumericString(16) // Informs bbb-web about the token so that when we use it to upload the presentation, it is able to look it up in the list of tokens outGW.send(buildPresentationUploadTokenSysPubMsg(parentMeetingId, userId, presentationUploadToken, currentPres.name)) // 1) Send Annotations to Redis - var annotations = new StoredAnnotations(presId, storeAnnotationPages) + var annotations = new StoredAnnotations(jobId, presId, storeAnnotationPages) outGW.send(buildStoreAnnotationsInRedisSysMsg(annotations)) // 2) Insert Export Job in Redis - val jobId = RandomStringGenerator.randomAlphanumericString(16) val jobType: String = "PresentationWithAnnotationExportJob" val presLocation = s"/var/bigbluebutton/${presId}" val exportJob = new ExportJob(jobId, jobType, presId, presLocation, allPages, storeAnnotationPages, parentMeetingId, presentationUploadToken) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/AnalyticsActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/AnalyticsActor.scala index bee0cba874..08307475ab 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/AnalyticsActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/AnalyticsActor.scala @@ -114,8 +114,8 @@ class AnalyticsActor(val includeChat: Boolean) extends Actor with ActorLogging { case m: SetPresentationDownloadableEvtMsg => logMessage(msg) //case m: PresentationPageConvertedSysMsg => logMessage(msg) //case m: PresentationPageConvertedEventMsg => logMessage(msg) - case m: StoreAnnotationsInRedisSysMsg => logMessage(msg) - case m: StoreExportJobInRedisSysMsg => logMessage(msg) + // case m: StoreAnnotationsInRedisSysMsg => logMessage(msg) + // case m: StoreExportJobInRedisSysMsg => logMessage(msg) case m: MakePresentationWithAnnotationDownloadReqMsg => logMessage(msg) case m: ExportPresentationWithAnnotationReqMsg => logMessage(msg) case m: PresentationPageConversionStartedSysMsg => logMessage(msg) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/RedisRecorderActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/RedisRecorderActor.scala index ecb459e05a..31005a14f9 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/RedisRecorderActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/RedisRecorderActor.scala @@ -142,6 +142,7 @@ class RedisRecorderActor( private def handleStoreAnnotationsInRedisSysMsg(msg: StoreAnnotationsInRedisSysMsg) { val ev = new StorePresentationAnnotationsRecordEvent() + ev.setJobId(msg.body.annotations.jobId) ev.setPresId(msg.body.annotations.presId) ev.setPages(msg.body.annotations.pages) diff --git a/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/RedisStorageService.java b/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/RedisStorageService.java index 0ff3781d54..0c26c29b46 100755 --- a/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/RedisStorageService.java +++ b/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/RedisStorageService.java @@ -21,6 +21,8 @@ package org.bigbluebutton.common2.redis; import java.util.HashMap; import java.util.Map; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import io.lettuce.core.api.sync.BaseRedisCommands; import org.slf4j.Logger; @@ -113,11 +115,29 @@ public class RedisStorageService extends RedisAwareCommunicator { } public void storePresentationAnnotations(String meetingId, Map event, String msgType) { - RedisCommands commands = connection.sync(); - Long msgid = commands.incr("global:nextRecordedMsgId"); + RedisCommands commands = connection.sync(); + commands.multi(); - commands.hmset("store" + msgType + ":" + meetingId + ":" + msgid, event); - commands.rpush("meeting:" + meetingId + ":" + "store" + msgType, Long.toString(msgid)); + + switch (msgType) { + case "Annotations": { + commands.hmset(event.get("jobId"), event); + break; + } + + case "ExportJob": { + Gson gson = new Gson(); + String exportJobAsJson = gson.toJson(event); + commands.rpush("exportJobs", exportJobAsJson.toString()); + break; + } + + default: { + log.error("Attempted to store PresentationAnnotations message of type: {} (expected 'Annotations' or 'ExportJob')", clientName); + break; + } + } + commands.exec(); } diff --git a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/WhiteboardMsgs.scala b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/WhiteboardMsgs.scala index ed9381f807..abc6862bfb 100755 --- a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/WhiteboardMsgs.scala +++ b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/WhiteboardMsgs.scala @@ -13,6 +13,7 @@ case class PresentationPageForExport( ) case class StoredAnnotations( + jobId: String, presId: String, pages: Array[PresentationPageForExport], )