Merge pull request #2968 from ritzalam/expire-redis-keys-after-14-days
Expire redis keys after 14 days
This commit is contained in:
commit
3273912bd1
@ -27,8 +27,9 @@ public class RedisDispatcher implements Recorder {
|
||||
|
||||
private static final String COLON=":";
|
||||
private JedisPool redisPool;
|
||||
|
||||
public RedisDispatcher(String host, int port, String password) {
|
||||
private int keysExpiresInSec;
|
||||
|
||||
public RedisDispatcher(String host, int port, String password, int keysExpiresInSec) {
|
||||
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
|
||||
config.setMaxTotal(32);
|
||||
config.setMaxIdle(8);
|
||||
@ -41,6 +42,8 @@ public class RedisDispatcher implements Recorder {
|
||||
config.setTimeBetweenEvictionRunsMillis(60000);
|
||||
config.setBlockWhenExhausted(true);
|
||||
|
||||
this.keysExpiresInSec = keysExpiresInSec;
|
||||
|
||||
// Set the name of this client to be able to distinguish when doing
|
||||
// CLIENT LIST on redis-cli
|
||||
redisPool = new JedisPool(config, host, port, Protocol.DEFAULT_TIMEOUT, null,
|
||||
@ -52,8 +55,12 @@ public class RedisDispatcher implements Recorder {
|
||||
Jedis jedis = redisPool.getResource();
|
||||
try {
|
||||
Long msgid = jedis.incr("global:nextRecordedMsgId");
|
||||
jedis.hmset("recording" + COLON + session + COLON + msgid, message.toMap());
|
||||
jedis.rpush("meeting" + COLON + session + COLON + "recordings", msgid.toString());
|
||||
String key = "recording" + COLON + session + COLON + msgid;
|
||||
jedis.hmset(key, message.toMap());
|
||||
jedis.expire(key, keysExpiresInSec);
|
||||
key = "meeting" + COLON + session + COLON + "recordings";
|
||||
jedis.rpush(key, msgid.toString());
|
||||
jedis.expire(key, keysExpiresInSec);
|
||||
} finally {
|
||||
jedis.close();
|
||||
}
|
||||
|
@ -31,4 +31,6 @@ redis {
|
||||
host="127.0.0.1"
|
||||
port=6379
|
||||
password=""
|
||||
# recording keys should expire in 14 days
|
||||
keyExpiry=1209600
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ object Boot extends App with SystemConfiguration {
|
||||
val redisPublisher = new RedisPublisher(system)
|
||||
val msgSender = new MessageSender(redisPublisher)
|
||||
|
||||
val redisDispatcher = new RedisDispatcher(redisHost, redisPort, redisPassword)
|
||||
val redisDispatcher = new RedisDispatcher(redisHost, redisPort, redisPassword, keysExpiresInSec)
|
||||
val recorderApp = new RecorderApplication(redisDispatcher)
|
||||
recorderApp.start()
|
||||
|
||||
|
@ -10,4 +10,5 @@ trait SystemConfiguration {
|
||||
lazy val redisHost = Try(config.getString("redis.host")).getOrElse("127.0.0.1")
|
||||
lazy val redisPort = Try(config.getInt("redis.port")).getOrElse(6379)
|
||||
lazy val redisPassword = Try(config.getString("redis.password")).getOrElse("")
|
||||
lazy val keysExpiresInSec = Try(config.getInt("redis.keyExpiry")).getOrElse(14 * 86400) // 14 days
|
||||
}
|
@ -297,21 +297,30 @@ class RecorderActor(val meetingId: String, val recorder: RecorderApplication)
|
||||
}
|
||||
|
||||
private def handleChangedUserEmojiStatus(msg: UserChangedEmojiStatus) {
|
||||
val status = UserStatusChange(msg.meetingID, msg.recorded,
|
||||
msg.userID, "emojiStatus", msg.emojiStatus)
|
||||
handleUserStatusChange(status)
|
||||
if (msg.recorded) {
|
||||
val status = UserStatusChange(msg.meetingID, msg.recorded,
|
||||
msg.userID, "emojiStatus", msg.emojiStatus)
|
||||
handleUserStatusChange(status)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private def handleUserSharedWebcam(msg: UserSharedWebcam) {
|
||||
val status = UserStatusChange(msg.meetingID, msg.recorded,
|
||||
msg.userID, "hasStream", "true,stream=" + msg.stream)
|
||||
handleUserStatusChange(status)
|
||||
if (msg.recorded) {
|
||||
val status = UserStatusChange(msg.meetingID, msg.recorded,
|
||||
msg.userID, "hasStream", "true,stream=" + msg.stream)
|
||||
handleUserStatusChange(status)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private def handleUserUnsharedWebcam(msg: UserUnsharedWebcam) {
|
||||
val status = UserStatusChange(msg.meetingID, msg.recorded,
|
||||
msg.userID, "hasStream", "false,stream=" + msg.stream)
|
||||
handleUserStatusChange(status)
|
||||
if (msg.recorded) {
|
||||
val status = UserStatusChange(msg.meetingID, msg.recorded,
|
||||
msg.userID, "hasStream", "false,stream=" + msg.stream)
|
||||
handleUserStatusChange(status)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private def handleUserStatusChange(msg: UserStatusChange): Unit = {
|
||||
@ -365,55 +374,64 @@ class RecorderActor(val meetingId: String, val recorder: RecorderApplication)
|
||||
}
|
||||
|
||||
private def handleSendWhiteboardAnnotationEvent(msg: SendWhiteboardAnnotationEvent) {
|
||||
if ((msg.shape.shapeType == WhiteboardKeyUtil.TEXT_TYPE) && (msg.shape.status != WhiteboardKeyUtil.TEXT_CREATED_STATUS)) {
|
||||
if (msg.recorded) {
|
||||
if ((msg.shape.shapeType == WhiteboardKeyUtil.TEXT_TYPE) && (msg.shape.status != WhiteboardKeyUtil.TEXT_CREATED_STATUS)) {
|
||||
|
||||
val event = new ModifyTextWhiteboardRecordEvent()
|
||||
val event = new ModifyTextWhiteboardRecordEvent()
|
||||
event.setMeetingId(msg.meetingID)
|
||||
event.setTimestamp(TimestampGenerator.generateTimestamp)
|
||||
event.setPresentation(getPresentationId(msg.whiteboardId))
|
||||
event.setPageNumber(getPageNum(msg.whiteboardId))
|
||||
event.setWhiteboardId(msg.whiteboardId)
|
||||
event.addAnnotation(mapAsJavaMap(msg.shape.shape))
|
||||
recorder.record(msg.meetingID, event)
|
||||
} else if ((msg.shape.shapeType == WhiteboardKeyUtil.POLL_RESULT_TYPE)) {
|
||||
val event = new AddShapeWhiteboardRecordEvent()
|
||||
event.setMeetingId(msg.meetingID)
|
||||
event.setTimestamp(TimestampGenerator.generateTimestamp)
|
||||
event.setPresentation(getPresentationId(msg.whiteboardId))
|
||||
event.setPageNumber(getPageNum(msg.whiteboardId))
|
||||
event.setWhiteboardId(msg.whiteboardId);
|
||||
event.addAnnotation(mapAsJavaMap(msg.shape.shape))
|
||||
recorder.record(msg.meetingID, event)
|
||||
} else {
|
||||
val event = new AddShapeWhiteboardRecordEvent()
|
||||
event.setMeetingId(msg.meetingID)
|
||||
event.setTimestamp(TimestampGenerator.generateTimestamp)
|
||||
event.setPresentation(getPresentationId(msg.whiteboardId))
|
||||
event.setPageNumber(getPageNum(msg.whiteboardId))
|
||||
event.setWhiteboardId(msg.whiteboardId);
|
||||
event.addAnnotation(mapAsJavaMap(msg.shape.shape))
|
||||
recorder.record(msg.meetingID, event)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private def handleClearWhiteboardEvent(msg: ClearWhiteboardEvent) {
|
||||
if (msg.recorded) {
|
||||
val event = new ClearPageWhiteboardRecordEvent()
|
||||
event.setMeetingId(msg.meetingID)
|
||||
event.setTimestamp(TimestampGenerator.generateTimestamp)
|
||||
event.setPresentation(getPresentationId(msg.whiteboardId))
|
||||
event.setPageNumber(getPageNum(msg.whiteboardId))
|
||||
event.setWhiteboardId(msg.whiteboardId)
|
||||
event.addAnnotation(mapAsJavaMap(msg.shape.shape))
|
||||
recorder.record(msg.meetingID, event)
|
||||
} else if ((msg.shape.shapeType == WhiteboardKeyUtil.POLL_RESULT_TYPE)) {
|
||||
val event = new AddShapeWhiteboardRecordEvent()
|
||||
event.setMeetingId(msg.meetingID)
|
||||
event.setTimestamp(TimestampGenerator.generateTimestamp)
|
||||
event.setPresentation(getPresentationId(msg.whiteboardId))
|
||||
event.setPageNumber(getPageNum(msg.whiteboardId))
|
||||
event.setWhiteboardId(msg.whiteboardId);
|
||||
event.addAnnotation(mapAsJavaMap(msg.shape.shape))
|
||||
recorder.record(msg.meetingID, event)
|
||||
} else {
|
||||
val event = new AddShapeWhiteboardRecordEvent()
|
||||
event.setMeetingId(msg.meetingID)
|
||||
event.setTimestamp(TimestampGenerator.generateTimestamp)
|
||||
event.setPresentation(getPresentationId(msg.whiteboardId))
|
||||
event.setPageNumber(getPageNum(msg.whiteboardId))
|
||||
event.setWhiteboardId(msg.whiteboardId);
|
||||
event.addAnnotation(mapAsJavaMap(msg.shape.shape))
|
||||
recorder.record(msg.meetingID, event)
|
||||
}
|
||||
}
|
||||
|
||||
private def handleClearWhiteboardEvent(msg: ClearWhiteboardEvent) {
|
||||
val event = new ClearPageWhiteboardRecordEvent()
|
||||
event.setMeetingId(msg.meetingID)
|
||||
event.setTimestamp(TimestampGenerator.generateTimestamp)
|
||||
event.setPresentation(getPresentationId(msg.whiteboardId))
|
||||
event.setPageNumber(getPageNum(msg.whiteboardId))
|
||||
event.setWhiteboardId(msg.whiteboardId)
|
||||
recorder.record(msg.meetingID, event)
|
||||
}
|
||||
|
||||
private def handleUndoWhiteboardEvent(msg: UndoWhiteboardEvent) {
|
||||
val event = new UndoShapeWhiteboardRecordEvent()
|
||||
event.setMeetingId(msg.meetingID)
|
||||
event.setTimestamp(TimestampGenerator.generateTimestamp)
|
||||
event.setPresentation(getPresentationId(msg.whiteboardId))
|
||||
event.setPageNumber(getPageNum(msg.whiteboardId))
|
||||
event.setWhiteboardId(msg.whiteboardId)
|
||||
event.setShapeId(msg.shapeId);
|
||||
recorder.record(msg.meetingID, event)
|
||||
if (msg.recorded) {
|
||||
val event = new UndoShapeWhiteboardRecordEvent()
|
||||
event.setMeetingId(msg.meetingID)
|
||||
event.setTimestamp(TimestampGenerator.generateTimestamp)
|
||||
event.setPresentation(getPresentationId(msg.whiteboardId))
|
||||
event.setPageNumber(getPageNum(msg.whiteboardId))
|
||||
event.setWhiteboardId(msg.whiteboardId)
|
||||
event.setShapeId(msg.shapeId);
|
||||
recorder.record(msg.meetingID, event)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -28,10 +28,12 @@ public class EventRecordingService {
|
||||
|
||||
private final String host;
|
||||
private final int port;
|
||||
private final int keyExpiry;
|
||||
|
||||
public EventRecordingService(String host, int port) {
|
||||
public EventRecordingService(String host, int port, int keyExpiry) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.keyExpiry = keyExpiry;
|
||||
}
|
||||
|
||||
public void record(String meetingId, Map<String, String> event) {
|
||||
@ -44,9 +46,9 @@ public class EventRecordingService {
|
||||
* recording the event into redis even if the meeting is not
|
||||
* recorded. (ralam sept 23, 2015)
|
||||
*/
|
||||
jedis.expire(key, 14*24*60*60 /*14days*/);
|
||||
jedis.expire(key, keyExpiry);
|
||||
key = "meeting:" + meetingId + COLON + "recordings";
|
||||
jedis.rpush(key, msgid.toString());
|
||||
jedis.expire(key, 14*24*60*60 /*14days*/);
|
||||
jedis.expire(key, keyExpiry);
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1,4 @@
|
||||
redis.host=127.0.0.1
|
||||
redis.port=6379
|
||||
# recording keys should expire in 14 days
|
||||
redis.keyExpiry=1209600
|
||||
|
@ -59,6 +59,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
<bean id="redisRecorder" class="org.bigbluebutton.app.video.EventRecordingService">
|
||||
<constructor-arg index="0" value="${redis.host}"/>
|
||||
<constructor-arg index="1" value="${redis.port}"/>
|
||||
<constructor-arg index="2" value="${redis.keyExpiry}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="redisSender" class="org.bigbluebutton.red5.pubsub.MessageSender"
|
||||
|
@ -30,10 +30,12 @@ public class EventRecorder implements RecordStatusListener {
|
||||
private static final String COLON=":";
|
||||
private String host;
|
||||
private int port;
|
||||
|
||||
public EventRecorder(String host, int port){
|
||||
private final int keyExpiry;
|
||||
|
||||
public EventRecorder(String host, int port, int keyExpiry){
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.keyExpiry = keyExpiry;
|
||||
}
|
||||
|
||||
private Long genTimestamp() {
|
||||
@ -50,10 +52,10 @@ public class EventRecorder implements RecordStatusListener {
|
||||
* recording the event into redis even if the meeting is not
|
||||
* recorded. (ralam sept 23, 2015)
|
||||
*/
|
||||
jedis.expire(key, 14*24*60*60 /*14days*/);
|
||||
jedis.expire(key, keyExpiry);
|
||||
key = "meeting" + COLON + session + COLON + "recordings";
|
||||
jedis.rpush(key, msgid.toString());
|
||||
jedis.expire(key, 14*24*60*60 /*14days*/);
|
||||
jedis.expire(key, keyExpiry);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,7 +13,8 @@ recordingDirectory=/var/bigbluebutton/deskshare
|
||||
|
||||
redis.host=127.0.0.1
|
||||
redis.port=6379
|
||||
|
||||
# recording keys should expire in 14 days
|
||||
redis.keyExpiry=1209600
|
||||
|
||||
serverPort = 9123
|
||||
|
||||
|
@ -69,5 +69,6 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
<bean id="redisRecorder" class="org.bigbluebutton.deskshare.server.recorder.EventRecorder">
|
||||
<constructor-arg index="0" value="${redis.host}"/>
|
||||
<constructor-arg index="1" value="${redis.port}"/>
|
||||
<constructor-arg index="2" value="${redis.keyExpiry}"/>
|
||||
</bean>
|
||||
</beans>
|
||||
|
Loading…
Reference in New Issue
Block a user