Skip to content

Commit 52e2ecc

Browse files
committed
Query dispatcher
1 parent 6935dd8 commit 52e2ecc

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

publication/src/test/scala/hmda/publication/reports/ReportGenerators.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package hmda.publication.reports
22

33
import hmda.model.census.Census
4-
import hmda.model.publication.reports.MinorityStatusEnum.WhiteNonHispanic
54
import hmda.model.publication.reports._
65
import org.scalacheck.Gen
76

query/src/main/resources/application.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,20 @@ cassandra {
7575
retries = 60
7676
retry-interval = 1000
7777
}
78+
79+
query-dispatcher {
80+
type = Dispatcher
81+
executor = "fork-join-executor"
82+
fork-join-executor {
83+
# Min number of threads to cap factor-based parallelism number to
84+
parallelism-min = 2
85+
# Parallelism (threads) ... ceil(available processors * factor)
86+
parallelism-factor = 2.0
87+
# Max number of threads to cap factor-based parallelism number to
88+
parallelism-max = 10
89+
}
90+
# Throughput defines the maximum number of messages to be
91+
# processed per actor before the thread jumps to the next actor.
92+
# Set to 1 for as fair as possible.
93+
throughput = 100
94+
}

query/src/main/scala/hmda/query/HmdaQuerySupervisor.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class HmdaQuerySupervisor extends HmdaSupervisorActor {
3939

4040
override protected def createActor(name: String): ActorRef = name match {
4141
case id @ InstitutionView.name =>
42-
val actor = context.actorOf(InstitutionView.props(), id)
42+
val actor = context.actorOf(InstitutionView.props().withDispatcher("query-dispatcher"), id)
4343
supervise(actor, id)
4444
}
4545

@@ -49,7 +49,7 @@ class HmdaQuerySupervisor extends HmdaSupervisorActor {
4949

5050
private def createHmdaFilingView(period: String)(implicit ec: ExecutionContext): ActorRef = {
5151
val id = s"${HmdaFilingView.name}-$period"
52-
val actor = context.actorOf(HmdaFilingView.props(period), id)
52+
val actor = context.actorOf(HmdaFilingView.props(period).withDispatcher("query-dispatcher"), id)
5353
for {
5454
p <- (actor ? GetProjectionActorRef).mapTo[ActorRef]
5555
} yield {

query/src/main/scala/hmda/query/view/filing/HmdaFilingView.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ class HmdaFilingView(period: String) extends HmdaPersistentActor {
4141

4242
var counter = 0
4343

44-
val queryProjector = context.actorOf(HmdaFilingDBProjection.props(period), "queryProjector")
44+
val queryProjector = context
45+
.actorOf(HmdaFilingDBProjection.props(period)
46+
.withDispatcher("query-dispatcher"), "queryProjector")
4547

4648
val conf = ConfigFactory.load()
4749
val snapshotCounter = conf.getInt("hmda.journal.snapshot.counter")

query/src/main/scala/hmda/query/view/institutions/InstitutionView.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ class InstitutionView extends HmdaPersistentActor {
5050

5151
var counter = 0
5252

53-
val queryProjector = context.actorOf(InstitutionDBProjection.props(), "institution-projection")
53+
val queryProjector = context
54+
.actorOf(InstitutionDBProjection.props()
55+
.withDispatcher("query-dispatcher"), "institution-projection")
5456

5557
val snapshotCounter = configuration.getInt("hmda.journal.snapshot.counter")
5658

0 commit comments

Comments
 (0)