Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fairblue
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hosting
chat
fairblue
Commits
c9791b32
Commit
c9791b32
authored
6 years ago
by
Ghazi Triki
Browse files
Options
Downloads
Patches
Plain Diff
Use single connection for RedisStorageService instead of connection pool.
parent
79d34c42
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/RedisStorageService.java
+31
-49
31 additions, 49 deletions
.../org/bigbluebutton/common2/redis/RedisStorageService.java
with
31 additions
and
49 deletions
bbb-common-message/src/main/java/org/bigbluebutton/common2/redis/RedisStorageService.java
+
31
−
49
View file @
c9791b32
...
@@ -21,7 +21,6 @@ package org.bigbluebutton.common2.redis;
...
@@ -21,7 +21,6 @@ package org.bigbluebutton.common2.redis;
import
java.util.Map
;
import
java.util.Map
;
import
org.apache.commons.pool2.impl.GenericObjectPool
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -30,13 +29,12 @@ import io.lettuce.core.RedisClient;
...
@@ -30,13 +29,12 @@ import io.lettuce.core.RedisClient;
import
io.lettuce.core.RedisURI
;
import
io.lettuce.core.RedisURI
;
import
io.lettuce.core.api.StatefulRedisConnection
;
import
io.lettuce.core.api.StatefulRedisConnection
;
import
io.lettuce.core.api.sync.RedisCommands
;
import
io.lettuce.core.api.sync.RedisCommands
;
import
io.lettuce.core.support.ConnectionPoolSupport
;
public
class
RedisStorageService
extends
RedisAwareCommunicator
{
public
class
RedisStorageService
extends
RedisAwareCommunicator
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
RedisStorageService
.
class
);
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
RedisStorageService
.
class
);
GenericObjectPool
<
StatefulRedisConnection
<
String
,
String
>
>
connection
Pool
;
StatefulRedisConnection
<
String
,
String
>
connection
;
public
void
start
()
{
public
void
start
()
{
log
.
info
(
"Starting RedisStorageService with client name: {}"
,
clientName
);
log
.
info
(
"Starting RedisStorageService with client name: {}"
,
clientName
);
...
@@ -46,12 +44,11 @@ public class RedisStorageService extends RedisAwareCommunicator {
...
@@ -46,12 +44,11 @@ public class RedisStorageService extends RedisAwareCommunicator {
redisClient
=
RedisClient
.
create
(
redisUri
);
redisClient
=
RedisClient
.
create
(
redisUri
);
redisClient
.
setOptions
(
ClientOptions
.
builder
().
autoReconnect
(
true
).
build
());
redisClient
.
setOptions
(
ClientOptions
.
builder
().
autoReconnect
(
true
).
build
());
connectionPool
=
ConnectionPoolSupport
.
createGenericObjectPool
(()
->
redisClient
.
connect
(),
connection
=
redisClient
.
connect
();
createPoolingConfig
());
}
}
public
void
stop
()
{
public
void
stop
()
{
connection
Pool
.
close
();
connection
.
close
();
redisClient
.
shutdown
();
redisClient
.
shutdown
();
log
.
info
(
"RedisStorageService Stopped"
);
log
.
info
(
"RedisStorageService Stopped"
);
}
}
...
@@ -68,67 +65,52 @@ public class RedisStorageService extends RedisAwareCommunicator {
...
@@ -68,67 +65,52 @@ public class RedisStorageService extends RedisAwareCommunicator {
public
void
addBreakoutRoom
(
String
parentId
,
String
breakoutId
)
{
public
void
addBreakoutRoom
(
String
parentId
,
String
breakoutId
)
{
log
.
debug
(
"Saving breakout room for meeting {}"
,
parentId
);
log
.
debug
(
"Saving breakout room for meeting {}"
,
parentId
);
try
(
StatefulRedisConnection
<
String
,
String
>
connection
=
connectionPool
.
borrowObject
())
{
RedisCommands
<
String
,
String
>
commands
=
connection
.
sync
();
RedisCommands
<
String
,
String
>
commands
=
connection
.
sync
();
commands
.
sadd
(
Keys
.
BREAKOUT_ROOMS
+
parentId
,
breakoutId
);
commands
.
sadd
(
Keys
.
BREAKOUT_ROOMS
+
parentId
,
breakoutId
);
connection
.
close
();
}
catch
(
Exception
e
)
{
log
.
error
(
"Cannot add breakout room data: {}"
,
parentId
,
e
);
}
}
}
public
void
record
(
String
meetingId
,
Map
<
String
,
String
>
event
)
{
public
void
record
(
String
meetingId
,
Map
<
String
,
String
>
event
)
{
log
.
debug
(
"Recording meeting event {} inside a transaction"
,
meetingId
);
log
.
debug
(
"Recording meeting event {} inside a transaction"
,
meetingId
);
try
(
StatefulRedisConnection
<
String
,
String
>
connection
=
connectionPool
.
borrowObject
())
{
RedisCommands
<
String
,
String
>
commands
=
connection
.
sync
();
RedisCommands
<
String
,
String
>
commands
=
connection
.
sync
();
Long
msgid
=
commands
.
incr
(
"global:nextRecordedMsgId"
);
Long
msgid
=
commands
.
incr
(
"global:nextRecordedMsgId"
);
commands
.
hmset
(
"recording:"
+
meetingId
+
":"
+
msgid
,
event
);
commands
.
hmset
(
"recording:"
+
meetingId
+
":"
+
msgid
,
event
);
commands
.
rpush
(
"meeting:"
+
meetingId
+
":"
+
"recordings"
,
Long
.
toString
(
msgid
));
commands
.
rpush
(
"meeting:"
+
meetingId
+
":"
+
"recordings"
,
Long
.
toString
(
msgid
));
connection
.
close
();
}
catch
(
Exception
e
)
{
log
.
debug
(
"Cannot record meeting data: {}"
,
meetingId
,
e
);
}
}
}
// @fixme: not used anywhere
// @fixme: not used anywhere
public
void
removeMeeting
(
String
meetingId
)
{
public
void
removeMeeting
(
String
meetingId
)
{
log
.
debug
(
"Removing meeting meeting {} inside a transaction"
,
meetingId
);
log
.
debug
(
"Removing meeting meeting {} inside a transaction"
,
meetingId
);
try
(
StatefulRedisConnection
<
String
,
String
>
connection
=
connectionPool
.
borrowObject
())
{
RedisCommands
<
String
,
String
>
commands
=
connection
.
sync
();
RedisCommands
<
String
,
String
>
commands
=
connection
.
sync
();
commands
.
del
(
Keys
.
MEETING
+
meetingId
);
commands
.
del
(
Keys
.
MEETING
+
meetingId
);
commands
.
srem
(
Keys
.
MEETINGS
+
meetingId
);
commands
.
srem
(
Keys
.
MEETINGS
+
meetingId
);
connection
.
close
();
}
catch
(
Exception
e
)
{
log
.
debug
(
"Cannot remove meeting data : {}"
,
meetingId
,
e
);
}
}
}
public
void
recordAndExpire
(
String
meetingId
,
Map
<
String
,
String
>
event
)
{
public
void
recordAndExpire
(
String
meetingId
,
Map
<
String
,
String
>
event
)
{
log
.
debug
(
"Recording meeting event {} inside a transaction"
,
meetingId
);
log
.
debug
(
"Recording meeting event {} inside a transaction"
,
meetingId
);
try
(
StatefulRedisConnection
<
String
,
String
>
connection
=
connectionPool
.
borrowObject
())
{
RedisCommands
<
String
,
String
>
commands
=
connection
.
sync
();
RedisCommands
<
String
,
String
>
commands
=
connection
.
sync
();
Long
msgid
=
commands
.
incr
(
"global:nextRecordedMsgId"
);
Long
msgid
=
commands
.
incr
(
"global:nextRecordedMsgId"
);
commands
.
hmset
(
"recording:"
+
meetingId
+
":"
+
msgid
,
event
);
commands
.
hmset
(
"recording:"
+
meetingId
+
":"
+
msgid
,
event
);
/**
/**
* We set the key to expire after 14 days as we are still recording the
* We set the key to expire after 14 days as we are still recording
* event into redis even if the meeting is not recorded. (ralam sept 23,
* the event into redis even if the meeting is not recorded. (ralam
* 2015)
* sept 23, 2015)
*/
*/
commands
.
expire
(
"meeting:"
+
meetingId
+
":recordings"
,
expireKey
);
commands
.
expire
(
"meeting:"
+
meetingId
+
":recordings"
,
expireKey
);
commands
.
rpush
(
"meeting:"
+
meetingId
+
":recordings"
,
Long
.
toString
(
msgid
));
commands
.
rpush
(
"meeting:"
+
meetingId
+
":recordings"
,
Long
.
toString
(
msgid
));
commands
.
expire
(
"meeting:"
+
meetingId
+
":recordings"
,
expireKey
);
commands
.
expire
(
"meeting:"
+
meetingId
+
":recordings"
,
expireKey
);
connection
.
close
();
}
catch
(
Exception
e
)
{
log
.
error
(
"Cannot record data with expire: {}"
,
meetingId
,
e
);
}
}
}
private
String
recordMeeting
(
String
key
,
Map
<
String
,
String
>
info
)
{
private
String
recordMeeting
(
String
key
,
Map
<
String
,
String
>
info
)
{
log
.
debug
(
"Storing metadata {}"
,
info
);
log
.
debug
(
"Storing metadata {}"
,
info
);
String
result
=
""
;
String
result
=
""
;
try
(
StatefulRedisConnection
<
String
,
String
>
connection
=
connectionPool
.
borrowObject
())
{
RedisCommands
<
String
,
String
>
commands
=
connection
.
sync
();
RedisCommands
<
String
,
String
>
commands
=
connection
.
sync
();
result
=
commands
.
hmset
(
key
,
info
);
result
=
commands
.
hmset
(
key
,
info
);
connection
.
close
();
}
catch
(
Exception
e
)
{
log
.
debug
(
"Cannot record data with expire: {}"
,
key
,
e
);
}
return
result
;
return
result
;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment