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 fc441fba9aefd611d8403572c7368a2dac998974..53c001a320b47aaaebb373fd1cb88fd843641178 100644 --- 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,8 +21,6 @@ package org.bigbluebutton.common2.redis; import java.util.Map; -import org.bigbluebutton.common2.redis.commands.MeetingCommands; -import org.bigbluebutton.common2.redis.commands.RecordingCommands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,7 +29,6 @@ import io.lettuce.core.RedisClient; import io.lettuce.core.RedisURI; import io.lettuce.core.api.StatefulRedisConnection; import io.lettuce.core.api.sync.RedisCommands; -import io.lettuce.core.dynamic.RedisCommandFactory; public class RedisStorageService extends RedisAwareCommunicator { @@ -39,9 +36,9 @@ public class RedisStorageService extends RedisAwareCommunicator { private long keyExpiry; - MeetingCommands meetingCommands; - RecordingCommands recordingCommands; - + // MeetingCommands meetingCommands; + // RecordingCommands recordingCommands; + RedisCommands<String, String> commands; private StatefulRedisConnection<String, String> connection; public void start() { @@ -56,13 +53,6 @@ public class RedisStorageService extends RedisAwareCommunicator { redisClient.setOptions(ClientOptions.builder().autoReconnect(true).build()); connection = redisClient.connect(); - RedisCommandFactory factory = new RedisCommandFactory(connection); - initCommands(factory); - } - - private void initCommands(RedisCommandFactory factory) { - meetingCommands = factory.getCommands(MeetingCommands.class); - recordingCommands = factory.getCommands(RecordingCommands.class); } public void stop() { @@ -83,18 +73,16 @@ public class RedisStorageService extends RedisAwareCommunicator { public void addBreakoutRoom(String parentId, String breakoutId) { log.debug("Saving breakout room for meeting {}", parentId); - meetingCommands.addBreakoutRooms(Keys.BREAKOUT_ROOMS + parentId, breakoutId); + commands.sadd(Keys.BREAKOUT_ROOMS + parentId, breakoutId); } public void record(String meetingId, Map<String, String> event) { log.debug("Recording meeting event {} inside a transaction", meetingId); RedisCommands<String, String> commands = connection.sync(); commands.multi(); - // @fixme increment Long msgid = - // recordingCommands.incrementRecords("global:nextRecordedMsgId"); - Long msgid = 999L; - recordingCommands.recordEventName("recording:" + meetingId + ":" + msgid, event); - recordingCommands.recordEventValues("meeting:" + meetingId + ":" + "recordings", Long.toString(msgid)); + Long msgid = commands.incr("global:nextRecordedMsgId"); + commands.hmset("recording:" + meetingId + ":" + msgid, event); + commands.rpush("meeting:" + meetingId + ":" + "recordings", Long.toString(msgid)); commands.exec(); } @@ -103,8 +91,8 @@ public class RedisStorageService extends RedisAwareCommunicator { log.debug("Removing meeting meeting {} inside a transaction", meetingId); RedisCommands<String, String> commands = connection.sync(); commands.multi(); - meetingCommands.deleteMeeting(Keys.MEETING + meetingId); - meetingCommands.deleteMeetings(Keys.MEETINGS + meetingId); + commands.del(Keys.MEETING + meetingId); + commands.srem(Keys.MEETINGS + meetingId); commands.exec(); } @@ -113,26 +101,23 @@ public class RedisStorageService extends RedisAwareCommunicator { RedisCommands<String, String> commands = connection.sync(); commands.multi(); - // @fixme increment Long msgid = - // recordingCommands.incrementRecords("global:nextRecordedMsgId"); - Long msgid = 999L; - recordingCommands.recordEventName("recording:" + meetingId + ":" + msgid, event); - recordingCommands.recordEventValues("meeting:" + meetingId + ":recordings", Long.toString(msgid)); + Long msgid = commands.incr("global:nextRecordedMsgId"); + commands.hmset("recording:" + meetingId + ":" + msgid, event); + commands.rpush("meeting:" + meetingId + ":recordings", Long.toString(msgid)); /** * We set the key to expire after 14 days as we are still recording the * event into redis even if the meeting is not recorded. (ralam sept 23, * 2015) */ - // @fixme buggy recordingCommands.expireKey("meeting:" + meetingId + - // ":recordings", keyExpiry); - recordingCommands.recordEventValues("meeting:" + meetingId + ":recordings", Long.toString(msgid)); - // @fixme buggy recordingCommands.expireKey("meeting:" + meetingId + - // ":recordings", keyExpiry); + commands.expire("meeting:" + meetingId + ":recordings", keyExpiry); + commands.rpush("meeting:" + meetingId + ":recordings", Long.toString(msgid)); + commands.expire("meeting:" + meetingId + ":recordings", keyExpiry); commands.exec(); } private String recordMeeting(String key, Map<String, String> info) { - return meetingCommands.recordMeetingInfo(key, info); + RedisCommands<String, String> commands = connection.sync(); + return commands.hmset(key, info); } } diff --git a/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/commands/MeetingCommands.java b/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/commands/MeetingCommands.java deleted file mode 100644 index 07706079d0ffcbe906c677ef6995427c61eac770..0000000000000000000000000000000000000000 --- a/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/commands/MeetingCommands.java +++ /dev/null @@ -1,42 +0,0 @@ -/** -* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ -* -* Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below). -* -* This program is free software; you can redistribute it and/or modify it under the -* terms of the GNU Lesser General Public License as published by the Free Software -* Foundation; either version 3.0 of the License, or (at your option) any later -* version. -* -* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY -* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License along -* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. -* -*/ - -package org.bigbluebutton.common2.redis.commands; - -import java.util.List; -import java.util.Map; - -import io.lettuce.core.dynamic.Commands; -import io.lettuce.core.dynamic.annotation.Command; - -public interface MeetingCommands extends Commands { - List<String> mget(String... keys); - - @Command("DEL ?0") - Long deleteMeeting(String meetingKey); - - @Command("SREM ?0") - Long deleteMeetings(String meetingsKey); - - @Command("HMSET ?0 ?1") - String recordMeetingInfo(String meetingKey, Map<String, String> values); - - @Command("SADD ?0 ?1") - Long addBreakoutRooms(String parentKey, String breakoutId); -} diff --git a/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/commands/RecordingCommands.java b/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/commands/RecordingCommands.java deleted file mode 100644 index 6ac7786b03936234fb034b13ec14757fe81ef86d..0000000000000000000000000000000000000000 --- a/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/commands/RecordingCommands.java +++ /dev/null @@ -1,40 +0,0 @@ -/** -* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ -* -* Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below). -* -* This program is free software; you can redistribute it and/or modify it under the -* terms of the GNU Lesser General Public License as published by the Free Software -* Foundation; either version 3.0 of the License, or (at your option) any later -* version. -* -* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY -* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License along -* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. -* -*/ - -package org.bigbluebutton.common2.redis.commands; - -import java.util.Map; - -import io.lettuce.core.dynamic.Commands; -import io.lettuce.core.dynamic.annotation.Command; - -public interface RecordingCommands extends Commands { - // Temporary deactivated due to a bug - // @Command("INCR ?0") - // Long incrementRecords(String key); - - @Command("HMSET ?0 ?1") - String recordEventName(String meetingKey, Map<String, String> values); - - @Command("RPUSH ?0 ?1") - Long recordEventValues(String meetingKey, String values); - // Buggy command !! - // @Command("EXPIRE ?0 ?1") - // Boolean expireKey(String key, long seconds); -} diff --git a/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/pubsub/ReceivedMessageHandler.java b/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/pubsub/ReceivedMessageHandler.java index 8fecf05c7f48734e613b93e6dc6db521b3e13c16..818ce20ef70dc41f61b93822ec23b759ea26c303 100755 --- a/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/pubsub/ReceivedMessageHandler.java +++ b/bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/pubsub/ReceivedMessageHandler.java @@ -9,7 +9,7 @@ import org.red5.logging.Red5LoggerFactory; import org.slf4j.Logger; public class ReceivedMessageHandler { - private static Logger log = Red5LoggerFactory.getLogger(ReceivedMessageHandler.class//, "video"); + private static Logger log = Red5LoggerFactory.getLogger(ReceivedMessageHandler.class/*, "video"*/); private BlockingQueue<ReceivedMessage> receivedMessages = new LinkedBlockingQueue<ReceivedMessage>();