Skip to content
Snippets Groups Projects
Commit de0c992e authored by Ghazi Triki's avatar Ghazi Triki
Browse files

Update redis commands implementation.

parent fbd1d631
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
}
/**
* 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);
}
/**
* 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);
}
......@@ -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>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment