Skip to content
This repository has been archived by the owner on Jun 28, 2019. It is now read-only.

added reset all subscriptions functionality #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/src/main/scala/tmt/common/Messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ object Messages {
case class UpdateDelay(serverName: String, value: FiniteDuration)
case class Subscribe(connection: Connection)
case class Unsubscribe(connection: Connection)
case class ResetConnections()
}
9 changes: 5 additions & 4 deletions frontend/app/actors/ConnectionStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import akka.cluster.Cluster
import akka.cluster.ClusterEvent._
import akka.cluster.pubsub.DistributedPubSub
import akka.cluster.pubsub.DistributedPubSubMediator.{Publish, Subscribe}
import akka.persistence.{SnapshotOffer, PersistentActor}
import akka.persistence.{SnapshotSelectionCriteria, SnapshotOffer, PersistentActor}
import tmt.common.Messages
import tmt.shared.Topics
import tmt.shared.models.ConnectionSet
Expand Down Expand Up @@ -34,9 +34,10 @@ class ConnectionStore extends PersistentActor {
}

def receiveCommand = {
case event: Messages.Subscribe => addConnection(event)
case event: Messages.Unsubscribe => removeConnection(event)
case x: MemberUp =>
case event: Messages.Subscribe => addConnection(event)
case event: Messages.Unsubscribe => removeConnection(event)
case event: Messages.ResetConnections => connectionSet = ConnectionSet.empty; deleteSnapshots(SnapshotSelectionCriteria())
case x: MemberUp =>
println("******: ", x)
scheduler.scheduleOnce(2.second, mediator, Publish(Topics.Connections, connectionSet))
case ConnectionStore.GetConnections => sender() ! connectionSet
Expand Down
5 changes: 5 additions & 0 deletions frontend/app/controllers/StreamController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@ class StreamController @Inject()(
clusterClientService.unsubscribe(Connection(serverName, topic))
Accepted("ok")
}

def resetConnections() = Action {
clusterClientService.resetConnections()
Accepted("ok")
}
}
4 changes: 4 additions & 0 deletions frontend/app/services/ClusterClientService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ class ClusterClientService @Inject()(roleIndexService: RoleIndexService)(implici
}

def allConnections = (connectionStore ? ConnectionStore.GetConnections).mapTo[ConnectionSet]

def resetConnections() = {
mediator ! Publish(Topics.Subscription, Messages.ResetConnections())
}
}
1 change: 1 addition & 0 deletions frontend/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ GET /connections controllers.StreamController.conn
POST /:server/throttle/:delay controllers.StreamController.throttle(server, delay: Long)
POST /:server/subscribe/:topic controllers.StreamController.subscribe(server, topic)
POST /:server/unsubscribe/:topic controllers.StreamController.unsubscribe(server, topic)
POST /reset-connections controllers.StreamController.resetConnections

# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)