Skip to content

Commit

Permalink
#1398 Use a dedicated threadpool for MISP synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Aug 11, 2020
1 parent c74d753 commit a320572
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion thehive-misp/app/connectors/misp/MispSynchro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ class MispSynchro @Inject()(
tempSrv: TempSrv,
lifecycle: ApplicationLifecycle,
system: ActorSystem,
implicit val ec: ExecutionContext,
implicit val mat: Materializer
) {

private[misp] lazy val logger = Logger(getClass)
private[misp] lazy val alertSrv = alertSrvProvider.get
implicit val ec: ExecutionContext = try {
system.dispatchers.lookup("misp-thread-pools")
} catch {
case e: Throwable =>
logger.warn(s"Unable to use MISP specific dispatcher ($e). Fallback to default dispatcher")
system.dispatcher
}

private[misp] def initScheduler(): Unit = {
val task = system.scheduler.scheduleWithFixedDelay(0.seconds, mispConfig.interval) {() =>
Expand Down
11 changes: 11 additions & 0 deletions thehive-misp/conf/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ misp {
# Interval between two MISP event import
interval = 1h
}

misp-thread-pool {
fork-join-executor {
# Min number of threads available for MISP synchronization
parallelism-min = 2
# Parallelism (threads) ... ceil(available processors * factor)
parallelism-factor = 2.0
# Max number of threads available for MISP synchronization
parallelism-max = 4
}
}

0 comments on commit a320572

Please sign in to comment.