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

Upgrade to Play 3 #7562

Merged
merged 7 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Updated antd UI library from version 4.24.8 to 4.24.15. [#7505](https://github.com/scalableminds/webknossos/pull/7505)
- Changed the default dataset search mode to also search in subfolders. [#7539](https://github.com/scalableminds/webknossos/pull/7539)
- When clicking a segment in the viewport, it is automatically focused in the segment list. A corresponding context menu entry was added as well. [#7512](https://github.com/scalableminds/webknossos/pull/7512)
- Upgraded to Play 3. [#7562](https://github.com/scalableminds/webknossos/pull/7562)
- Updated the isValidName route in the API to return 200 for valid and invalid names. With this, the API version was bumped up to 6. [#7550](https://github.com/scalableminds/webknossos/pull/7550)
- The metadata for ND datasets and their annotation has changed: upper bound of additionalAxes is now stored as an exclusive value, called "end" in the NML format. [#7547](https://github.com/scalableminds/webknossos/pull/7547)

Expand Down
3 changes: 3 additions & 0 deletions MIGRATIONS.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ User-facing changes are documented in the [changelog](CHANGELOG.released.md).
- If your setup contains webknossos-workers, you may want to add the new available worker job `compute_segment_index_file` to the `supportedJobCommands` column of one or more of your workers. [#7493](https://github.com/scalableminds/webknossos/pull/7493)
- The WEBKNOSSOS api version has changed to 6. The `isValidNewName` route for datasets now returns 200 regardless of whether the name is valid or not. The body contains a JSON object with the key "isValid". [#7550](https://github.com/scalableminds/webknossos/pull/7550)
- If your setup contains ND datasets, run the python3 script at `tools/migrate-axis-bounds/migration.py` on your datastores to update the datasource-properties.jsons of the ND datasets.
- With the upgrade to Play 3 and the migration to pekko, configuration keys using akka need to be changed. For the default configuration this results in the following changes:
- akka.requestTimeout → pekko.requestTimeout
- akka.actor.default-dispatcher → pekko.actor.default-dispatcher

### Postgres Evolutions:

Expand Down
2 changes: 1 addition & 1 deletion app/Startup.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import akka.actor.{ActorSystem, Props}
import org.apache.pekko.actor.{ActorSystem, Props}
import cleanup.CleanUpService
import com.typesafe.scalalogging.LazyLogging
import controllers.InitialDataService
Expand Down
8 changes: 4 additions & 4 deletions app/cleanup/CleanUpService.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cleanup

import akka.actor.{ActorSystem, Cancellable}
import org.apache.pekko.actor.{ActorSystem, Cancellable}
import com.scalableminds.util.tools.Fox
import com.typesafe.scalalogging.LazyLogging
import javax.inject.Inject
Expand All @@ -11,18 +11,18 @@ import scala.concurrent.duration.FiniteDuration

class CleanUpService @Inject()(system: ActorSystem)(implicit ec: ExecutionContext) extends LazyLogging {

@volatile private var akkaIsShuttingDown = false
@volatile private var pekkoIsShuttingDown = false

system.registerOnTermination {
akkaIsShuttingDown = true
pekkoIsShuttingDown = true
}

def register[T](description: String, interval: FiniteDuration, runOnShutdown: Boolean = false)(
job: => Fox[T]): Cancellable =
system.scheduler.scheduleWithFixedDelay(interval, interval)(() => runJob(description, job, runOnShutdown))

private def runJob[T](description: String, job: => Fox[T], runOnShutdown: Boolean): Unit =
if (!akkaIsShuttingDown || runOnShutdown) {
if (!pekkoIsShuttingDown || runOnShutdown) {
job.futureBox.map {
case Full(value) =>
logger.info(s"Completed cleanup job: $description. Result: " + value)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/AnnotationController.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package controllers

import akka.util.Timeout
import org.apache.pekko.util.Timeout
import play.silhouette.api.Silhouette
import com.scalableminds.util.accesscontext.{DBAccessContext, GlobalAccessContext}
import com.scalableminds.util.geometry.BoundingBox
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/AnnotationIOController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package controllers

import java.io.{BufferedOutputStream, File, FileOutputStream}
import java.util.zip.Deflater
import akka.actor.ActorSystem
import akka.stream.Materializer
import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.stream.Materializer
import play.silhouette.api.Silhouette
import com.scalableminds.util.accesscontext.{DBAccessContext, GlobalAccessContext}
import com.scalableminds.util.io.ZipIO
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Application.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package controllers

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import play.silhouette.api.Silhouette
import com.scalableminds.util.tools.{Fox, FoxImplicits}
import com.typesafe.config.ConfigRenderOptions
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/AuthenticationController.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package controllers

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import play.silhouette.api.actions.SecuredRequest
import play.silhouette.api.exceptions.ProviderException
import play.silhouette.api.services.AuthenticatorResult
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/OrganizationController.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package controllers

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import play.silhouette.api.Silhouette
import com.scalableminds.util.accesscontext.{DBAccessContext, GlobalAccessContext}
import com.scalableminds.util.time.Instant
Expand Down
2 changes: 1 addition & 1 deletion app/mail/MailchimpTicker.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mail

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import com.scalableminds.util.accesscontext.{DBAccessContext, GlobalAccessContext}
import com.scalableminds.util.time.Instant
import com.scalableminds.util.tools.Fox
Expand Down
2 changes: 1 addition & 1 deletion app/mail/Mailer.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mail

import akka.actor._
import org.apache.pekko.actor._
import com.typesafe.scalalogging.LazyLogging
import javax.mail.internet.InternetAddress
import org.apache.commons.mail._
Expand Down
2 changes: 1 addition & 1 deletion app/models/annotation/AnnotationMutexService.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package models.annotation

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import com.scalableminds.util.accesscontext.GlobalAccessContext
import com.scalableminds.util.time.Instant
import com.scalableminds.util.tools.Fox
Expand Down
4 changes: 2 additions & 2 deletions app/models/annotation/AnnotationService.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package models.annotation

import akka.actor.ActorSystem
import akka.stream.Materializer
import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.stream.Materializer
import com.scalableminds.util.accesscontext.{AuthorizedAccessContext, DBAccessContext, GlobalAccessContext}
import com.scalableminds.util.geometry.{BoundingBox, Vec3Double, Vec3Int}
import com.scalableminds.util.io.{NamedStream, ZipIO}
Expand Down
2 changes: 1 addition & 1 deletion app/models/job/Job.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package models.job

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import com.scalableminds.util.accesscontext.{DBAccessContext, GlobalAccessContext}
import com.scalableminds.util.geometry.{BoundingBox, Vec3Int}
import com.scalableminds.util.mvc.Formatter
Expand Down
2 changes: 1 addition & 1 deletion app/models/job/Worker.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package models.job

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import com.scalableminds.util.accesscontext.GlobalAccessContext
import com.scalableminds.util.mvc.Formatter
import com.scalableminds.util.time.Instant
Expand Down
2 changes: 1 addition & 1 deletion app/models/storage/UsedStorageService.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package models.storage

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import com.scalableminds.util.accesscontext.{DBAccessContext, GlobalAccessContext}
import com.scalableminds.util.time.Instant
import com.scalableminds.util.tools.Fox
Expand Down
2 changes: 1 addition & 1 deletion app/models/user/EmailVerificationService.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package models.user

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import com.scalableminds.util.accesscontext.DBAccessContext
import com.scalableminds.util.time.Instant
import com.scalableminds.util.tools.Fox
Expand Down
2 changes: 1 addition & 1 deletion app/models/user/Invite.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package models.user

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import com.scalableminds.util.accesscontext.DBAccessContext
import com.scalableminds.util.time.Instant
import com.scalableminds.util.tools.{Fox, FoxImplicits}
Expand Down
2 changes: 1 addition & 1 deletion app/models/user/UserService.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package models.user

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import play.silhouette.api.LoginInfo
import play.silhouette.api.services.IdentityService
import play.silhouette.api.util.PasswordInfo
Expand Down
5 changes: 3 additions & 2 deletions app/models/voxelytics/LokiClient.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package models.voxelytics

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.pattern.after
import com.scalableminds.util.mvc.MimeTypes
import com.scalableminds.util.time.Instant
import com.scalableminds.util.tools.Fox
Expand Down Expand Up @@ -42,7 +43,7 @@ class LokiClient @Inject()(wkConf: WkConf, rpc: RPC, val system: ActorSystem)(im
private def pollUntilServerStartedUp(until: Instant): Fox[Unit] = {
def waitAndRecurse(until: Instant): Fox[Unit] =
for {
_ <- akka.pattern.after(POLLING_INTERVAL, using = system.scheduler)(Future.successful(()))
_ <- after(POLLING_INTERVAL, using = system.scheduler)(Future.successful(()))
_ <- bool2Fox(!until.isPast) ?~> s"Loki did not become ready within ${conf.startupTimeout}."
_ <- pollUntilServerStartedUp(until)
} yield ()
Expand Down
2 changes: 1 addition & 1 deletion app/opengraph/OpenGraphService.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package opengraph

import akka.http.scaladsl.model.Uri
import org.apache.pekko.http.scaladsl.model.Uri
import com.google.inject.Inject
import com.scalableminds.util.accesscontext.DBAccessContext
import com.scalableminds.util.enumeration.ExtendedEnumeration
Expand Down
2 changes: 1 addition & 1 deletion app/thirdparty/BrainTracing.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package thirdparty

import akka.actor.{ActorSelection, ActorSystem}
import org.apache.pekko.actor.{ActorSelection, ActorSystem}
import com.scalableminds.util.accesscontext.GlobalAccessContext
import com.scalableminds.util.security.SCrypt
import com.scalableminds.util.tools.{Fox, FoxImplicits}
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ThisBuild / javacOptions ++= Seq(
)
ThisBuild / dependencyCheckAssemblyAnalyzerEnabled := Some(false)

PlayKeys.devSettings := Seq("play.server.akka.requestTimeout" -> "10000s", "play.server.http.idleTimeout" -> "10000s")
PlayKeys.devSettings := Seq("play.server.pekko.requestTimeout" -> "10000s", "play.server.http.idleTimeout" -> "10000s")

// Disable unused import warnings, only in sbt console REPL
Compile / console / scalacOptions -= "-Xlint:unused"
Expand Down
4 changes: 2 additions & 2 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ play {
# Timeouts. Note that these take effect only in production mode (timeouts are shorter in dev)
server {
http.idleTimeout = 2 hours
akka.requestTimeout = 2 hours
pekko.requestTimeout = 2 hours
}
assets {
cache {
Expand All @@ -72,7 +72,7 @@ play {
}
}

akka.actor.default-dispatcher {
pekko.actor.default-dispatcher {
# We use a compromise for our thread pool configuration
# Parts of our api are async, so they should not need many threads,
# but some parts are also blocking (file io, gcs, s3 access), causing new requests
Expand Down
2 changes: 1 addition & 1 deletion conf/logback-dev.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<logger name="controllers" level="DEBUG" />
<logger name="controllers.AssetsConfiguration" level="INFO" />
<logger name="models" level="DEBUG" />
<logger name="akka.event" level="WARN" />
<logger name="pekko.event" level="WARN" />

<root level="INFO">
<appender-ref ref="STDOUT" />
Expand Down
2 changes: 1 addition & 1 deletion conf/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<logger name="controllers" level="DEBUG" />
<logger name="controllers.AssetsConfiguration" level="INFO" />
<logger name="models" level="DEBUG" />
<logger name="akka.event" level="WARN" />
<logger name="org.apache.pekko.event" level="WARN" />

<root level="INFO">
<appender-ref ref="STDOUT" />
Expand Down
8 changes: 4 additions & 4 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import play.sbt.PlayImport.{filters, _}
import sbt._

object Dependencies {
private val silhouetteVersion = "9.0.0"
private val silhouetteVersion = "10.0.0"
private val brotliVersion = "1.11.0"
private val scalapbVersion = scalapb.compiler.Version.scalapbVersion
private val grpcVersion = scalapb.compiler.Version.grpcJavaVersion

val utilDependencies: Seq[ModuleID] = Seq(
// Play Web Framework. import play
"com.typesafe.play" %% "play" % "2.9.0",
"org.playframework" %% "play" % "3.0.1",
// Play’s JSON serialization. import play.api.libs.json
"com.typesafe.play" %% "play-json" % "2.10.1",
// Sending emails. import org.apache.commons.mail
Expand Down Expand Up @@ -85,8 +85,8 @@ object Dependencies {
val webknossosDependencies: Seq[ModuleID] = Seq(
// Base64, Hashing. import org.apache.commons.codec
"commons-codec" % "commons-codec" % "1.16.0",
// End-to-end tests. import org.scalatestplus.play
"org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % "test",
// End-to-end tests, backend unit tests. import org.scalatestplus.play
"org.scalatestplus.play" %% "scalatestplus-play" % "7.0.1" % "test",
// Authenticated requests. import play.silhouette
"org.playframework.silhouette" %% "play-silhouette" % silhouetteVersion,
// Signing Cookies. import play.silhouette.crypto
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// play framework
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.0-RC3")
addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.1")

// buildinfo routes
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import net.liftweb.common.{Box, Failure}

import java.util.concurrent.{CompletableFuture, Executor, TimeUnit}
import java.util.function.BiFunction
import scala.compat.java8.FunctionConverters.asJavaBiFunction
import scala.compat.java8.FutureConverters.{CompletionStageOps, FutureOps}
import scala.jdk.FunctionWrappers.AsJavaBiFunction
import scala.jdk.FutureConverters.{CompletionStageOps, FutureOps}
import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.duration.{DurationInt, FiniteDuration}
import scala.jdk.CollectionConverters._
Expand All @@ -25,7 +25,7 @@ class AlfuCache[K, V](store: AsyncCache[K, Box[V]]) extends FoxImplicits {
} yield result

private def getOrLoadAdapter(key: K, loadValue: K => Future[Box[V]]): Future[Box[V]] =
store.get(key, AlfuCache.toJavaMappingFunction[K, Box[V]](loadValue)).toScala
store.get(key, AlfuCache.toJavaMappingFunction[K, Box[V]](loadValue)).asScala

def remove(key: K): Unit = store.synchronous().invalidate(key)

Expand Down Expand Up @@ -73,7 +73,7 @@ object AlfuCache {
}

private def toJavaMappingFunction[K, V](loadValue: K => Future[V]): BiFunction[K, Executor, CompletableFuture[V]] =
asJavaBiFunction[K, Executor, CompletableFuture[V]]((k, _) => loadValue(k).toJava.toCompletableFuture)
new AsJavaBiFunction[K, Executor, CompletableFuture[V]]((k, _) => loadValue(k).asJava.toCompletableFuture)

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.scalableminds.webknossos.datastore

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import com.google.inject.AbstractModule
import com.google.inject.name.Names
import com.scalableminds.webknossos.datastore.services._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.scalableminds.webknossos.datastore.helpers

import akka.actor.{ActorSystem, Cancellable}
import org.apache.pekko.actor.{ActorSystem, Cancellable}
import play.api.inject.ApplicationLifecycle

import scala.concurrent.{ExecutionContext, Future}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.scalableminds.webknossos.datastore.services

import java.nio._
import akka.actor.{Actor, ActorRef, ActorSystem, Props}
import akka.pattern.ask
import akka.routing.RoundRobinPool
import akka.util.Timeout
import org.apache.pekko.actor.{Actor, ActorRef, ActorSystem, Props}
import org.apache.pekko.pattern.ask
import org.apache.pekko.routing.RoundRobinPool
import org.apache.pekko.util.Timeout
import com.scalableminds.util.geometry.{BoundingBox, Vec3Double, Vec3Int}
import com.scalableminds.util.tools.{Fox, FoxImplicits}
import com.scalableminds.webknossos.datastore.models.AdditionalCoordinate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.scalableminds.webknossos.datastore.services

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import javax.inject.Inject

import scala.concurrent.ExecutionContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.scalableminds.webknossos.datastore.services

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import com.google.inject.Inject
import com.google.inject.name.Named
import com.scalableminds.util.cache.AlfuCache
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.scalableminds.webknossos.datastore.services

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import com.google.inject.Inject
import com.google.inject.name.Named
import com.scalableminds.webknossos.datastore.models.datasource.inbox.InboxDataSource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.scalableminds.webknossos.datastore.services

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import com.google.inject.Inject
import com.google.inject.name.Named
import com.scalableminds.util.io.PathUtils
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.scalableminds.webknossos.datastore.services

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import com.google.inject.name.Named
import com.scalableminds.webknossos.datastore.helpers.IntervalScheduler
import com.typesafe.scalalogging.LazyLogging
Expand Down
Loading