Created
May 17, 2019 15:44
-
-
Save chbatey/4be580aa11a468b7191ac2ce526488f0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import akka.actor.{ ActorSystem, PoisonPill } | |
import akka.util.Timeout | |
import com.datastax.driver.core.Cluster | |
import com.typesafe.config.ConfigFactory | |
import scala.concurrent.duration._ | |
import scala.collection.JavaConverters._ | |
import scala.io.StdIn | |
object Sandbox extends App { | |
val system = ActorSystem( | |
"pants", | |
ConfigFactory.parseString(""" | |
akka.loglevel = DEBUG | |
akka.persistence.journal.plugin = "cassandra-journal" | |
akka.persistence.snapshot-store.plugin = "cassandra-snapshot-store" | |
""".stripMargin)) | |
implicit val timeout = Timeout(101.second) | |
lazy val cluster = Cluster.builder().addContactPoint("localhost").build() | |
lazy val session = cluster.connect("akka") | |
val pa = system.actorOf(TestTaggingActor.props("p1", Set("cat", "dog"))) | |
import akka.persistence.cassandra.TestTaggingActor.Ack | |
import akka.persistence.cassandra.TestTaggingActor.{ DoASnapshotPlease, SnapShotAck } | |
import akka.pattern.ask | |
import scala.concurrent.Await | |
Await.result((pa ? "one").mapTo[Ack.type], 100.second) | |
Await.result((pa ? "two").mapTo[Ack.type], 100.second) | |
Await.result((pa ? DoASnapshotPlease).mapTo[SnapShotAck.type], 100.second) | |
Await.result((pa ? "three").mapTo[Ack.type], 100.second) | |
pa ! PoisonPill | |
println("Press enter to truncate the tag view tables") | |
StdIn.readLine() | |
session.execute("truncate tag_views") | |
session.execute("truncate tag_write_progress") | |
session.execute("truncate tag_scanning") | |
println("Tag views rows:") | |
session.execute("select * from tag_views").asScala.foreach(println) | |
println("Press enter to start actor again") | |
StdIn.readLine() | |
system.actorOf(TestTaggingActor.props("p1", Set("cat", "dog"))) | |
println("Press enter to see tag views after starting actor") | |
StdIn.readLine() | |
session.execute("select * from tag_views").asScala.foreach(println) | |
system.terminate() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment