Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings + build for scala 2.12 #173

Merged
merged 3 commits into from
Sep 27, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 9 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ lazy val commonSettings = Seq(
"-Xfuture",
"-Ywarn-unused",
"-Ywarn-unused-import"
),
) ++ (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => Nil
Seq(
"-Ywarn-unused:-params"
)
case _ =>
Nil
}),
devMode := Option(System.getProperty("devMode")).isDefined,
writeClasspath := {
val f = file(s"/tmp/classpath_${organization.value}.${name.value}")
Expand Down Expand Up @@ -148,7 +155,7 @@ lazy val cuttle =
libraryDependencies ++= Seq(
"de.sciss" %% "fingertree" % "1.5.2",
"org.scala-stm" %% "scala-stm" % "0.8",
"org.scala-lang" % "scala-reflect" % "2.11.9",
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.typelevel" %% "cats" % "0.9.0",
"codes.reactive" %% "scala-time" % "0.4.1",
"com.zaxxer" % "nuprocess" % "1.1.0"
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/com/criteo/cuttle/App.scala
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private[cuttle] case class App[S <: Scheduling](project: CuttleProject[S], execu
}
events match {
case "true" | "yes" =>
sse(getStats, asJson)
sse(getStats _, asJson)
case _ =>
Ok(asJson(getStats().get))
}
Expand Down Expand Up @@ -228,7 +228,7 @@ private[cuttle] case class App[S <: Scheduling](project: CuttleProject[S], execu
}
events match {
case "true" | "yes" =>
sse(getExecutions, asJson)
sse(getExecutions _, asJson)
case _ =>
getExecutions().map(e => Ok(asJson(e))).getOrElse(NotFound)
}
Expand All @@ -237,7 +237,7 @@ private[cuttle] case class App[S <: Scheduling](project: CuttleProject[S], execu
def getExecution() = executor.getExecution(scheduler.allContexts, id)
events match {
case "true" | "yes" =>
sse(getExecution, (e: ExecutionLog) => e.asJson)
sse(getExecution _, (e: ExecutionLog) => e.asJson)
case _ =>
getExecution().map(e => Ok(e.asJson)).getOrElse(NotFound)
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/com/criteo/cuttle/Database.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private[cuttle] object Database {
)

implicit val ExecutionStatusMeta: Meta[ExecutionStatus] = Meta[Boolean].xmap(
x => if (x != null && x) ExecutionSuccessful else ExecutionFailed,
x => if (x) ExecutionSuccessful else ExecutionFailed,
x =>
x match {
case ExecutionSuccessful => true
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/com/criteo/cuttle/Executor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ class Executor[S <: Scheduling] private[cuttle] (
toCancel.foreach(_.cancel())

val runningFutures = atomic { implicit tx =>
runningState.map({ case (k, v) => v })
runningState.map({ case (_, v) => v })
}

Future
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private[cuttle] trait WaitingExecutionQueue {
}

maybeToRun.foreach {
case entry @ (execution, DelayedResult(effect, _, promise, _, _)) =>
case entry @ (_, DelayedResult(effect, _, promise, _, _)) =>
val effectResult = try {
effect()
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ case class HttpPlatform(maxConcurrentRequests: Int, rateLimits: Seq[(String, Htt
))
}
rateLimiters.zipWithIndex.foldLeft(index) {
case (routes, ((pattern, rateLimiter), i)) =>
case (routes, ((_, rateLimiter), i)) =>
routes.orElse(rateLimiter.routes(s"/api/platforms/http/rate-limiters/$i"))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private[timeseries] object Database {
val stateJson = state.toList.map {
case (job, im) =>
(job.id, im.toList.filter {
case (interval, jobState) =>
case (_, jobState) =>
jobState match {
case Done => true
case Todo(_) => true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private[timeseries] trait TimeSeriesApp { self: TimeSeriesScheduler =>
}

if (request.headers.get(h"Accept").exists(_ == h"text/event-stream"))
sse(watchState, getExecutions)
sse(watchState _, getExecutions)
else
Ok(getExecutions())

Expand Down Expand Up @@ -211,7 +211,7 @@ private[timeseries] trait TimeSeriesApp { self: TimeSeriesScheduler =>
.nonEmpty)
if (gridView.aggregationFactor == 1)
jobStatesOnIntervals match {
case (executionInterval, state) :: Nil =>
case (_, state) :: Nil =>
Some(JobExecution(interval, getStatusLabelFromState(state), inBackfill))
case _ => None
} else
Expand Down Expand Up @@ -275,7 +275,7 @@ private[timeseries] trait TimeSeriesApp { self: TimeSeriesScheduler =>
}

if (request.headers.get(h"Accept").exists(_ == h"text/event-stream"))
sse(watchState, getFocusView)
sse(watchState _, getFocusView)
else
Ok(getFocusView())

Expand Down Expand Up @@ -335,7 +335,7 @@ private[timeseries] trait TimeSeriesApp { self: TimeSeriesScheduler =>
}

if (request.headers.get(h"Accept").exists(_ == h"text/event-stream"))
sse(watchState, getCalendar)
sse(watchState _, getCalendar)
else
Ok(getCalendar())

Expand Down Expand Up @@ -422,7 +422,7 @@ private[timeseries] trait TimeSeriesApp { self: TimeSeriesScheduler =>
}
events match {
case "true" | "yes" =>
sse(allExecutions, asTotalJson)
sse(allExecutions _, asTotalJson)
case _ =>
allExecutions().map(e => Ok(asTotalJson(e))).getOrElse(NotFound)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ sealed trait TimeSeriesGrid {
interval match {
case Interval(Finite(lo), Finite(hi)) =>
go(ceil(lo), hi).grouped(maxPeriods).map(xs => (xs.head._1, xs.last._2))
case _ =>
sys.error("panic")
}
}
private[timeseries] def split(interval: Interval[Instant]) = {
Expand All @@ -51,6 +53,8 @@ sealed trait TimeSeriesGrid {
interval match {
case Interval(Finite(lo), Finite(hi)) =>
go(lo, hi)
case _ =>
sys.error("panic")
}
}
}
Expand Down Expand Up @@ -274,12 +278,12 @@ case class TimeSeriesScheduler(logger: Logger) extends Scheduler[TimeSeries] wit
.queryBackfills(Some(sql"""status = 'RUNNING'"""))
.list
.map(_.map {
case (id, name, description, jobsIdsString, priority, start, end, created_at, status, created_by) =>
case (id, name, description, jobsIdsString, priority, start, end, _, status, createdBy) =>
val jobsIds = jobsIdsString.split(",")
val jobs = workflow.vertices.filter { job =>
jobsIds.contains(job.id)
}
Backfill(id, start, end, jobs, priority, name, description, status, created_by)
Backfill(id, start, end, jobs, priority, name, description, status, createdBy)
})
.transact(xa)
.unsafePerformIO
Expand All @@ -305,12 +309,11 @@ case class TimeSeriesScheduler(logger: Logger) extends Scheduler[TimeSeries] wit
case(_,_,effect) => effect.isCompleted
}

val now = Instant.now
val (stateSnapshot, completedBackfills, toRun) = atomic { implicit txn =>
val (stateSnapshot, newBackfills, completedBackfills) =
collectCompletedJobs(workflow, now, _state(), _backfills(), completed)
collectCompletedJobs(_state(), _backfills(), completed)

val toRun = jobsToRun(workflow, stateSnapshot, now)
val toRun = jobsToRun(workflow, stateSnapshot, Instant.now)

_state() = stateSnapshot
_backfills() = newBackfills
Expand Down Expand Up @@ -373,8 +376,6 @@ case class TimeSeriesScheduler(logger: Logger) extends Scheduler[TimeSeries] wit
}

private[timeseries] def collectCompletedJobs(
workflow : Workflow[TimeSeries],
now : Instant,
state : State,
backfills : Set[Backfill],
completed : Set[Run]) : (State, Set[Backfill], Set[Backfill]) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ private[timeseries] object IntervalMap {
val (leftOfLow, rightOfLow) = tree.span(lower(interval))

val withoutLow = leftOfLow.viewRight match {
case ViewRightCons(_, (Interval(lo, hi), v)) if hi > interval.lo =>
case ViewRightCons(_, (Interval(_, hi), v)) if hi > interval.lo =>
(Interval(interval.lo, hi) -> v) +: rightOfLow
case _ =>
rightOfLow
}
val (leftOfHigh, rightOfHigh) = withoutLow.span(greater(interval))

val newTree = rightOfHigh.viewLeft match {
case ViewLeftCons((Interval(lo, hi), v), _) if lo < interval.hi =>
case ViewLeftCons((Interval(lo, _), v), _) if lo < interval.hi =>
leftOfHigh :+ (Interval(lo, interval.hi) -> v)
case _ =>
leftOfHigh
Expand Down