forked from bigbluebutton/bigbluebutton
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove rediscala library and replace it by a lettuce implementation.
- Loading branch information
1 parent
7e736d4
commit fd959f9
Showing
40 changed files
with
388 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 16 additions & 49 deletions
65
...b-apps/src/main/scala/org/bigbluebutton/endpoint/redis/AkkaAppsRedisSubscriberActor.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,32 @@ | ||
package org.bigbluebutton.endpoint.redis | ||
|
||
import java.net.InetSocketAddress | ||
|
||
import org.bigbluebutton.SystemConfiguration | ||
import org.bigbluebutton.common2.bus.IncomingJsonMessage | ||
import org.bigbluebutton.common2.bus.IncomingJsonMessageBus | ||
import org.bigbluebutton.common2.bus.ReceivedJsonMessage | ||
import org.bigbluebutton.common2.redis.RedisAppSubscriberActor | ||
import org.bigbluebutton.common2.redis.RedisConfiguration | ||
import org.bigbluebutton.common2.redis.RedisSubscriber | ||
import org.bigbluebutton.common2.redis.{ RedisSubscriber, RedisSubscriberProvider } | ||
|
||
import akka.actor.ActorSystem | ||
import akka.actor.Props | ||
import redis.actors.RedisSubscriberActor | ||
import redis.api.pubsub.Message | ||
import redis.api.servers.ClientSetname | ||
import java.io.StringWriter | ||
import akka.actor.OneForOneStrategy | ||
import akka.actor.SupervisorStrategy.Resume | ||
import scala.concurrent.duration.DurationInt | ||
import java.io.PrintWriter | ||
|
||
object AppsRedisSubscriberActor extends RedisSubscriber with RedisConfiguration { | ||
object AppsRedisSubscriberActor extends RedisSubscriber { | ||
|
||
val channels = Seq(toAkkaAppsRedisChannel, fromVoiceConfRedisChannel) | ||
val patterns = Seq("bigbluebutton:to-bbb-apps:*", "bigbluebutton:from-voice-conf:*", "bigbluebutton:from-bbb-transcode:*") | ||
|
||
def props(jsonMsgBus: IncomingJsonMessageBus): Props = | ||
Props(classOf[AppsRedisSubscriberActor], jsonMsgBus, | ||
def props(system: ActorSystem, jsonMsgBus: IncomingJsonMessageBus): Props = | ||
Props( | ||
classOf[AppsRedisSubscriberActor], | ||
system, jsonMsgBus, | ||
redisHost, redisPort, | ||
channels, patterns).withDispatcher("akka.rediscala-subscriber-worker-dispatcher") | ||
channels, patterns).withDispatcher("akka.redis-subscriber-worker-dispatcher") | ||
} | ||
|
||
class AppsRedisSubscriberActor(jsonMsgBus: IncomingJsonMessageBus, redisHost: String, | ||
redisPort: Int, | ||
channels: Seq[String] = Nil, patterns: Seq[String] = Nil) | ||
extends RedisSubscriberActor( | ||
new InetSocketAddress(redisHost, redisPort), | ||
channels, patterns, onConnectStatus = connected => { println(s"connected: $connected") }) | ||
with SystemConfiguration | ||
with RedisAppSubscriberActor { | ||
|
||
override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) { | ||
case e: Exception => { | ||
val sw: StringWriter = new StringWriter() | ||
sw.write("An exception has been thrown on AppsRedisSubscriberActor, exception message [" + e.getMessage() + "] (full stacktrace below)\n") | ||
e.printStackTrace(new PrintWriter(sw)) | ||
log.error(sw.toString()) | ||
Resume | ||
} | ||
} | ||
|
||
// Set the name of this client to be able to distinguish when doing | ||
// CLIENT LIST on redis-cli | ||
write(ClientSetname("BbbAppsAkkaSub").encodedRequest) | ||
|
||
def onMessage(message: Message) { | ||
if (message.channel == toAkkaAppsRedisChannel || message.channel == fromVoiceConfRedisChannel) { | ||
val receivedJsonMessage = new ReceivedJsonMessage(message.channel, message.data.utf8String) | ||
//log.debug(s"RECEIVED:\n [${receivedJsonMessage.channel}] \n ${receivedJsonMessage.data} \n") | ||
jsonMsgBus.publish(IncomingJsonMessage(toAkkaAppsJsonChannel, receivedJsonMessage)) | ||
} | ||
} | ||
class AppsRedisSubscriberActor( | ||
system: ActorSystem, | ||
jsonMsgBus: IncomingJsonMessageBus, | ||
redisHost: String, redisPort: Int, | ||
channels: Seq[String] = Nil, patterns: Seq[String] = Nil) | ||
extends RedisSubscriberProvider(system, "BbbAppsAkkaSub", channels, patterns, jsonMsgBus) with SystemConfiguration { | ||
|
||
addListener(toAkkaAppsJsonChannel) | ||
subscribe() | ||
} |
Oops, something went wrong.