From 0efeee1a846c1f2fcc1b4fa68d172f3fd7f291db Mon Sep 17 00:00:00 2001 From: Sylvain Pendino Date: Mon, 1 Apr 2019 16:46:13 +0200 Subject: [PATCH] Public executor (#387) * Change executor's methods visibility We need to be able to access the executor's running executions from outside of cuttle's scope --- build.sbt | 4 +++- .../scala/com/criteo/cuttle/Executor.scala | 18 +++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/build.sbt b/build.sbt index 583593dbc..144f93a68 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,9 @@ val devMode = settingKey[Boolean]("Some build optimization are applied in devMode.") val writeClasspath = taskKey[File]("Write the project classpath to a file.") -val VERSION = "0.9.3" + +val VERSION = "0.9.4" + lazy val catsCore = "1.5.0" lazy val circe = "0.10.1" diff --git a/core/src/main/scala/com/criteo/cuttle/Executor.scala b/core/src/main/scala/com/criteo/cuttle/Executor.scala index 233743ba3..528c8037a 100755 --- a/core/src/main/scala/com/criteo/cuttle/Executor.scala +++ b/core/src/main/scala/com/criteo/cuttle/Executor.scala @@ -480,7 +480,7 @@ class Executor[S <: Scheduling] ( } } - private[cuttle] def allRunning: Seq[ExecutionLog] = + def allRunning: Seq[ExecutionLog] = flagWaitingExecutions(runningState.single.keys.toSeq).map { case (execution, status) => execution.toExecutionLog(status) @@ -489,18 +489,18 @@ class Executor[S <: Scheduling] ( private[cuttle] def jobStatsForLastThirtyDays(jobId: String): IO[Seq[ExecutionStat]] = queries.jobStatsForLastThirtyDays(jobId).transact(xa) - private[cuttle] def runningExecutions: Seq[(Execution[S], ExecutionStatus)] = + def runningExecutions: Seq[(Execution[S], ExecutionStatus)] = flagWaitingExecutions(runningState.single.keys.toSeq) - private[cuttle] def runningExecutionsSizeTotal(filteredJobs: Set[String]): Int = + def runningExecutionsSizeTotal(filteredJobs: Set[String]): Int = runningState.single.keys.count(e => filteredJobs.contains(e.job.id)) - private[cuttle] def runningExecutionsSizes(filteredJobs: Set[String]): (Int, Int) = { + def runningExecutionsSizes(filteredJobs: Set[String]): (Int, Int) = { val statuses = flagWaitingExecutions(runningState.single.keys.toSeq.filter(e => filteredJobs.contains(e.job.id))).map(_._2) (statuses.count(_ == ExecutionRunning), statuses.count(_ == ExecutionWaiting)) } - private[cuttle] def runningExecutions(filteredJobs: Set[String], + def runningExecutions(filteredJobs: Set[String], sort: String, asc: Boolean, offset: Int, @@ -524,19 +524,19 @@ class Executor[S <: Scheduling] ( execution.toExecutionLog(status) }) - private[cuttle] def allFailingExecutions: Seq[Execution[S]] = + def allFailingExecutions: Seq[Execution[S]] = throttledState.single.keys.toSeq - private[cuttle] def allFailingJobsWithContext: Set[(Job[S], S#Context)] = + def allFailingJobsWithContext: Set[(Job[S], S#Context)] = allFailingExecutions.map(e => (e.job, e.context)).toSet // Count as failing all jobs that have failed and are not running (throttledState) // and all jobs that have recently failed and are now running. - private[cuttle] def failingExecutionsSize(filteredJobs: Set[String]): Int = + def failingExecutionsSize(filteredJobs: Set[String]): Int = throttledState.single.keys.filter(e => filteredJobs.contains(e.job.id)).size + retryingExecutionsSize(filteredJobs) - private[cuttle] def failingExecutions(filteredJobs: Set[String], + def failingExecutions(filteredJobs: Set[String], sort: String, asc: Boolean, offset: Int,